Wiki
Show
Ignore:
Timestamp:
02/28/10 21:24:48 (2 years ago)
Author:
Chuck.Esterbrook
Message:

Added -test-runner command line option to specify the method to invoke to run the unit tests.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • cobra/trunk/Source/BackEndClr/SharpGenerator.cobra

    r2294 r2295  
    6262                if .hasExceptionReportOption 
    6363                    print '     try {' 
    64                 print '     CobraLangInternal.Test.ITestRunListener listener = new CobraLangInternal.Test.TextWriterListener(System.Console.Out);' 
    65                 print '     new CobraLangInternal.Test.TestRunner(listener).RunAllTests();' 
     64                .writeSharpRunAllTests(f) 
    6665                if .hasExceptionReportOption 
    6766                    print '     } catch (System.Exception e) {' 
     
    7271        .mainMethodTypeName = '_GeneratedTestRunner' 
    7372        _modules.add(SharpModule(fileName, _verbosity)) 
     73 
     74    def writeSharpRunAllTests(cw as CurlyWriter) 
     75        runner = .options['test-runner'] to String  # ex: Cobra.Lang.CobraCore.runAllTests, ex: MyProgram.runTests 
     76        if runner <> 'nil' 
     77            if runner.endsWith('()'), runner = runner[:-2] 
     78            if runner.startsWith('Cobra.Lang.'), runner = 'CobraLangInternal.' + runner['Cobra.Lang.'.length:] 
     79            parts = List<of String>(runner.split(c'.')) 
     80            if parts.count > 1 
     81                parts[parts.count-1] = parts.last[0].toUpper.toString + parts.last[1:] 
     82            stmt = parts.join('.') + '();' 
     83            cw.writeLine(stmt) 
    7484 
    7585    var _didWriteSharpInfoClass as bool 
     
    18401850                sw.indent 
    18411851        if .isMain and .compiler.options.boolValue('include-tests') 
    1842             sw.writeLine('CobraLangInternal.CobraCore.RunAllTests();  // turn off with -include-tests:no (see cobra -h)') 
     1852            (.compiler to Compiler).writeSharpRunAllTests(sw) 
    18431853 
    18441854    def writeSharpImpFooter(sw as CurlyWriter)