Skip to content

Commit b655ac8

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

File tree

2 files changed

+29
-25
lines changed

2 files changed

+29
-25
lines changed

src/ParallelTestRunner.jl

Lines changed: 29 additions & 24 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
@@ -715,23 +711,25 @@ function runtests(ARGS; testfilter = Returns(true), RecordType = TestRecord,
715711
if VERSION < v"1.13.0-DEV.1037"
716712
o_ts.time_start = t0
717713
o_ts.time_end = t1
714+
o_ts.verbose = do_verbose
718715
else
719716
@atomic o_ts.time_start = t0
720717
@atomic o_ts.time_end = t1
718+
@atomic o_ts.verbose = do_verbose
721719
end
722720
with_testset(o_ts) do
723721
completed_tests = Set{String}()
724-
for (testname, res) in results
722+
for (testname, res, start, stop) in results
725723
if res isa AbstractTestRecord
726724
resp = res.test
727725
else
728726
resp = res[1]
729727
end
730728
push!(completed_tests, testname)
731-
if isa(resp, Test.DefaultTestSet)
732-
with_testset(resp) do
733-
Test.record(o_ts, resp)
734-
end
729+
730+
# decode or fake a testset
731+
testset = if isa(resp, Test.DefaultTestSet)
732+
resp
735733
elseif isa(resp, Tuple{Int, Int})
736734
fake = Test.DefaultTestSet(testname)
737735
for i in 1:resp[1]
@@ -740,10 +738,9 @@ function runtests(ARGS; testfilter = Returns(true), RecordType = TestRecord,
740738
for i in 1:resp[2]
741739
Test.record(fake, Test.Broken(:test, nothing))
742740
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)
741+
fake
742+
elseif isa(resp, RemoteException) &&
743+
isa(resp.captured.ex, Test.TestSetException)
747744
println("Worker $(resp.pid) failed running test $(testname):")
748745
Base.showerror(stdout, resp.captured)
749746
println()
@@ -757,9 +754,7 @@ function runtests(ARGS; testfilter = Returns(true), RecordType = TestRecord,
757754
for t in resp.captured.ex.errors_and_fails
758755
Test.record(fake, t)
759756
end
760-
with_testset(fake) do
761-
Test.record(o_ts, fake)
762-
end
757+
fake
763758
else
764759
if !isa(resp, Exception)
765760
resp = ErrorException(string("Unknown result type : ", typeof(resp)))
@@ -770,9 +765,19 @@ function runtests(ARGS; testfilter = Returns(true), RecordType = TestRecord,
770765
# deserialization errors or something similar. Record this testset as Errored.
771766
fake = Test.DefaultTestSet(testname)
772767
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
768+
fake
769+
end
770+
771+
# record the testset
772+
if VERSION < v"1.13.0-DEV.1037"
773+
testset.time_start = start
774+
testset.time_end = stop
775+
else
776+
@atomic testset.time_start = start
777+
@atomic testset.time_end = stop
778+
end
779+
with_testset(testset) do
780+
Test.record(o_ts, testset)
776781
end
777782
end
778783

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)