Skip to content

Commit b595e8c

Browse files
committed
Record every testset's timing information.
1 parent e08341a commit b595e8c

File tree

2 files changed

+23
-25
lines changed

2 files changed

+23
-25
lines changed

src/ParallelTestRunner.jl

Lines changed: 23 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)
@@ -629,16 +622,19 @@ function runtests(ARGS; testfilter = Returns(true), RecordType = TestRecord,
629622
# get a test to run
630623
test = popfirst!(tests)
631624
wrkr = something(test_worker(test), p)
632-
running_tests[test] = (wrkr, now())
633625

634626
# run the test
627+
test_t0 = now()
628+
running_tests[test] = (wrkr, test_t0)
629+
put!(printer_channel, (:started, test, wrkr))
635630
resp = try
636631
remotecall_fetch(runtest, wrkr, RecordType, test_runners[test], test, init_code)
637632
catch e
638633
isa(e, InterruptException) && return
639634
Any[e]
640635
end
641-
push!(results, (test, resp))
636+
test_t1 = now()
637+
push!(results, (test, resp, test_t0, test_t1))
642638

643639
# act on the results
644640
if resp isa AbstractTestRecord
@@ -716,19 +712,20 @@ function runtests(ARGS; testfilter = Returns(true), RecordType = TestRecord,
716712
o_ts = Test.DefaultTestSet("Overall")
717713
o_ts.time_start = Dates.datetime2unix(t0)
718714
o_ts.time_end = Dates.datetime2unix(t1)
715+
o_ts.verbose = do_verbose
719716
with_testset(o_ts) do
720717
completed_tests = Set{String}()
721-
for (testname, res) in results
718+
for (testname, res, start, stop) in results
722719
if res isa AbstractTestRecord
723720
resp = res.test
724721
else
725722
resp = res[1]
726723
end
727724
push!(completed_tests, testname)
728-
if isa(resp, Test.DefaultTestSet)
729-
with_testset(resp) do
730-
Test.record(o_ts, resp)
731-
end
725+
726+
# decode or fake a testset
727+
testset = if isa(resp, Test.DefaultTestSet)
728+
resp
732729
elseif isa(resp, Tuple{Int, Int})
733730
fake = Test.DefaultTestSet(testname)
734731
for i in 1:resp[1]
@@ -737,10 +734,9 @@ function runtests(ARGS; testfilter = Returns(true), RecordType = TestRecord,
737734
for i in 1:resp[2]
738735
Test.record(fake, Test.Broken(:test, nothing))
739736
end
740-
with_testset(fake) do
741-
Test.record(o_ts, fake)
742-
end
743-
elseif isa(resp, RemoteException) && isa(resp.captured.ex, Test.TestSetException)
737+
fake
738+
elseif isa(resp, RemoteException) &&
739+
isa(resp.captured.ex, Test.TestSetException)
744740
println("Worker $(resp.pid) failed running test $(testname):")
745741
Base.showerror(stdout, resp.captured)
746742
println()
@@ -754,9 +750,7 @@ function runtests(ARGS; testfilter = Returns(true), RecordType = TestRecord,
754750
for t in resp.captured.ex.errors_and_fails
755751
Test.record(fake, t)
756752
end
757-
with_testset(fake) do
758-
Test.record(o_ts, fake)
759-
end
753+
fake
760754
else
761755
if !isa(resp, Exception)
762756
resp = ErrorException(string("Unknown result type : ", typeof(resp)))
@@ -767,9 +761,14 @@ function runtests(ARGS; testfilter = Returns(true), RecordType = TestRecord,
767761
# deserialization errors or something similar. Record this testset as Errored.
768762
fake = Test.DefaultTestSet(testname)
769763
Test.record(fake, Test.Error(:nontest_error, testname, nothing, Base.ExceptionStack([(exception = resp, backtrace = [])]), LineNumberNode(1)))
770-
with_testset(fake) do
771-
Test.record(o_ts, fake)
772-
end
764+
fake
765+
end
766+
767+
# record the testset
768+
testset.time_start = Dates.datetime2unix(start)
769+
testset.time_end = Dates.datetime2unix(stop)
770+
with_testset(testset) do
771+
Test.record(o_ts, testset)
773772
end
774773
end
775774

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)