Skip to content

Commit 37dde5c

Browse files
committed
Record every testset's timing information.
1 parent 6212436 commit 37dde5c

File tree

2 files changed

+29
-27
lines changed

2 files changed

+29
-27
lines changed

src/ParallelTestRunner.jl

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,6 @@ function runtest(::Type{TestRecord}, f, name, init_code)
126126
@eval(mod, import ParallelTestRunner: Test, Random)
127127
@eval(mod, using .Test, .Random)
128128

129-
# Signal that this test has started
130-
let id = myid()
131-
@spawnat 1 begin
132-
put!(printer_channel, (:started, name, id))
133-
end
134-
end
135-
136129
Core.eval(mod, init_code)
137130
data = @eval mod begin
138131
GC.gc(true)
@@ -627,16 +620,19 @@ function runtests(ARGS; testfilter = Returns(true), RecordType = TestRecord,
627620
# get a test to run
628621
test = popfirst!(tests)
629622
wrkr = something(test_worker(test), p)
630-
running_tests[test] = (wrkr, time())
631623

632624
# run the test
625+
test_t0 = time()
626+
running_tests[test] = (wrkr, test_t0)
627+
put!(printer_channel, (:started, test, wrkr))
633628
resp = try
634629
remotecall_fetch(runtest, wrkr, RecordType, test_runners[test], test, init_code)
635630
catch e
636631
isa(e, InterruptException) && return
637632
Any[e]
638633
end
639-
push!(results, (test, resp))
634+
test_t1 = time()
635+
push!(results, (test, resp, test_t0, test_t1))
640636

641637
# act on the results
642638
if resp isa AbstractTestRecord
@@ -711,27 +707,27 @@ function runtests(ARGS; testfilter = Returns(true), RecordType = TestRecord,
711707

712708
# construct a testset to render the test results
713709
t1 = time()
714-
o_ts = Test.DefaultTestSet("Overall")
710+
o_ts = Test.DefaultTestSet("Overall"; verbose=do_verbose)
715711
if VERSION < v"1.13.0-DEV.1037"
716712
o_ts.time_start = t0
717713
o_ts.time_end = t1
718714
else
719-
@atomic o_ts.time_start = t0
715+
#@atomic o_ts.time_start = t0
720716
@atomic o_ts.time_end = t1
721717
end
722718
with_testset(o_ts) do
723719
completed_tests = Set{String}()
724-
for (testname, res) in results
720+
for (testname, res, start, stop) in results
725721
if res isa AbstractTestRecord
726722
resp = res.test
727723
else
728724
resp = res[1]
729725
end
730726
push!(completed_tests, testname)
731-
if isa(resp, Test.DefaultTestSet)
732-
with_testset(resp) do
733-
Test.record(o_ts, resp)
734-
end
727+
728+
# decode or fake a testset
729+
testset = if isa(resp, Test.DefaultTestSet)
730+
resp
735731
elseif isa(resp, Tuple{Int, Int})
736732
fake = Test.DefaultTestSet(testname)
737733
for i in 1:resp[1]
@@ -740,10 +736,9 @@ function runtests(ARGS; testfilter = Returns(true), RecordType = TestRecord,
740736
for i in 1:resp[2]
741737
Test.record(fake, Test.Broken(:test, nothing))
742738
end
743-
with_testset(fake) do
744-
Test.record(o_ts, fake)
745-
end
746-
elseif isa(resp, RemoteException) && isa(resp.captured.ex, Test.TestSetException)
739+
fake
740+
elseif isa(resp, RemoteException) &&
741+
isa(resp.captured.ex, Test.TestSetException)
747742
println("Worker $(resp.pid) failed running test $(testname):")
748743
Base.showerror(stdout, resp.captured)
749744
println()
@@ -757,9 +752,7 @@ function runtests(ARGS; testfilter = Returns(true), RecordType = TestRecord,
757752
for t in resp.captured.ex.errors_and_fails
758753
Test.record(fake, t)
759754
end
760-
with_testset(fake) do
761-
Test.record(o_ts, fake)
762-
end
755+
fake
763756
else
764757
if !isa(resp, Exception)
765758
resp = ErrorException(string("Unknown result type : ", typeof(resp)))
@@ -770,9 +763,19 @@ function runtests(ARGS; testfilter = Returns(true), RecordType = TestRecord,
770763
# deserialization errors or something similar. Record this testset as Errored.
771764
fake = Test.DefaultTestSet(testname)
772765
Test.record(fake, Test.Error(:nontest_error, testname, nothing, Base.ExceptionStack([(exception = resp, backtrace = [])]), LineNumberNode(1)))
773-
with_testset(fake) do
774-
Test.record(o_ts, fake)
775-
end
766+
fake
767+
end
768+
769+
# record the testset
770+
if VERSION < v"1.13.0-DEV.1037"
771+
testset.time_start = start
772+
testset.time_end = stop
773+
else
774+
#@atomic testset.time_start = start
775+
@atomic testset.time_end = stop
776+
end
777+
with_testset(testset) do
778+
Test.record(o_ts, testset)
776779
end
777780
end
778781

test/basic.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
@test true
2-
sleep(10)

0 commit comments

Comments
 (0)