Skip to content

Commit f2aa539

Browse files
committed
Drop unnecessary Lockable wrapping of tests
It's read-only anyway.
1 parent 1611730 commit f2aa539

1 file changed

Lines changed: 13 additions & 14 deletions

File tree

src/ParallelTestRunner.jl

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -932,15 +932,15 @@ function runtests(mod::Module, args::ParsedArgs;
932932
filter_tests!(testsuite, args)
933933

934934
# determine test order
935-
tests = Lockable(collect(keys(testsuite)))
936-
@lock tests Random.shuffle!(tests[])
935+
tests = collect(keys(testsuite))
936+
Random.shuffle!(tests)
937937
historical_durations = load_test_history(mod)
938-
@lock tests sort!(tests[], by = x -> -get(historical_durations, x, Inf))
938+
sort!(tests, by = x -> -get(historical_durations, x, Inf))
939939

940940
# determine parallelism
941941
jobs = something(args.jobs, default_njobs())
942-
jobs = @lock tests clamp(jobs, 1, length(tests[]))
943-
@lock tests println(stdout, "Running $(length(tests[])) tests using $jobs parallel jobs. If this is too many concurrent jobs, specify the `--jobs=N` argument to the tests, or set the `JULIA_CPU_THREADS` environment variable.")
942+
jobs = clamp(jobs, 1, length(tests))
943+
println(stdout, "Running $(length(tests)) tests using $jobs parallel jobs. If this is too many concurrent jobs, specify the `--jobs=N` argument to the tests, or set the `JULIA_CPU_THREADS` environment variable.")
944944
!isnothing(args.verbose) && println(stdout, "Available memory: $(Base.format_bytes(available_memory()))")
945945
sem = Base.Semaphore(max(1, jobs))
946946
worker_pool = Channel{Union{Nothing, PTRWorker}}(jobs)
@@ -974,10 +974,10 @@ function runtests(mod::Module, args::ParsedArgs;
974974
# pretty print information about gc and mem usage
975975
testgroupheader = "Test"
976976
workerheader = "(Worker)"
977-
name_align = @lock tests maximum(
977+
name_align = maximum(
978978
[
979979
textwidth(testgroupheader) + textwidth(" ") + textwidth(workerheader);
980-
map(x -> textwidth(x) + 5, tests[])
980+
map(x -> textwidth(x) + 5, tests)
981981
]
982982
)
983983

@@ -1009,7 +1009,7 @@ function runtests(mod::Module, args::ParsedArgs;
10091009
isempty(running_snapshot) && return
10101010
results_snapshot = @lock results copy(results[])
10111011
completed = length(results_snapshot)
1012-
total = @lock tests length(tests[])
1012+
total = length(tests)
10131013

10141014
# line 1: empty line
10151015
line1 = ""
@@ -1043,7 +1043,7 @@ function runtests(mod::Module, args::ParsedArgs;
10431043
est_remaining += max(0.0, duration - elapsed)
10441044
end
10451045
## yet-to-run
1046-
@lock tests for test in tests[]
1046+
for test in tests
10471047
haskey(running_snapshot, test) && continue
10481048
# Test is in any completed test
10491049
any(r -> test == r.test, results_snapshot) && continue
@@ -1131,8 +1131,7 @@ function runtests(mod::Module, args::ParsedArgs;
11311131
finally
11321132
n_running = @lock running_tests length(running_tests[])
11331133
n_results = @lock results length(results[])
1134-
n_tests = @lock tests length(tests[])
1135-
if n_running == 0 && n_results >= n_tests
1134+
if n_running == 0 && n_results >= length(tests)
11361135
# XXX: only erase the status if we completed successfully.
11371136
# in other cases we'll have printed "caught interrupt"
11381137
clear_status()
@@ -1144,9 +1143,9 @@ function runtests(mod::Module, args::ParsedArgs;
11441143
# execution
11451144
#
11461145

1147-
tests_to_start = @lock tests Threads.Atomic{Int}(length(tests[]))
1146+
tests_to_start = Threads.Atomic{Int}(length(tests))
11481147
try
1149-
@sync for test in @lock(tests, tests[])
1148+
@sync for test in tests
11501149
push!(worker_tasks, Threads.@spawn begin
11511150
local p = nothing
11521151
acquired = false
@@ -1366,7 +1365,7 @@ function runtests(mod::Module, args::ParsedArgs;
13661365
end
13671366

13681367
# mark remaining or running tests as interrupted
1369-
for test in @lock(tests, tests[])
1368+
for test in tests
13701369
(test in completed_tests) && continue
13711370
testset = create_testset(test)
13721371
Test.record(testset, Test.Error(:test_interrupted, test, nothing, Base.ExceptionStack(NamedTuple[(;exception = "skipped", backtrace = [])]), LineNumberNode(1)))

0 commit comments

Comments
 (0)