@@ -2042,57 +2042,69 @@ end
2042
2042
mktempdir () do dir
2043
2043
path = copy_test_package (dir, " TestThreads" )
2044
2044
cd (path) do
2045
- with_current_env () do
2046
- default_nthreads_default = Threads. nthreads (:default )
2047
- default_nthreads_interactive = Threads. nthreads (:interactive )
2048
- other_nthreads_default = default_nthreads_default == 1 ? 2 : 1
2049
- other_nthreads_interactive = default_nthreads_interactive == 0 ? 1 : 0
2050
- @testset " default" begin
2045
+ # Do this all in a subprocess to protect against the parent having non-default threadpool sizes.
2046
+ script = """
2047
+ using Pkg, Test
2048
+ @testset "JULIA_NUM_THREADS=1" begin
2051
2049
withenv(
2052
- " EXPECTED_NUM_THREADS_DEFAULT" => " $default_nthreads_default " ,
2053
- " EXPECTED_NUM_THREADS_INTERACTIVE" => " $default_nthreads_interactive " ,
2050
+ "EXPECTED_NUM_THREADS_DEFAULT" => "1",
2051
+ "EXPECTED_NUM_THREADS_INTERACTIVE" => "0", # https://github.com/JuliaLang/julia/pull/57454
2052
+ "JULIA_NUM_THREADS" => "1",
2054
2053
) do
2055
2054
Pkg.test("TestThreads")
2056
2055
end
2057
2056
end
2058
- @testset " JULIA_NUM_THREADS=other_nthreads_default " begin
2057
+ @testset "JULIA_NUM_THREADS=2 " begin
2059
2058
withenv(
2060
- " EXPECTED_NUM_THREADS_DEFAULT" => " $other_nthreads_default " ,
2061
- " EXPECTED_NUM_THREADS_INTERACTIVE" => " $default_nthreads_interactive " ,
2062
- " JULIA_NUM_THREADS" => " $other_nthreads_default " ,
2059
+ "EXPECTED_NUM_THREADS_DEFAULT" => "2 ",
2060
+ "EXPECTED_NUM_THREADS_INTERACTIVE" => "1 ",
2061
+ "JULIA_NUM_THREADS" => "2 ",
2063
2062
) do
2064
2063
Pkg.test("TestThreads")
2065
2064
end
2066
2065
end
2067
- @testset " JULIA_NUM_THREADS=other_nthreads_default,other_nthreads_interactive " begin
2066
+ @testset "JULIA_NUM_THREADS=2,0 " begin
2068
2067
withenv(
2069
- " EXPECTED_NUM_THREADS_DEFAULT" => " $other_nthreads_default " ,
2070
- " EXPECTED_NUM_THREADS_INTERACTIVE" => " $other_nthreads_interactive " ,
2071
- " JULIA_NUM_THREADS" => " $other_nthreads_default , $other_nthreads_interactive " ,
2068
+ "EXPECTED_NUM_THREADS_DEFAULT" => "2 ",
2069
+ "EXPECTED_NUM_THREADS_INTERACTIVE" => "0 ",
2070
+ "JULIA_NUM_THREADS" => "2,0 ",
2072
2071
) do
2073
2072
Pkg.test("TestThreads")
2074
2073
end
2075
2074
end
2076
- @testset " --threads=other_nthreads_default" begin
2075
+
2076
+ @testset "--threads=1" begin
2077
2077
withenv(
2078
- " EXPECTED_NUM_THREADS_DEFAULT" => " $other_nthreads_default " ,
2079
- " EXPECTED_NUM_THREADS_INTERACTIVE" => " $default_nthreads_interactive " ,
2078
+ "EXPECTED_NUM_THREADS_DEFAULT" => "1",
2079
+ "EXPECTED_NUM_THREADS_INTERACTIVE" => "0", # https://github.com/JuliaLang/julia/pull/57454
2080
+ "JULIA_NUM_THREADS" => nothing,
2080
2081
) do
2081
- Pkg. test (" TestThreads" ; julia_args= ` --threads=$other_nthreads_default ` )
2082
+ Pkg.test("TestThreads"; julia_args=`--threads=1 `)
2082
2083
end
2083
2084
end
2084
- @testset " --threads=other_nthreads_default,other_nthreads_interactive " begin
2085
+ @testset "--threads=2 " begin
2085
2086
withenv(
2086
- " EXPECTED_NUM_THREADS_DEFAULT" => " $other_nthreads_default " ,
2087
- " EXPECTED_NUM_THREADS_INTERACTIVE" => " $other_nthreads_interactive " ,
2087
+ "EXPECTED_NUM_THREADS_DEFAULT" => "2",
2088
+ "EXPECTED_NUM_THREADS_INTERACTIVE" => "1",
2089
+ "JULIA_NUM_THREADS" => nothing,
2088
2090
) do
2089
- Pkg. test (" TestThreads" ; julia_args= ` --threads=$other_nthreads_default , $other_nthreads_interactive ` )
2091
+ Pkg.test("TestThreads"; julia_args=`--threads=2 `)
2090
2092
end
2091
2093
end
2092
- end
2094
+ @testset "--threads=2,0" begin
2095
+ withenv(
2096
+ "EXPECTED_NUM_THREADS_DEFAULT" => "2",
2097
+ "EXPECTED_NUM_THREADS_INTERACTIVE" => "0",
2098
+ "JULIA_NUM_THREADS" => nothing,
2099
+ ) do
2100
+ Pkg.test("TestThreads"; julia_args=`--threads=2,0`)
2101
+ end
2102
+ end
2103
+ """
2104
+ @test Utils. show_output_if_command_errors (` $(Base. julia_cmd ()) --project=$(path) --startup-file=no -e "$script "` )
2093
2105
end
2094
2106
end
2095
- end
2107
+ end
2096
2108
end
2097
2109
2098
2110
#
0 commit comments