Wiki

Ticket #215: lib-tests.patch

File lib-tests.patch, 3.6 KB (added by hopscc, 12 years ago)
  • Source/CommandLine.cobra

     
    463463        { 
    464464            'name': 'test-runner', 
    465465            'type': 'string', 
    466             'description': 'Specify the method to invoke to run the unit tests. The method must be "shared". Typically the method will make use of classes in Cobra.Core.Test to set up and initiate the test run.', 
    467             'default': 'Cobra.Core.CobraCore.runAllTests', 
     466            'description': 'Specify the method to invoke to run the unit tests. The default runs all tests in the local Assembly, specify "Cobra.Core.CobraCore.runAllTests" to run tests in libraries as well. The method must be "shared". Typically the method will make use of classes in Cobra.Core.Test to set up and initiate the test run.', 
     467            'default': 'Cobra.Core.CobraCore.runAppTests', 
    468468            'args': 'QUALIFIED-METHOD-NAME|nil', 
    469469        }, 
    470470        { 
  • Source/BackEndClr/SharpGenerator.cobra

     
    131131            if target.length 
    132132                if target=='lib', target = 'library' 
    133133                backEndOptions.add('[optChar]target:[target]') 
     134 
     135                if options.boolValue('test') 
     136                    sub='To run the tests in libraries, compile a program that refs the library(ies) and compile it with option "-test-runner:Cobra.Core.CobraCore.runAllTests"' 
     137                    .recordError(SourceException('Cannot specify "-test" with "-target:lib" since csc disallows a main method with library targets. [sub]')) 
     138                    return 
    134139                 
    135140            delaySign = options.boolValue('delay-sign') 
    136141            if delaySign, backEndOptions.add('[optChar]delaysign+') 
  • Source/Cobra.Core/CobraCore.cobra

     
    136136 
    137137            ## Run Tests 
    138138 
     139            def runAppTests  
     140                _runAllTests(false) 
     141                 
    139142            def runAllTests 
     143                _runAllTests(true) 
     144 
     145            def _runAllTests(testDeep as bool) 
    140146                """ 
    141                 Run all Cobra `test` sections in all assemblies using reflection to locate them. 
     147                Run Cobra `test` sections in all assemblies using reflection to locate them. 
     148                Default is to just run tests in this assembly.  
     149                If testDeep is true will also run tests in all libraries referenced as well 
    142150                """ 
    143151                if CobraImp.showTestProgress, listener = Cobra.Core.Test.TextWriterListener(Console.out) 
    144152                else, listener = Cobra.Core.Test.TextWriterOnlyOnFailureListener(Console.out) 
    145153                tr = Cobra.Core.Test.TestRunner(listener) 
     154                if testDeep, tr.params.willTestLibraries = true 
    146155                tr.runAllTests 
    147156                if listener.testFailures, CobraCore.exit(1) 
    148157 
  • Source/Cobra.Core/Test.cobra

     
    8989     
    9090        pro willRunDry from var = false 
    9191     
     92        pro willTestLibraries  from var = false 
     93         
    9294        # TODO: pro excludeTests ... 
    9395 
    9496        # TODO: pro includeTests ... 
     
    109111     
    110112        pro listener from var as ITestRunListener? 
    111113 
    112         def runAllTests 
    113             .runTestsFor(Assembly.getEntryAssembly, false) 
     114        def runAllTests  
     115            # default is to not run tests in Libraries 
     116            .runTestsFor(Assembly.getEntryAssembly, .params.willTestLibraries) 
    114117 
    115118        def runTestsFor(ass as Assembly, willFollowReferences as bool) 
    116119            .runTestsFor(.collectTestsFor(ass, willFollowReferences))