@@ -45,6 +45,20 @@ function extract_flag!(args, flag, default = nothing; typ = typeof(default))
4545 return (false , default)
4646end
4747
48+ function with_testset (f, testset)
49+ @static if VERSION >= v " 1.13.0-DEV.1044"
50+ Test. @with_testset testset f ()
51+ else
52+ Test. push_testset (testset)
53+ try
54+ f ()
55+ finally
56+ Test. pop_testset ()
57+ end
58+ end
59+ return nothing
60+ end
61+
4862function runtests (ARGS , testfilter = _ -> true )
4963 do_help, _ = extract_flag! (ARGS , " --help" )
5064 if do_help
@@ -362,16 +376,15 @@ function runtests(ARGS, testfilter = _ -> true)
362376 println (" Testing finished in $elapsed " )
363377
364378 # construct a testset to render the test results
365- completed_tests = Set {String} ()
366379 o_ts = Test. DefaultTestSet (" Overall" )
367- @static if VERSION < v " 1.13.0-DEV.1044 "
368- Test . push_testset (o_ts )
380+ with_testset (o_ts) do
381+ completed_tests = Set {String} ( )
369382 for (testname, (resp,)) in results
370383 push! (completed_tests, testname)
371384 if isa (resp, Test. DefaultTestSet)
372- Test . push_testset (resp)
373- Test. record (o_ts, resp)
374- Test . pop_testset ()
385+ with_testset (resp) do
386+ Test. record (o_ts, resp)
387+ end
375388 elseif isa (resp, Tuple{Int, Int})
376389 fake = Test. DefaultTestSet (testname)
377390 for i in 1 : resp[1 ]
@@ -380,9 +393,9 @@ function runtests(ARGS, testfilter = _ -> true)
380393 for i in 1 : resp[2 ]
381394 Test. record (fake, Test. Broken (:test , nothing ))
382395 end
383- Test . push_testset (fake)
384- Test. record (o_ts, fake)
385- Test . pop_testset ()
396+ with_testset (fake) do
397+ Test. record (o_ts, fake)
398+ end
386399 elseif isa (resp, RemoteException) && isa (resp. captured. ex, Test. TestSetException)
387400 println (" Worker $(resp. pid) failed running test $(testname) :" )
388401 Base. showerror (stdout , resp. captured)
@@ -397,9 +410,9 @@ function runtests(ARGS, testfilter = _ -> true)
397410 for t in resp. captured. ex. errors_and_fails
398411 Test. record (fake, t)
399412 end
400- Test . push_testset (fake)
401- Test. record (o_ts, fake)
402- Test . pop_testset ()
413+ with_testset (fake) do
414+ Test. record (o_ts, fake)
415+ end
403416 else
404417 if ! isa (resp, Exception)
405418 resp = ErrorException (string (" Unknown result type : " , typeof (resp)))
@@ -409,95 +422,32 @@ function runtests(ARGS, testfilter = _ -> true)
409422 # the test runner itself had some problem, so we may have hit a segfault,
410423 # deserialization errors or something similar. Record this testset as Errored.
411424 fake = Test. DefaultTestSet (testname)
412- Test. record (fake, Test. Error (:nontest_error , testname, nothing , Any[(resp, [])], LineNumberNode (1 )))
413- Test. push_testset (fake)
414- Test. record (o_ts, fake)
415- Test. pop_testset ()
416- end
417- end
418- else
419- Test. @with_testset o_ts begin
420- for (testname, (resp,)) in results
421- push! (completed_tests, testname)
422- if isa (resp, Test. DefaultTestSet)
423- Test. @with_testset resp begin
424- Test. record (o_ts, resp)
425- end
426- elseif isa (resp, Tuple{Int, Int})
427- fake = Test. DefaultTestSet (testname)
428- for i in 1 : resp[1 ]
429- Test. record (fake, Test. Pass (:test , nothing , nothing , nothing , nothing ))
430- end
431- for i in 1 : resp[2 ]
432- Test. record (fake, Test. Broken (:test , nothing ))
433- end
434- Test. @with_testset fake begin
435- Test. record (o_ts, fake)
436- end
437- elseif isa (resp, RemoteException) && isa (resp. captured. ex, Test. TestSetException)
438- println (" Worker $(resp. pid) failed running test $(testname) :" )
439- Base. showerror (stdout , resp. captured)
440- println ()
441- fake = Test. DefaultTestSet (testname)
442- for i in 1 : resp. captured. ex. pass
443- Test. record (fake, Test. Pass (:test , nothing , nothing , nothing , nothing ))
444- end
445- for i in 1 : resp. captured. ex. broken
446- Test. record (fake, Test. Broken (:test , nothing ))
447- end
448- for t in resp. captured. ex. errors_and_fails
449- Test. record (fake, t)
450- end
451- Test. @with_testset fake begin
452- Test. record (o_ts, fake)
453- end
454- else
455- if ! isa (resp, Exception)
456- resp = ErrorException (string (" Unknown result type : " , typeof (resp)))
457- end
458- # If this test raised an exception that is not a remote testset exception,
459- # i.e. not a RemoteException capturing a TestSetException that means
460- # the test runner itself had some problem, so we may have hit a segfault,
461- # deserialization errors or something similar. Record this testset as Errored.
462- fake = Test. DefaultTestSet (testname)
463- Test. record (fake, Test. Error (:nontest_error , testname, nothing , Base. ExceptionStack ([(exception = resp, backtrace = [])]), LineNumberNode (1 )))
464- Test. @with_testset fake begin
465- Test. record (o_ts, fake)
466- end
425+ Test. record (fake, Test. Error (:nontest_error , testname, nothing , Base. ExceptionStack ([(exception = resp, backtrace = [])]), LineNumberNode (1 )))
426+ with_testset (fake) do
427+ Test. record (o_ts, fake)
467428 end
468429 end
469430 end
470- end
471- for test in tests
472- (test in completed_tests) && continue
473- fake = Test. DefaultTestSet (test)
474- @static if VERSION < v " 1.13.0-DEV.1044"
475- Test. record (
476- fake, Test. Error (
477- :test_interrupted , test, nothing ,
478- [(" skipped" , [])], LineNumberNode (1 )
479- )
480- )
481- Test. push_testset (fake)
482- Test. record (o_ts, fake)
483- Test. pop_testset ()
484- else
431+ for test in tests
432+ (test in completed_tests) && continue
433+ fake = Test. DefaultTestSet (test)
485434 Test. record (fake, Test. Error (:test_interrupted , test, nothing , Base. ExceptionStack ([(exception = " skipped" , backtrace = [])]), LineNumberNode (1 )))
486- Test . @ with_testset fake begin
435+ with_testset ( fake) do
487436 Test. record (o_ts, fake)
488437 end
489438 end
490439 end
491440 println ()
492441 Test. print_test_results (o_ts, 1 )
493- if ! o_ts. anynonpass
442+ if (VERSION >= v " 1.13.0-DEV.1037" && ! Test. anynonpass (o_ts)) ||
443+ (VERSION < v " 1.13.0-DEV.1037" && ! o_ts. anynonpass)
494444 println (" \0 33[32;1mSUCCESS\0 33[0m" )
495445 else
496446 println (" \0 33[31;1mFAILURE\0 33[0m\n " )
497447 Test. print_test_errors (o_ts)
498448 throw (Test. FallbackTestSetException (" Test run finished with errors" ))
499449 end
500-
450+ return nothing
501451end # runtests
502452
503- end # module ParallelTestRunner
453+ end # module ParallelTestRunner
0 commit comments