Skip to content

Commit

Permalink
Base.runtests: add environment variables for overriding the automat…
Browse files Browse the repository at this point in the history
…ic networking detection (JuliaLang#43217)
  • Loading branch information
DilumAluthge authored Nov 28, 2021
1 parent 30602be commit 9e69a89
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 10 deletions.
28 changes: 19 additions & 9 deletions test/choosetests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -164,16 +164,26 @@ function choosetests(choices = [])
"download",
]
net_on = true
try
ipa = getipaddr()
catch
if ci_option_passed
@error("Networking unavailable, but `--ci` was passed")
rethrow()
JULIA_TEST_NETWORKING_AVAILABLE = get(ENV, "JULIA_TEST_NETWORKING_AVAILABLE", "") |>
strip |>
lowercase |>
s -> tryparse(Bool, s) |>
x -> x === true
# If the `JULIA_TEST_NETWORKING_AVAILABLE` environment variable is set to `true`, we
# always set `net_on` to `true`.
# Otherwise, we set `net_on` to true if and only if networking is actually available.
if !JULIA_TEST_NETWORKING_AVAILABLE
try
ipa = getipaddr()
catch
if ci_option_passed
@error("Networking unavailable, but `--ci` was passed")
rethrow()
end
net_on = false
@warn "Networking unavailable: Skipping tests [" * join(net_required_for, ", ") * "]"
filter!(!in(net_required_for), tests)
end
net_on = false
@warn "Networking unavailable: Skipping tests [" * join(net_required_for, ", ") * "]"
filter!(!in(net_required_for), tests)
end

if ccall(:jl_running_on_valgrind,Cint,()) != 0 && "rounding" in tests
Expand Down
10 changes: 9 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,15 @@ cd(@__DIR__) do
# * https://github.com/JuliaLang/julia/pull/29384
# * https://github.com/JuliaLang/julia/pull/40348
n = 1
if net_on
JULIA_TEST_USE_MULTIPLE_WORKERS = get(ENV, "JULIA_TEST_USE_MULTIPLE_WORKERS", "") |>
strip |>
lowercase |>
s -> tryparse(Bool, s) |>
x -> x === true
# If the `JULIA_TEST_USE_MULTIPLE_WORKERS` environment variable is set to `true`, we use
# multiple worker processes regardless of the value of `net_on`.
# Otherwise, we use multiple worker processes if and only if `net_on` is true.
if net_on || JULIA_TEST_USE_MULTIPLE_WORKERS
n = min(Sys.CPU_THREADS, length(tests))
n > 1 && addprocs_with_testenv(n)
LinearAlgebra.BLAS.set_num_threads(1)
Expand Down

0 comments on commit 9e69a89

Please sign in to comment.