Skip to content

Commit 8a961f0

Browse files
kshyattmaleadt
andauthored
Use new ScopedValues testsets on nightly (#2889)
[only julia] Co-authored-by: Tim Besard <tim.besard@gmail.com>
1 parent c929405 commit 8a961f0

File tree

3 files changed

+122
-63
lines changed

3 files changed

+122
-63
lines changed

test/core/initialization.jl

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -177,13 +177,3 @@ end
177177
proc, out, err = julia_exec(`-e $script`, "CUDA_VISIBLE_DEVICES"=>"-1")
178178
@test success(proc)
179179
end
180-
181-
182-
## allocations
183-
184-
let broken = v"1.11.3" <= VERSION < v"1.11.5" && Base.JLOptions().code_coverage != 0
185-
@test @allocated(current_context()) == 0 broken=broken
186-
@test @allocated(context()) == 0 broken=broken
187-
@test @allocated(stream()) == 0 broken=broken
188-
@test @allocated(device()) == 0 broken=broken
189-
end

test/runtests.jl

Lines changed: 112 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -440,67 +440,128 @@ elapsed = canonicalize(Dates.CompoundPeriod(t1-t0))
440440
println("Testing finished in $elapsed")
441441

442442
# construct a testset to render the test results
443-
o_ts = Test.DefaultTestSet("Overall")
444-
Test.push_testset(o_ts)
445443
completed_tests = Set{String}()
446-
for (testname, (resp,)) in results
447-
push!(completed_tests, testname)
448-
if isa(resp, Test.DefaultTestSet)
449-
Test.push_testset(resp)
450-
Test.record(o_ts, resp)
451-
Test.pop_testset()
452-
elseif isa(resp, Tuple{Int,Int})
453-
fake = Test.DefaultTestSet(testname)
454-
for i in 1:resp[1]
455-
Test.record(fake, Test.Pass(:test, nothing, nothing, nothing, nothing))
456-
end
457-
for i in 1:resp[2]
458-
Test.record(fake, Test.Broken(:test, nothing))
459-
end
460-
Test.push_testset(fake)
461-
Test.record(o_ts, fake)
462-
Test.pop_testset()
463-
elseif isa(resp, RemoteException) && isa(resp.captured.ex, Test.TestSetException)
464-
println("Worker $(resp.pid) failed running test $(testname):")
465-
Base.showerror(stdout, resp.captured)
466-
println()
467-
fake = Test.DefaultTestSet(testname)
468-
for i in 1:resp.captured.ex.pass
469-
Test.record(fake, Test.Pass(:test, nothing, nothing, nothing, nothing))
470-
end
471-
for i in 1:resp.captured.ex.broken
472-
Test.record(fake, Test.Broken(:test, nothing))
444+
o_ts = Test.DefaultTestSet("Overall")
445+
@static if VERSION < v"1.13.0-DEV.1044"
446+
Test.push_testset(o_ts)
447+
for (testname, (resp,)) in results
448+
push!(completed_tests, testname)
449+
if isa(resp, Test.DefaultTestSet)
450+
Test.push_testset(resp)
451+
Test.record(o_ts, resp)
452+
Test.pop_testset()
453+
elseif isa(resp, Tuple{Int,Int})
454+
fake = Test.DefaultTestSet(testname)
455+
for i in 1:resp[1]
456+
Test.record(fake, Test.Pass(:test, nothing, nothing, nothing, nothing))
457+
end
458+
for i in 1:resp[2]
459+
Test.record(fake, Test.Broken(:test, nothing))
460+
end
461+
Test.push_testset(fake)
462+
Test.record(o_ts, fake)
463+
Test.pop_testset()
464+
elseif isa(resp, RemoteException) && isa(resp.captured.ex, Test.TestSetException)
465+
println("Worker $(resp.pid) failed running test $(testname):")
466+
Base.showerror(stdout, resp.captured)
467+
println()
468+
fake = Test.DefaultTestSet(testname)
469+
for i in 1:resp.captured.ex.pass
470+
Test.record(fake, Test.Pass(:test, nothing, nothing, nothing, nothing))
471+
end
472+
for i in 1:resp.captured.ex.broken
473+
Test.record(fake, Test.Broken(:test, nothing))
474+
end
475+
for t in resp.captured.ex.errors_and_fails
476+
Test.record(fake, t)
477+
end
478+
Test.push_testset(fake)
479+
Test.record(o_ts, fake)
480+
Test.pop_testset()
481+
else
482+
if !isa(resp, Exception)
483+
resp = ErrorException(string("Unknown result type : ", typeof(resp)))
484+
end
485+
# If this test raised an exception that is not a remote testset exception,
486+
# i.e. not a RemoteException capturing a TestSetException that means
487+
# the test runner itself had some problem, so we may have hit a segfault,
488+
# deserialization errors or something similar. Record this testset as Errored.
489+
fake = Test.DefaultTestSet(testname)
490+
Test.record(fake, Test.Error(:nontest_error, testname, nothing, Any[(resp, [])], LineNumberNode(1)))
491+
Test.push_testset(fake)
492+
Test.record(o_ts, fake)
493+
Test.pop_testset()
473494
end
474-
for t in resp.captured.ex.errors_and_fails
475-
Test.record(fake, t)
495+
end
496+
else
497+
Test.@with_testset o_ts begin
498+
for (testname, (resp,)) in results
499+
push!(completed_tests, testname)
500+
if isa(resp, Test.DefaultTestSet)
501+
Test.@with_testset resp begin
502+
Test.record(o_ts, resp)
503+
end
504+
elseif isa(resp, Tuple{Int,Int})
505+
fake = Test.DefaultTestSet(testname)
506+
for i in 1:resp[1]
507+
Test.record(fake, Test.Pass(:test, nothing, nothing, nothing, nothing))
508+
end
509+
for i in 1:resp[2]
510+
Test.record(fake, Test.Broken(:test, nothing))
511+
end
512+
Test.@with_testset fake begin
513+
Test.record(o_ts, fake)
514+
end
515+
elseif isa(resp, RemoteException) && isa(resp.captured.ex, Test.TestSetException)
516+
println("Worker $(resp.pid) failed running test $(testname):")
517+
Base.showerror(stdout, resp.captured)
518+
println()
519+
fake = Test.DefaultTestSet(testname)
520+
for i in 1:resp.captured.ex.pass
521+
Test.record(fake, Test.Pass(:test, nothing, nothing, nothing, nothing))
522+
end
523+
for i in 1:resp.captured.ex.broken
524+
Test.record(fake, Test.Broken(:test, nothing))
525+
end
526+
for t in resp.captured.ex.errors_and_fails
527+
Test.record(fake, t)
528+
end
529+
Test.@with_testset fake begin
530+
Test.record(o_ts, fake)
531+
end
532+
else
533+
if !isa(resp, Exception)
534+
resp = ErrorException(string("Unknown result type : ", typeof(resp)))
535+
end
536+
# If this test raised an exception that is not a remote testset exception,
537+
# i.e. not a RemoteException capturing a TestSetException that means
538+
# the test runner itself had some problem, so we may have hit a segfault,
539+
# deserialization errors or something similar. Record this testset as Errored.
540+
fake = Test.DefaultTestSet(testname)
541+
Test.record(fake, Test.Error(:nontest_error, testname, nothing, Base.ExceptionStack([(exception=resp,backtrace=[])]), LineNumberNode(1)))
542+
Test.@with_testset fake begin
543+
Test.record(o_ts, fake)
544+
end
545+
end
476546
end
547+
end
548+
end
549+
for test in tests
550+
(test in completed_tests) && continue
551+
fake = Test.DefaultTestSet(test)
552+
@static if VERSION < v"1.13.0-DEV.1044"
553+
Test.record(fake, Test.Error(:test_interrupted, test, nothing,
554+
[("skipped", [])], LineNumberNode(1)))
477555
Test.push_testset(fake)
478556
Test.record(o_ts, fake)
479557
Test.pop_testset()
480558
else
481-
if !isa(resp, Exception)
482-
resp = ErrorException(string("Unknown result type : ", typeof(resp)))
559+
Test.record(fake, Test.Error(:test_interrupted, test, nothing, Base.ExceptionStack([(exception="skipped",backtrace=[])]), LineNumberNode(1)))
560+
Test.@with_testset fake begin
561+
Test.record(o_ts, fake)
483562
end
484-
# If this test raised an exception that is not a remote testset exception,
485-
# i.e. not a RemoteException capturing a TestSetException that means
486-
# the test runner itself had some problem, so we may have hit a segfault,
487-
# deserialization errors or something similar. Record this testset as Errored.
488-
fake = Test.DefaultTestSet(testname)
489-
Test.record(fake, Test.Error(:nontest_error, testname, nothing, Any[(resp, [])], LineNumberNode(1)))
490-
Test.push_testset(fake)
491-
Test.record(o_ts, fake)
492-
Test.pop_testset()
493563
end
494564
end
495-
for test in tests
496-
(test in completed_tests) && continue
497-
fake = Test.DefaultTestSet(test)
498-
Test.record(fake, Test.Error(:test_interrupted, test, nothing,
499-
[("skipped", [])], LineNumberNode(1)))
500-
Test.push_testset(fake)
501-
Test.record(o_ts, fake)
502-
Test.pop_testset()
503-
end
504565
println()
505566
Test.print_test_results(o_ts, 1)
506567
if !o_ts.anynonpass

test/setup.jl

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ CUDA.precompile_runtime()
4444

4545
function runtests(f, name, time_source=:cuda)
4646
old_print_setting = Test.TESTSET_PRINT_ENABLE[]
47-
Test.TESTSET_PRINT_ENABLE[] = false
47+
if VERSION < v"1.13.0-DEV.1044"
48+
Test.TESTSET_PRINT_ENABLE[] = false
49+
else
50+
Test.TESTSET_PRINT_ENABLE[] => false
51+
end
4852

4953
try
5054
# generate a temporary module to execute the tests in
@@ -122,7 +126,11 @@ function runtests(f, name, time_source=:cuda)
122126
GC.gc(true)
123127
res
124128
finally
125-
Test.TESTSET_PRINT_ENABLE[] = old_print_setting
129+
if VERSION < v"1.13.0-DEV.1044"
130+
Test.TESTSET_PRINT_ENABLE[] = old_print_setting
131+
else
132+
Test.TESTSET_PRINT_ENABLE[] => old_print_setting
133+
end
126134
end
127135
end
128136

0 commit comments

Comments
 (0)