Skip to content

Commit 13c70d2

Browse files
committed
Fixes and simplifications for nightly.
1 parent 53ff205 commit 13c70d2

File tree

1 file changed

+60
-82
lines changed

1 file changed

+60
-82
lines changed

src/ParallelTestRunner.jl

Lines changed: 60 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -210,24 +210,6 @@ function runtest(::Type{TestRecord}, f, name, init_code)
210210

211211
# process results
212212
rss = Sys.maxrss()
213-
if VERSION >= v"1.11.0-DEV.1529"
214-
tc = Test.get_test_counts(data.testset)
215-
passes, fails, error, broken, c_passes, c_fails, c_errors, c_broken =
216-
tc.passes, tc.fails, tc.errors, tc.broken, tc.cumulative_passes,
217-
tc.cumulative_fails, tc.cumulative_errors, tc.cumulative_broken
218-
else
219-
passes, fails, errors, broken, c_passes, c_fails, c_errors, c_broken =
220-
Test.get_test_counts(data.testset)
221-
end
222-
if !data.testset.anynonpass
223-
data = (;
224-
result=(passes + c_passes, broken + c_broken),
225-
data.output,
226-
data.time,
227-
data.bytes,
228-
data.gctime,
229-
)
230-
end
231213
res = TestRecord(data..., rss)
232214

