Wiki
Show
Ignore:
Timestamp:
02/27/10 09:18:29 (2 years ago)
Author:
Chuck.Esterbrook
Message:

Use the new Cobra.Lang.Test.TestRunner? for running inline unit tests.
Fix some test cases from the last checkin.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • cobra/trunk/Source/Cobra.Lang/CobraCore.cobra

    r2229 r2291  
    138138                Run all Cobra `test` sections in all assemblies using reflection to locate them. 
    139139                """ 
    140                 # start = DateTime.now 
    141                 _runAllTests(Assembly.getEntryAssembly, Dictionary<of String, String>()) 
    142                 # duration = DateTime.now.subtract(start) 
    143                 # trace duration 
    144  
    145             def _runAllTests(ass as Assembly, found as Dictionary<of String, String>)  # CC: found should be Set<of String> 
    146                 name = ass.getName.toString 
    147                 if found.containsKey(name) 
    148                     return 
    149                 found.add(name, name) 
    150                 if _skipAssemblyNameForTesting(name)  # saves some time 
    151                     return 
    152  
    153                 # print 'Testing assembly:', ass 
    154                 for type in ass.getExportedTypes 
    155                     members = type.getMember('RunTestsIfNeeded') 
    156                     if members and members.length and members[0] inherits MethodInfo 
    157                         method = members[0] to MethodInfo 
    158                         # trace type, method 
    159                         if type.containsGenericParameters 
    160                             # TODO: this is quite awful. tests in generic types are being skipped! 
    161                             # potential solution 1: move type test out of the type into a "sister" type: private __FooTest 
    162                             # potential solution 2: require a constructed type in Cobra: `test Foo<of int> ...` and then put that in a method attribute in the gen C# and use that type 
    163                             continue 
    164                         method.invoke(type, nil) 
    165  
    166                 # traverse further assemblies 
    167                 for assName in ass.getReferencedAssemblies 
    168                     subAss = Assembly.load(assName) 
    169                     _runAllTests(subAss to !, found) 
     140                # listener = Cobra.Lang.Test.TextWriterListener(Console.out) 
     141                listener = Cobra.Lang.Test.TextWriterOnlyOnFailureListener(Console.out) 
     142                tr = Cobra.Lang.Test.TestRunner(listener) 
     143                tr.runAllTests 
    170144 
    171145            var _skipPrefixes = @['System.', 'Mono.', 'mscorlib,', 'System,']