Skip to content

Commit abd6fdf

Browse files
authored
Merge pull request #621 from JuliaGPU/ksh/testset_nightly
Try using the new with-testset for nightly
1 parent ea52033 commit abd6fdf

File tree

2 files changed

+146
-64
lines changed

2 files changed

+146
-64
lines changed

test/runtests.jl

Lines changed: 136 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -276,75 +276,149 @@ t1 = now()
276276
elapsed = canonicalize(Dates.CompoundPeriod(t1-t0))
277277
println("Testing finished in $elapsed")
278278

279-
# construct a testset to render the test results
280-
o_ts = Test.DefaultTestSet("Overall")
281-
Test.push_testset(o_ts)
282-
completed_tests = Set{String}()
283-
for (testname, (resp,)) in results
284-
push!(completed_tests, testname)
285-
if isa(resp, Test.DefaultTestSet)
286-
Test.push_testset(resp)
287-
Test.record(o_ts, resp)
288-
Test.pop_testset()
289-
elseif isa(resp, Tuple{Int,Int})
290-
fake = Test.DefaultTestSet(testname)
291-
for i in 1:resp[1]
292-
Test.record(fake, Test.Pass(:test, nothing, nothing, nothing, nothing))
293-
end
294-
for i in 1:resp[2]
295-
Test.record(fake, Test.Broken(:test, nothing))
279+
@static if VERSION < v"1.13.0-DEV.1044"
280+
# construct a testset to render the test results
281+
o_ts = Test.DefaultTestSet("Overall")
282+
Test.push_testset(o_ts)
283+
completed_tests = Set{String}()
284+
for (testname, (resp,)) in results
285+
push!(completed_tests, testname)
286+
if isa(resp, Test.DefaultTestSet)
287+
Test.push_testset(resp)
288+
Test.record(o_ts, resp)
289+
Test.pop_testset()
290+
elseif isa(resp, Tuple{Int,Int})
291+
fake = Test.DefaultTestSet(testname)
292+
for i in 1:resp[1]
293+
Test.record(fake, Test.Pass(:test, nothing, nothing, nothing, nothing))
294+
end
295+
for i in 1:resp[2]
296+
Test.record(fake, Test.Broken(:test, nothing))
297+
end
298+
Test.push_testset(fake)
299+
Test.record(o_ts, fake)
300+
Test.pop_testset()
301+
elseif isa(resp, RemoteException) && isa(resp.captured.ex, Test.TestSetException)
302+
println("Worker $(resp.pid) failed running test $(testname):")
303+
Base.showerror(stdout, resp.captured)
304+
println()
305+
fake = Test.DefaultTestSet(testname)
306+
for i in 1:resp.captured.ex.pass
307+
Test.record(fake, Test.Pass(:test, nothing, nothing, nothing, nothing))
308+
end
309+
for i in 1:resp.captured.ex.broken
310+
Test.record(fake, Test.Broken(:test, nothing))
311+
end
312+
for t in resp.captured.ex.errors_and_fails
313+
Test.record(fake, t)
314+
end
315+
Test.push_testset(fake)
316+
Test.record(o_ts, fake)
317+
Test.pop_testset()
318+
else
319+
if !isa(resp, Exception)
320+
resp = ErrorException(string("Unknown result type : ", typeof(resp)))
321+
end
322+
# If this test raised an exception that is not a remote testset exception,
323+
# i.e. not a RemoteException capturing a TestSetException that means
324+
# the test runner itself had some problem, so we may have hit a segfault,
325+
# deserialization errors or something similar. Record this testset as Errored.
326+
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()
296331
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)))
297338
Test.push_testset(fake)
298339
Test.record(o_ts, fake)
299340
Test.pop_testset()
300-
elseif isa(resp, RemoteException) && isa(resp.captured.ex, Test.TestSetException)
301-
println("Worker $(resp.pid) failed running test $(testname):")
302-
Base.showerror(stdout, resp.captured)
303-
println()
304-
fake = Test.DefaultTestSet(testname)
305-
for i in 1:resp.captured.ex.pass
306-
Test.record(fake, Test.Pass(:test, nothing, nothing, nothing, nothing))
307-
end
308-
for i in 1:resp.captured.ex.broken
309-
Test.record(fake, Test.Broken(:test, nothing))
341+
end
342+
println()
343+
Test.print_test_results(o_ts, 1)
344+
if !o_ts.anynonpass
345+
println(" \033[32;1mSUCCESS\033[0m")
346+
else
347+
println(" \033[31;1mFAILURE\033[0m\n")
348+
Test.print_test_errors(o_ts)
349+
throw(Test.FallbackTestSetException("Test run finished with errors"))
350+
end
351+
else
352+
# construct a testset to render the test results
353+
o_ts = Test.DefaultTestSet("Overall")
354+
Test.@with_testset o_ts begin
355+
completed_tests = Set{String}()
356+
for (testname, (resp,)) in results
357+
push!(completed_tests, testname)
358+
if isa(resp, Test.DefaultTestSet)
359+
Test.@with_testset resp begin
360+
Test.record(o_ts, resp)
361+
end
362+
elseif isa(resp, Tuple{Int,Int})
363+
fake = Test.DefaultTestSet(testname)
364+
for i in 1:resp[1]
365+
Test.record(fake, Test.Pass(:test, nothing, nothing, nothing, nothing))
366+
end
367+
for i in 1:resp[2]
368+
Test.record(fake, Test.Broken(:test, nothing))
369+
end
370+
Test.@with_testset fake begin
371+
Test.record(o_ts, fake)
372+
end
373+
elseif isa(resp, RemoteException) && isa(resp.captured.ex, Test.TestSetException)
374+
println("Worker $(resp.pid) failed running test $(testname):")
375+
Base.showerror(stdout, resp.captured)
376+
println()
377+
fake = Test.DefaultTestSet(testname)
378+
for i in 1:resp.captured.ex.pass
379+
Test.record(fake, Test.Pass(:test, nothing, nothing, nothing, nothing))
380+
end
381+
for i in 1:resp.captured.ex.broken
382+
Test.record(fake, Test.Broken(:test, nothing))
383+
end
384+
for t in resp.captured.ex.errors_and_fails
385+
Test.record(fake, t)
386+
end
387+
Test.@with_testset fake begin
388+
Test.record(o_ts, fake)
389+
end
390+
else
391+
if !isa(resp, Exception)
392+
resp = ErrorException(string("Unknown result type : ", typeof(resp)))
393+
end
394+
# If this test raised an exception that is not a remote testset exception,
395+
# i.e. not a RemoteException capturing a TestSetException that means
396+
# the test runner itself had some problem, so we may have hit a segfault,
397+
# deserialization errors or something similar. Record this testset as Errored.
398+
fake = Test.DefaultTestSet(testname)
399+
Test.record(fake, Test.Error(:nontest_error, testname, nothing, Base.ExceptionStack([(exception=resp,backtrace=[])]), LineNumberNode(1)))
400+
Test.@with_testset fake begin
401+
Test.record(o_ts, fake)
402+
end
403+
end
310404
end
311-
for t in resp.captured.ex.errors_and_fails
312-
Test.record(fake, t)
405+
end
406+
for test in all_tests
407+
(test in completed_tests) && continue
408+
fake = Test.DefaultTestSet(test)
409+
Test.record(fake, Test.Error(:test_interrupted, test, nothing, Base.ExceptionStack([(exception="skipped",backtrace=[])]), LineNumberNode(1)))
410+
Test.@with_testset fake begin
411+
Test.record(o_ts, fake)
313412
end
314-
Test.push_testset(fake)
315-
Test.record(o_ts, fake)
316-
Test.pop_testset()
413+
end
414+
println()
415+
Test.print_test_results(o_ts, 1)
416+
if !o_ts.anynonpass
417+
println(" \033[32;1mSUCCESS\033[0m")
317418
else
318-
if !isa(resp, Exception)
319-
resp = ErrorException(string("Unknown result type : ", typeof(resp)))
320-
end
321-
# If this test raised an exception that is not a remote testset exception,
322-
# i.e. not a RemoteException capturing a TestSetException that means
323-
# the test runner itself had some problem, so we may have hit a segfault,
324-
# deserialization errors or something similar. Record this testset as Errored.
325-
fake = Test.DefaultTestSet(testname)
326-
Test.record(fake, Test.Error(:nontest_error, testname, nothing, Any[(resp, [])], LineNumberNode(1)))
327-
Test.push_testset(fake)
328-
Test.record(o_ts, fake)
329-
Test.pop_testset()
419+
println(" \033[31;1mFAILURE\033[0m\n")
420+
Test.print_test_errors(o_ts)
421+
throw(Test.FallbackTestSetException("Test run finished with errors"))
330422
end
331423
end
332-
for test in all_tests
333-
(test in completed_tests) && continue
334-
fake = Test.DefaultTestSet(test)
335-
Test.record(fake, Test.Error(:test_interrupted, test, nothing,
336-
[("skipped", [])], LineNumberNode(1)))
337-
Test.push_testset(fake)
338-
Test.record(o_ts, fake)
339-
Test.pop_testset()
340-
end
341-
println()
342-
Test.print_test_results(o_ts, 1)
343-
if !o_ts.anynonpass
344-
println(" \033[32;1mSUCCESS\033[0m")
345-
else
346-
println(" \033[31;1mFAILURE\033[0m\n")
347-
Test.print_test_errors(o_ts)
348-
throw(Test.FallbackTestSetException("Test run finished with errors"))
349-
end
350424

test/setup.jl

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ using Random
99

1010
function runtests(f, name)
1111
old_print_setting = Test.TESTSET_PRINT_ENABLE[]
12-
Test.TESTSET_PRINT_ENABLE[] = false
12+
@static if VERSION < v"1.13.0-DEV.1044"
13+
Test.TESTSET_PRINT_ENABLE[] = false
14+
else
15+
Test.TESTSET_PRINT_ENABLE[] => false
16+
end
1317

1418
try
1519
# generate a temporary module to execute the tests in
@@ -56,7 +60,11 @@ function runtests(f, name)
5660
GC.gc(true)
5761
res
5862
finally
59-
Test.TESTSET_PRINT_ENABLE[] = old_print_setting
63+
@static if VERSION < v"1.13.0-DEV.1044"
64+
Test.TESTSET_PRINT_ENABLE[] = old_print_setting
65+
else
66+
Test.TESTSET_PRINT_ENABLE[] => old_print_setting
67+
end
6068
end
6169
end
6270

0 commit comments

Comments
 (0)