Ticket #195: test-fail.2.patch
File test-fail.2.patch, 2.3 KB (added by hopscc, 15 years ago) |
---|
-
Source/Cobra.Lang/CobraCore.cobra
138 138 Run all Cobra `test` sections in all assemblies using reflection to locate them. 139 139 """ 140 140 # start = DateTime.now 141 _runAllTests(Assembly.getEntryAssembly, Dictionary<of String, String>()) 141 if not _runAllTests(Assembly.getEntryAssembly, Dictionary<of String, String>()) 142 CobraCore.exit(3) # test failed 142 143 # duration = DateTime.now.subtract(start) 143 144 # trace duration 144 145 145 def _runAllTests(ass as Assembly, found as Dictionary<of String, String>) # CC: found should be Set<of String>146 def _runAllTests(ass as Assembly, found as Dictionary<of String, String>) as bool # CC: found should be Set<of String> 146 147 name = ass.getName.toString 147 148 if found.containsKey(name) 148 return 149 return true 149 150 found.add(name, name) 150 151 if _skipAssemblyNameForTesting(name) # saves some time 151 return 152 return true 152 153 154 result=true 153 155 # print 'Testing assembly:', ass 154 156 for type in ass.getExportedTypes 155 157 members = type.getMember('RunTestsIfNeeded') … … 161 163 # potential solution 1: move type test out of the type into a "sister" type: private __FooTest 162 164 # 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 165 continue 164 method.invoke(type, nil) 165 166 try 167 method.invoke(type, nil) 168 catch exc as Exception 169 print '** Test Failure: Exception in Test clause' 170 print exc.innerException 171 result = false 166 172 # traverse further assemblies 167 173 for assName in ass.getReferencedAssemblies 168 174 subAss = Assembly.load(assName) 169 _runAllTests(subAss to !, found) 170 175 result = _runAllTests(subAss to !, found) and result 176 return result 177 171 178 var _skipPrefixes = @['System.', 'Mono.', 'mscorlib,', 'System,'] 172 179 173 180 def _skipAssemblyNameForTesting(name as String) as bool … … 176 183 return true 177 184 return false 178 185 179 180 186 ## Detailed stack trace 181 187 182 188 pro maxStackFrames as int