Skip to content

Commit d8f9904

Browse files
committed
Revert "Slightly improve inferred types in runtests (#100)"
This reverts commit 16f47d4.
1 parent 5488684 commit d8f9904

1 file changed

Lines changed: 11 additions & 13 deletions

File tree

src/ParallelTestRunner.jl

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -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::Int = clamp(_jobs, 1, length(tests))
790+
jobs = something(args.jobs, default_njobs())
791+
jobs = 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 = Ref(false)
801+
done = 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
@@ -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,14 +1001,12 @@ 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
10061004
if wrkr === nothing
1007-
wrkr = p2
1005+
wrkr = p
10081006
end
10091007
# if a worker failed, spawn a new one
10101008
if wrkr === nothing || !Malt.isrunning(wrkr)
1011-
wrkr = p2 = addworker(; init_worker_code, io_ctx.color)
1009+
wrkr = p = addworker(; init_worker_code, io_ctx.color)
10121010
end
10131011

10141012
# run the test
@@ -1057,7 +1055,7 @@ function runtests(mod::Module, args::ParsedArgs;
10571055
end
10581056

10591057
# get rid of the custom worker
1060-
if wrkr != p2
1058+
if wrkr != p
10611059
Malt.stop(wrkr)
10621060
end
10631061

@@ -1077,7 +1075,7 @@ function runtests(mod::Module, args::ParsedArgs;
10771075
if any(istaskfailed, worker_tasks)
10781076
println(io_ctx.stderr, "\nCaught an error, stopping...")
10791077
break
1080-
elseif done[] || Base.@lock(test_lock, isempty(tests) && isempty(running_tests))
1078+
elseif done || Base.@lock(test_lock, isempty(tests) && isempty(running_tests))
10811079
break
10821080
end
10831081
sleep(1)

0 commit comments

Comments
 (0)