From 557d7fd5d635e75f9dd06e38c359bee99fc76977 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mos=C3=A8=20Giordano?= Date: Thu, 26 Mar 2026 13:57:13 +0000 Subject: [PATCH 1/2] Add a lock to protect pushes to `results` --- src/ParallelTestRunner.jl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ParallelTestRunner.jl b/src/ParallelTestRunner.jl index 92f8656..3f0c5ca 100644 --- a/src/ParallelTestRunner.jl +++ b/src/ParallelTestRunner.jl @@ -834,6 +834,7 @@ function runtests(mod::Module, args::ParsedArgs; results = [] running_tests = Dict{String, Float64}() # test => start_time test_lock = ReentrantLock() # to protect crucial access to tests and running_tests + results_lock = ReentrantLock() # to protect concurrent access to results worker_tasks = Task[] @@ -1063,8 +1064,8 @@ function runtests(mod::Module, args::ParsedArgs; ex end test_t1 = time() - output = @lock wrkr.io_lock String(take!(wrkr.io)) - push!(results, (test, result, output, test_t0, test_t1)) + output = Base.@lock wrkr.io_lock String(take!(wrkr.io)) + Base.@lock results_lock push!(results, (test, result, output, test_t0, test_t1)) # act on the results if result isa AbstractTestRecord From f07a3d9af40464503b1f7ab4b1432ef69ada278d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mos=C3=A8=20Giordano?= Date: Thu, 26 Mar 2026 20:24:08 +0000 Subject: [PATCH 2/2] Lock `results` inside `update_status` --- src/ParallelTestRunner.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ParallelTestRunner.jl b/src/ParallelTestRunner.jl index 3f0c5ca..f597907 100644 --- a/src/ParallelTestRunner.jl +++ b/src/ParallelTestRunner.jl @@ -889,7 +889,7 @@ function runtests(mod::Module, args::ParsedArgs; function update_status() # only draw if we have something to show isempty(running_tests) && return - completed = length(results) + completed = Base.@lock results_lock length(results) total = completed + length(tests) + length(running_tests) # line 1: empty line @@ -911,7 +911,7 @@ function runtests(mod::Module, args::ParsedArgs; line3 = "Progress: $completed/$total tests completed" if completed > 0 # estimate per-test time (slightly pessimistic) - durations_done = [end_time - start_time for (_, _,_, start_time, end_time) in results] + durations_done = Base.@lock results_lock [end_time - start_time for (_, _,_, start_time, end_time) in results] μ = mean(durations_done) σ = length(durations_done) > 1 ? std(durations_done) : 0.0 est_per_test = μ + 0.5σ