@@ -277,16 +277,27 @@ elapsed = canonicalize(Dates.CompoundPeriod(t1-t0))
277277println (" Testing finished in $elapsed " )
278278
279279# construct a testset to render the test results
280- completed_tests = Set {String} ()
281280o_ts = Test. DefaultTestSet (" Overall" )
282- @static if VERSION < v " 1.13.0-DEV.1044"
283- Test. push_testset (o_ts)
281+ function with_testset (f, testset)
282+ @static if VERSION >= v " 1.13.0-DEV.1044"
283+ Test. @with_testset testset f ()
284+ else
285+ Test. push_testset (testset)
286+ try
287+ f ()
288+ finally
289+ Test. pop_testset ()
290+ end
291+ end
292+ end
293+ with_testset (o_ts) do
294+ completed_tests = Set {String} ()
284295 for (testname, (resp,)) in results
285296 push! (completed_tests, testname)
286297 if isa (resp, Test. DefaultTestSet)
287- Test . push_testset (resp)
288- Test. record (o_ts, resp)
289- Test . pop_testset ()
298+ with_testset (resp) do
299+ Test. record (o_ts, resp)
300+ end
290301 elseif isa (resp, Tuple{Int,Int})
291302 fake = Test. DefaultTestSet (testname)
292303 for i in 1 : resp[1 ]
@@ -295,9 +306,9 @@ o_ts = Test.DefaultTestSet("Overall")
295306 for i in 1 : resp[2 ]
296307 Test. record (fake, Test. Broken (:test , nothing ))
297308 end
298- Test . push_testset (fake)
299- Test. record (o_ts, fake)
300- Test . pop_testset ()
309+ with_testset (fake) do
310+ Test. record (o_ts, fake)
311+ end
301312 elseif isa (resp, RemoteException) && isa (resp. captured. ex, Test. TestSetException)
302313 println (" Worker $(resp. pid) failed running test $(testname) :" )
303314 Base. showerror (stdout , resp. captured)
@@ -312,9 +323,9 @@ o_ts = Test.DefaultTestSet("Overall")
312323 for t in resp. captured. ex. errors_and_fails
313324 Test. record (fake, t)
314325 end
315- Test . push_testset (fake)
316- Test. record (o_ts, fake)
317- Test . pop_testset ()
326+ with_testset (fake) do
327+ Test. record (o_ts, fake)
328+ end
318329 else
319330 if ! isa (resp, Exception)
320331 resp = ErrorException (string (" Unknown result type : " , typeof (resp)))
@@ -324,105 +335,28 @@ o_ts = Test.DefaultTestSet("Overall")
324335 # the test runner itself had some problem, so we may have hit a segfault,
325336 # deserialization errors or something similar. Record this testset as Errored.
326337 fake = Test. DefaultTestSet (testname)
327- Test. record (fake, Test. Error (:nontest_error , testname, nothing , Any[(resp, [])], LineNumberNode (1 )))
328- Test. push_testset (fake)
329- Test. record (o_ts, fake)
330- Test. pop_testset ()
331- end
332- end
333- for test in all_tests
334- (test in completed_tests) && continue
335- fake = Test. DefaultTestSet (test)
336- Test. record (fake, Test. Error (:test_interrupted , test, nothing ,
337- [(" skipped" , [])], LineNumberNode (1 )))
338- Test. push_testset (fake)
339- Test. record (o_ts, fake)
340- Test. pop_testset ()
341- end
342- println ()
343- Test. print_test_results (o_ts, 1 )
344- if ! o_ts. anynonpass
345- println (" \0 33[32;1mSUCCESS\0 33[0m" )
346- else
347- println (" \0 33[31;1mFAILURE\0 33[0m\n " )
348- Test. print_test_errors (o_ts)
349- throw (Test. FallbackTestSetException (" Test run finished with errors" ))
350- end
351- else
352- Test. @with_testset o_ts begin
353- for (testname, (resp,)) in results
354- push! (completed_tests, testname)
355- if isa (resp, Test. DefaultTestSet)
356- Test. @with_testset resp begin
357- Test. record (o_ts, resp)
358- end
359- elseif isa (resp, Tuple{Int,Int})
360- fake = Test. DefaultTestSet (testname)
361- for i in 1 : resp[1 ]
362- Test. record (fake, Test. Pass (:test , nothing , nothing , nothing , nothing ))
363- end
364- for i in 1 : resp[2 ]
365- Test. record (fake, Test. Broken (:test , nothing ))
366- end
367- Test. @with_testset fake begin
368- Test. record (o_ts, fake)
369- end
370- elseif isa (resp, RemoteException) && isa (resp. captured. ex, Test. TestSetException)
371- println (" Worker $(resp. pid) failed running test $(testname) :" )
372- Base. showerror (stdout , resp. captured)
373- println ()
374- fake = Test. DefaultTestSet (testname)
375- for i in 1 : resp. captured. ex. pass
376- Test. record (fake, Test. Pass (:test , nothing , nothing , nothing , nothing ))
377- end
378- for i in 1 : resp. captured. ex. broken
379- Test. record (fake, Test. Broken (:test , nothing ))
380- end
381- for t in resp. captured. ex. errors_and_fails
382- Test. record (fake, t)
383- end
384- Test. @with_testset fake begin
385- Test. record (o_ts, fake)
386- end
387- else
388- if ! isa (resp, Exception)
389- resp = ErrorException (string (" Unknown result type : " , typeof (resp)))
390- end
391- # If this test raised an exception that is not a remote testset exception,
392- # i.e. not a RemoteException capturing a TestSetException that means
393- # the test runner itself had some problem, so we may have hit a segfault,
394- # deserialization errors or something similar. Record this testset as Errored.
395- fake = Test. DefaultTestSet (testname)
396- Test. record (fake, Test. Error (:nontest_error , testname, nothing , Base. ExceptionStack ([(exception= resp,backtrace= [])]), LineNumberNode (1 )))
397- Test. @with_testset fake begin
398- Test. record (o_ts, fake)
399- end
338+ Test. record (fake, Test. Error (:nontest_error , testname, nothing , Base. ExceptionStack ([(exception= resp,backtrace= [])]), LineNumberNode (1 )))
339+ with_testset (fake) do
340+ Test. record (o_ts, fake)
400341 end
401342 end
402343 end
403- for test in all_tests
344+ for test in tests
404345 (test in completed_tests) && continue
405346 fake = Test. DefaultTestSet (test)
406347 Test. record (fake, Test. Error (:test_interrupted , test, nothing , Base. ExceptionStack ([(exception= " skipped" ,backtrace= [])]), LineNumberNode (1 )))
407- Test . @ with_testset fake begin
348+ with_testset ( fake) do
408349 Test. record (o_ts, fake)
409350 end
410351 end
411- println ()
412- Test. print_test_results (o_ts, 1 )
413-
414- success = @static if VERSION < v " 1.13.0-DEV.1044"
415- ! o_ts. anynonpass
416- else
417- o_ts. anynonpass == 0x01
418- end
419-
420- if success
421- println (" \0 33[32;1mSUCCESS\0 33[0m" )
422- else
423- println (" \0 33[31;1mFAILURE\0 33[0m\n " )
424- Test. print_test_errors (o_ts)
425- throw (Test. FallbackTestSetException (" Test run finished with errors" ))
426- end
427352end
428-
353+ println ()
354+ Test. print_test_results (o_ts, 1 )
355+ if (VERSION >= v " 1.13.0-DEV.1037" && ! Test. anynonpass (o_ts)) ||
356+ (VERSION < v " 1.13.0-DEV.1037" && ! o_ts. anynonpass)
357+ println (" \0 33[32;1mSUCCESS\0 33[0m" )
358+ else
359+ println (" \0 33[31;1mFAILURE\0 33[0m\n " )
360+ Test. print_test_errors (o_ts)
361+ throw (Test. FallbackTestSetException (" Test run finished with errors" ))
362+ end
0 commit comments