Skip to content

Commit fb6ae33

Browse files
committed
Merge remote-tracking branch 'origin/main' into mg/rm-rmprocs
2 parents 99da708 + 48032a3 commit fb6ae33

1 file changed

Lines changed: 17 additions & 15 deletions

File tree

src/ParallelTestRunner.jl

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ dictionary mapping test names to expression that include each test file.
493493
"""
494494
function find_tests(dir::String)
495495
tests = Dict{String, Expr}()
496-
for (rootpath, dirs, files) in walkdir(dir)
496+
for (rootpath, _dirs, files) in walkdir(dir)
497497
# find Julia files
498498
filter!(files) do file
499499
endswith(file, ".jl") && file !== "runtests.jl"
@@ -787,8 +787,8 @@ function runtests(mod::Module, args::ParsedArgs;
787787
sort!(tests, by = x -> -get(historical_durations, x, Inf))
788788

789789
# determine parallelism
790-
jobs = something(args.jobs, default_njobs())
791-
jobs = clamp(jobs, 1, length(tests))
790+
_jobs = something(args.jobs, default_njobs())
791+
jobs::Int = clamp(_jobs, 1, length(tests))
792792
println(stdout, "Running $jobs tests in parallel. If this is too many, specify the `--jobs=N` argument to the tests, or set the `JULIA_CPU_THREADS` environment variable.")
793793
nworkers = min(jobs, length(tests))
794794
workers = fill(nothing, nworkers)
@@ -798,10 +798,10 @@ function runtests(mod::Module, args::ParsedArgs;
798798
running_tests = Dict{String, Float64}() # test => start_time
799799
test_lock = ReentrantLock() # to protect crucial access to tests and running_tests
800800

801-
done = false
801+
done = Ref(false)
802802
function stop_work()
803-
if !done
804-
done = true
803+
if !done[]
804+
done[] = true
805805
for task in worker_tasks
806806
task == current_task() && continue
807807
Base.istaskdone(task) && continue
@@ -837,7 +837,7 @@ function runtests(mod::Module, args::ParsedArgs;
837837

838838
function clear_status()
839839
if status_lines_visible[] > 0
840-
for i in 1:status_lines_visible[]-1
840+
for _ in 1:(status_lines_visible[]-1)
841841
print(io_ctx.stdout, "\033[2K") # Clear entire line
842842
print(io_ctx.stdout, "\033[1A") # Move up one line
843843
end
@@ -950,7 +950,7 @@ function runtests(mod::Module, args::ParsedArgs;
950950
end
951951

952952
# After a while, display a status line
953-
if !done && time() - t0 >= 5 && (got_message || (time() - last_status_update[] >= 1))
953+
if !done[] && time() - t0 >= 5 && (got_message || (time() - last_status_update[] >= 1))
954954
update_status()
955955
last_status_update[] = time()
956956
end
@@ -983,7 +983,7 @@ function runtests(mod::Module, args::ParsedArgs;
983983
worker_tasks = Task[]
984984
for p in workers
985985
push!(worker_tasks, @async begin
986-
while !done
986+
while !done[]
987987
# get a test to run
988988
test, test_t0 = Base.@lock test_lock begin
989989
isempty(tests) && break
@@ -1001,12 +1001,14 @@ function runtests(mod::Module, args::ParsedArgs;
10011001
else
10021002
test_worker(test, init_worker_code)
10031003
end
1004+
# Create a new binding instead of assigning to the existing one to avoid `p` from being boxed
1005+
p2 = p
10041006
if wrkr === nothing
1005-
wrkr = p
1007+
wrkr = p2
10061008
end
10071009
# if a worker failed, spawn a new one
10081010
if wrkr === nothing || !Malt.isrunning(wrkr)
1009-
wrkr = p = addworker(; init_worker_code, io_ctx.color)
1011+
wrkr = p2 = addworker(; init_worker_code, io_ctx.color)
10101012
end
10111013

10121014
# run the test
@@ -1055,7 +1057,7 @@ function runtests(mod::Module, args::ParsedArgs;
10551057
end
10561058

10571059
# get rid of the custom worker
1058-
if wrkr != p
1060+
if wrkr != p2
10591061
Malt.stop(wrkr)
10601062
end
10611063

@@ -1075,7 +1077,7 @@ function runtests(mod::Module, args::ParsedArgs;
10751077
if any(istaskfailed, worker_tasks)
10761078
println(io_ctx.stderr, "\nCaught an error, stopping...")
10771079
break
1078-
elseif done || Base.@lock(test_lock, isempty(tests) && isempty(running_tests))
1080+
elseif done[] || Base.@lock(test_lock, isempty(tests) && isempty(running_tests))
10791081
break
10801082
end
10811083
sleep(1)
@@ -1106,7 +1108,7 @@ function runtests(mod::Module, args::ParsedArgs;
11061108
end
11071109

11081110
# print the output generated by each testset
1109-
for (testname, result, output, start, stop) in results
1111+
for (testname, result, output, _start, _stop) in results
11101112
if !isempty(output)
11111113
print(io_ctx.stdout, "\nOutput generated during execution of '")
11121114
if result isa Exception || anynonpass(result.value)
@@ -1164,7 +1166,7 @@ function runtests(mod::Module, args::ParsedArgs;
11641166
function collect_results()
11651167
with_testset(o_ts) do
11661168
completed_tests = Set{String}()
1167-
for (testname, result, output, start, stop) in results
1169+
for (testname, result, _output, start, stop) in results
11681170
push!(completed_tests, testname)
11691171

11701172
if result isa AbstractTestRecord

0 commit comments

Comments
 (0)