@@ -834,6 +834,7 @@ function runtests(mod::Module, args::ParsedArgs;
834834 results = []
835835 running_tests = Dict {String, Float64} () # test => start_time
836836 test_lock = ReentrantLock () # to protect crucial access to tests and running_tests
837+ results_lock = ReentrantLock () # to protect concurrent access to results
837838
838839 worker_tasks = Task[]
839840
@@ -888,7 +889,7 @@ function runtests(mod::Module, args::ParsedArgs;
888889 function update_status ()
889890 # only draw if we have something to show
890891 isempty (running_tests) && return
891- completed = length (results)
892+ completed = Base . @lock results_lock length (results)
892893 total = completed + length (tests) + length (running_tests)
893894
894895 # line 1: empty line
@@ -910,7 +911,7 @@ function runtests(mod::Module, args::ParsedArgs;
910911 line3 = " Progress: $completed /$total tests completed"
911912 if completed > 0
912913 # estimate per-test time (slightly pessimistic)
913- durations_done = [end_time - start_time for (_, _,_, start_time, end_time) in results]
914+ durations_done = Base . @lock results_lock [end_time - start_time for (_, _,_, start_time, end_time) in results]
914915 μ = mean (durations_done)
915916 σ = length (durations_done) > 1 ? std (durations_done) : 0.0
916917 est_per_test = μ + 0.5 σ
@@ -1063,8 +1064,8 @@ function runtests(mod::Module, args::ParsedArgs;
10631064 ex
10641065 end
10651066 test_t1 = time ()
1066- output = @lock wrkr. io_lock String (take! (wrkr. io))
1067- push! (results, (test, result, output, test_t0, test_t1))
1067+ output = Base . @lock wrkr. io_lock String (take! (wrkr. io))
1068+ Base . @lock results_lock push! (results, (test, result, output, test_t0, test_t1))
10681069
10691070 # act on the results
10701071 if result isa AbstractTestRecord
0 commit comments