Skip to content

Commit 7f27702

Browse files
authored
Remove useless workers variable (#103)
1 parent 48032a3 commit 7f27702

1 file changed

Lines changed: 6 additions & 10 deletions

File tree

src/ParallelTestRunner.jl

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,6 @@ function runtests(mod::Module, args::ParsedArgs;
791791
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))
794-
workers = fill(nothing, nworkers)
795794

796795
t0 = time()
797796
results = []
@@ -981,7 +980,7 @@ function runtests(mod::Module, args::ParsedArgs;
981980
#
982981

983982
worker_tasks = Task[]
984-
for p in workers
983+
for _ in 1:nworkers
985984
push!(worker_tasks, @async begin
986985
while !done[]
987986
# get a test to run
@@ -1001,14 +1000,11 @@ function runtests(mod::Module, args::ParsedArgs;
10011000
else
10021001
test_worker(test, init_worker_code)
10031002
end
1004-
# Create a new binding instead of assigning to the existing one to avoid `p` from being boxed
1005-
p2 = p
1006-
if wrkr === nothing
1007-
wrkr = p2
1008-
end
10091003
# if a worker failed, spawn a new one
1010-
if wrkr === nothing || !Malt.isrunning(wrkr)
1011-
wrkr = p2 = addworker(; init_worker_code, io_ctx.color)
1004+
p = if isnothing(wrkr) || !Malt.isrunning(wrkr)
1005+
wrkr = addworker(; init_worker_code, io_ctx.color)
1006+
else
1007+
nothing
10121008
end
10131009

10141010
# run the test
@@ -1057,7 +1053,7 @@ function runtests(mod::Module, args::ParsedArgs;
10571053
end
10581054

10591055
# get rid of the custom worker
1060-
if wrkr != p2
1056+
if wrkr != p
10611057
Malt.stop(wrkr)
10621058
end
10631059

0 commit comments

Comments
 (0)