233215
GC.gc(true)
@@ -770,21 +752,34 @@ function runtests(ARGS; testfilter = Returns(true), RecordType = TestRecord,
770752
end
771753

772754
# construct a testset to render the test results
773-
t1 = time()
774-
if VERSION < v"1.13.0-DEV.1037"
775-
o_ts = Test.DefaultTestSet("Overall"; verbose=do_verbose)
776-
o_ts.time_start = t0
777-
o_ts.time_end = t1
778-
else
779-
o_ts = if v"1.13.0-DEV.1037" <= VERSION < v"1.13.0-DEV.1297"
780-
# There's a small range of commits in the v1.13 development series where there's
781-
# no way to retroactively set the start time of the testset after it started.
782-
Test.DefaultTestSet("Overall"; verbose=do_verbose)
755+
function create_testset(name; start=nothing, stop=nothing, kwargs...)
756+
if start === nothing
757+
testset = Test.DefaultTestSet(name; kwargs...)
758+
elseif VERSION >= v"1.13.0-DEV.1297"
759+
testset = Test.DefaultTestSet(name; time_start=start, kwargs...)
760+
elseif VERSION < v"1.13.0-DEV.1037"
761+
testset = Test.DefaultTestSet(name; kwargs...)
762+
testset.time_start = start
783763
else
784-
Test.DefaultTestSet("Overall"; verbose=do_verbose, time_start=t0)
764+
# no way to set time_start retroactively
765+
testset = Test.DefaultTestSet(name; kwargs...)
766+
end
767+
768+
if stop !== nothing
769+
if VERSION < v"1.13.0-DEV.1037"
770+
testset.time_end = stop
771+
elseif VERSION >= v"1.13.0-DEV.1297"
772+
@atomic testset.time_end = stop
773+
else
774+
# if we can't set the start time, also don't set a stop one
775+
# to avoid negative timings
776+
end
785777
end
786-
@atomic o_ts.time_end = t1
778+
779+
return testset
787780
end
781+
t1 = time()
782+
o_ts = create_testset("Overall"; start=t0, stop=t1, verbose=do_verbose)
788783
with_testset(o_ts) do
789784
completed_tests = Set{String}()
790785
for (testname, res, start, stop) in results
@@ -796,61 +791,44 @@ function runtests(ARGS; testfilter = Returns(true), RecordType = TestRecord,
796791
push!(completed_tests, testname)
797792

798793
# decode or fake a testset
799-
testset = if isa(resp, Test.DefaultTestSet)
800-
resp
801-
elseif isa(resp, Tuple{Int, Int})
802-
fake = Test.DefaultTestSet(testname)
803-
for i in 1:resp[1]
804-
Test.record(fake, Test.Pass(:test, nothing, nothing, nothing, nothing))
805-
end
806-
for i in 1:resp[2]
807-
Test.record(fake, Test.Broken(:test, nothing))
808-
end
809-
fake
810-
elseif isa(resp, RemoteException) &&
811-
isa(resp.captured.ex, Test.TestSetException)
812-
println(io_ctx.stderr, "Worker $(resp.pid) failed running test $(testname):")
813-
Base.showerror(io_ctx.stderr, resp.captured)
814-
println(io_ctx.stderr)
815-
816-
fake = Test.DefaultTestSet(testname)
817-
c = IOCapture.capture() do
818-
for i in 1:resp.captured.ex.pass
819-
Test.record(fake, Test.Pass(:test, nothing, nothing, nothing, nothing))
794+
if isa(resp, Test.DefaultTestSet)
795+
testset = resp
796+
else
797+
testset = create_testset(testname; start, stop)
798+
if isa(resp, RemoteException) &&
799+
isa(resp.captured.ex, Test.TestSetException)
800+
println(io_ctx.stderr, "Worker $(resp.pid) failed running test $(testname):")
801+
Base.showerror(io_ctx.stderr, resp.captured)
802+
println(io_ctx.stderr)
803+
804+
c = IOCapture.capture() do
805+
for i in 1:resp.captured.ex.pass
806+
Test.record(testset, Test.Pass(:test, nothing, nothing, nothing, nothing))
807+
end
808+
for i in 1:resp.captured.ex.broken
809+
Test.record(testset, Test.Broken(:test, nothing))
810+
end
811+
for t in resp.captured.ex.errors_and_fails
812+
Test.record(testset, t)
813+
end
820814
end
821-
for i in 1:resp.captured.ex.broken
822-
Test.record(fake, Test.Broken(:test, nothing))
815+
print(io_ctx.stdout, c.output)
816+
else
817+
if !isa(resp, Exception)
818+
resp = ErrorException(string("Unknown result type : ", typeof(resp)))
823819
end
824-
for t in resp.captured.ex.errors_and_fails
825-
Test.record(fake, t)
820+
# If this test raised an exception that is not a remote testset exception,
821+
# i.e. not a RemoteException capturing a TestSetException that means
822+
# the test runner itself had some problem, so we may have hit a segfault,
823+
# deserialization errors or something similar. Record this testset as Errored.
824+
c = IOCapture.capture() do
825+
Test.record(testset, Test.Error(:nontest_error, testname, nothing, Base.ExceptionStack([(exception = resp, backtrace = [])]), LineNumberNode(1)))
826826
end
827+
print(io_ctx.stdout, c.output)
827828
end
828-
print(io_ctx.stdout, c.output)
829-
fake
830-
else
831-
if !isa(resp, Exception)
832-
resp = ErrorException(string("Unknown result type : ", typeof(resp)))
833-
end
834-
# If this test raised an exception that is not a remote testset exception,
835-
# i.e. not a RemoteException capturing a TestSetException that means
836-
# the test runner itself had some problem, so we may have hit a segfault,
837-
# deserialization errors or something similar. Record this testset as Errored.
838-
fake = Test.DefaultTestSet(testname)
839-
c = IOCapture.capture() do
840-
Test.record(fake, Test.Error(:nontest_error, testname, nothing, Base.ExceptionStack([(exception = resp, backtrace = [])]), LineNumberNode(1)))
841-
end
842-
print(io_ctx.stdout, c.output)
843-
fake
844829
end
845830

846831
# record the testset
847-
if VERSION < v"1.13.0-DEV.1037"
848-
testset.time_start = start
849-
testset.time_end = stop
850-
else
851-
#@atomic testset.time_start = start
852-
@atomic testset.time_end = stop
853-
end
854832
with_testset(testset) do
855833
Test.record(o_ts, testset)
856834
end
@@ -859,13 +837,13 @@ function runtests(ARGS; testfilter = Returns(true), RecordType = TestRecord,
859837
# mark remaining or running tests as interrupted
860838
for test in [tests; collect(keys(running_tests))]
861839
(test in completed_tests) && continue
862-
fake = Test.DefaultTestSet(test)
840+
testset = create_testset(test)
863841
c = IOCapture.capture() do
864-
Test.record(fake, Test.Error(:test_interrupted, test, nothing, Base.ExceptionStack([(exception = "skipped", backtrace = [])]), LineNumberNode(1)))
842+
Test.record(testset, Test.Error(:test_interrupted, test, nothing, Base.ExceptionStack([(exception = "skipped", backtrace = [])]), LineNumberNode(1)))
865843
end
866844
# don't print the output of interrupted tests, it's not useful
867-
with_testset(fake) do
868-
Test.record(o_ts, fake)
845+
with_testset(testset) do
846+
Test.record(o_ts, testset)
869847
end
870848
end
871849
end

0 commit comments

Comments
 (0)