Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions src/ParallelTestRunner.jl
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,6 @@ function runtests(mod::Module, args::ParsedArgs;
jobs::Int = clamp(_jobs, 1, length(tests))
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.")
nworkers = min(jobs, length(tests))
workers = fill(nothing, nworkers)

t0 = time()
results = []
Expand Down Expand Up @@ -981,7 +980,7 @@ function runtests(mod::Module, args::ParsedArgs;
#

worker_tasks = Task[]
for p in workers
for _ in 1:nworkers
push!(worker_tasks, @async begin
while !done[]
# get a test to run
Expand All @@ -1001,14 +1000,11 @@ function runtests(mod::Module, args::ParsedArgs;
else
test_worker(test, init_worker_code)
end
# Create a new binding instead of assigning to the existing one to avoid `p` from being boxed
p2 = p
if wrkr === nothing
wrkr = p2
end
# if a worker failed, spawn a new one
if wrkr === nothing || !Malt.isrunning(wrkr)
wrkr = p2 = addworker(; init_worker_code, io_ctx.color)
p = if isnothing(wrkr) || !Malt.isrunning(wrkr)
wrkr = addworker(; init_worker_code, io_ctx.color)
else
nothing
end

# run the test
Expand Down Expand Up @@ -1057,7 +1053,7 @@ function runtests(mod::Module, args::ParsedArgs;
end

# get rid of the custom worker
if wrkr != p2
if wrkr != p
Malt.stop(wrkr)
end

Expand Down