Skip to content

Commit 96bd19e

Browse files
committed
Fix parse error in runtests.jl when Hwloc fails
Add try-catch blocks to handle cases where Hwloc.num_physical_cores() or Hwloc.num_virtual_cores() might fail or return invalid values. This prevents the 'input string is empty or only contains whitespace' error when parsing the default values for RETESTITEMS_NWORKERS and RETESTITEMS_NWORKER_THREADS.
1 parent 714ead6 commit 96bd19e

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

test/runtests.jl

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,27 @@ length(EXTRA_PKGS) ≥ 1 && Pkg.add(EXTRA_PKGS)
2121
const RETESTITEMS_NWORKERS = if GROUP == "wrappers"
2222
0 # Sequential execution for wrapper tests
2323
else
24+
# Ensure we have a valid default value even if Hwloc fails
25+
default_workers = try
26+
min(ifelse(Sys.iswindows(), 0, Hwloc.num_physical_cores()), 4)
27+
catch
28+
1 # Fallback to 1 worker if Hwloc fails
29+
end
2430
parse(
25-
Int, get(ENV, "RETESTITEMS_NWORKERS",
26-
string(min(ifelse(Sys.iswindows(), 0, Hwloc.num_physical_cores()), 4))
27-
)
31+
Int, get(ENV, "RETESTITEMS_NWORKERS", string(default_workers))
2832
)
2933
end
3034
const RETESTITEMS_NWORKER_THREADS = parse(Int,
3135
get(
3236
ENV, "RETESTITEMS_NWORKER_THREADS",
33-
string(max(Hwloc.num_virtual_cores() ÷ max(RETESTITEMS_NWORKERS, 1), 1))
37+
string(max(
38+
try
39+
Hwloc.num_virtual_cores() ÷ max(RETESTITEMS_NWORKERS, 1)
40+
catch
41+
1 # Fallback to 1 thread if Hwloc fails
42+
end,
43+
1
44+
))
3445
)
3546
)
3647

0 commit comments

Comments
 (0)