Skip to content

Commit 8a88709

Browse files
Make threads test more robust + fix bug parsing JULIA_NUM_THREADS (#4241)
Co-authored-by: Ian Butterworth <[email protected]>
1 parent 1b26c92 commit 8a88709

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/Operations.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2014,6 +2014,9 @@ end
20142014

20152015
function get_threads_spec()
20162016
if haskey(ENV, "JULIA_NUM_THREADS")
2017+
if isempty(ENV["JULIA_NUM_THREADS"])
2018+
throw(ArgumentError("JULIA_NUM_THREADS is set to an empty string. It is not clear what Pkg.test should set for `-t` on the test worker."))
2019+
end
20172020
# if set, prefer JULIA_NUM_THREADS because this is passed to the test worker via --threads
20182021
# which takes precedence in the worker
20192022
ENV["JULIA_NUM_THREADS"]

test/new.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2128,6 +2128,7 @@ end
21282128
withenv(
21292129
"EXPECTED_NUM_THREADS_DEFAULT" => "$default_nthreads_default",
21302130
"EXPECTED_NUM_THREADS_INTERACTIVE" => "$default_nthreads_interactive",
2131+
"JULIA_NUM_THREADS" => nothing,
21312132
) do
21322133
Pkg.test("TestThreads")
21332134
end
@@ -2154,6 +2155,7 @@ end
21542155
withenv(
21552156
"EXPECTED_NUM_THREADS_DEFAULT" => "$other_nthreads_default",
21562157
"EXPECTED_NUM_THREADS_INTERACTIVE" => "$default_nthreads_interactive",
2158+
"JULIA_NUM_THREADS" => nothing,
21572159
) do
21582160
Pkg.test("TestThreads"; julia_args=`--threads=$other_nthreads_default`)
21592161
end
@@ -2162,6 +2164,7 @@ end
21622164
withenv(
21632165
"EXPECTED_NUM_THREADS_DEFAULT" => "$other_nthreads_default",
21642166
"EXPECTED_NUM_THREADS_INTERACTIVE" => "$other_nthreads_interactive",
2167+
"JULIA_NUM_THREADS" => nothing,
21652168
) do
21662169
Pkg.test("TestThreads"; julia_args=`--threads=$other_nthreads_default,$other_nthreads_interactive`)
21672170
end

0 commit comments

Comments
 (0)