Skip to content

Commit ee3af43

Browse files
RomeoVChrisRackauckas
authored andcommitted
refactor: main runtests.jl file
1 parent 852c5de commit ee3af43

File tree

1 file changed

+39
-43
lines changed

1 file changed

+39
-43
lines changed

test/runtests.jl

Lines changed: 39 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using ReTestItems, NonlinearSolve, Hwloc, InteractiveUtils, Pkg
1+
using ReTestItems, Hwloc, InteractiveUtils, Pkg
22

33
@info sprint(InteractiveUtils.versioninfo)
44

@@ -28,59 +28,55 @@ const GROUP = lowercase(get_from_test_args_or_env("GROUP", "all"))
2828
# To re-enable: change condition to `true` or `VERSION < v"1.13"`
2929
const ENZYME_ENABLED = VERSION < v"1.12"
3030

31-
function activate_trim_env!()
32-
Pkg.activate(abspath(joinpath(dirname(@__FILE__), "trim")))
33-
Pkg.instantiate()
34-
return nothing
35-
end
31+
if GROUP != "trim"
32+
using NonlinearSolve # trimming uses NonlinearSolve from a custom environment
3633

37-
const EXTRA_PKGS = Pkg.PackageSpec[]
38-
if GROUP == "all" || GROUP == "downstream"
39-
push!(EXTRA_PKGS, Pkg.PackageSpec("ModelingToolkit"))
40-
push!(EXTRA_PKGS, Pkg.PackageSpec("SymbolicIndexingInterface"))
41-
end
42-
if GROUP == "all" || GROUP == "nopre"
43-
# Only add Enzyme for nopre group if not on prerelease Julia and if enabled
44-
if isempty(VERSION.prerelease) && ENZYME_ENABLED
45-
push!(EXTRA_PKGS, Pkg.PackageSpec("Enzyme"))
46-
push!(EXTRA_PKGS, Pkg.PackageSpec("Mooncake"))
47-
push!(EXTRA_PKGS, Pkg.PackageSpec("SciMLSensitivity"))
34+
const EXTRA_PKGS = Pkg.PackageSpec[]
35+
if GROUP == "all" || GROUP == "downstream"
36+
push!(EXTRA_PKGS, Pkg.PackageSpec("ModelingToolkit"))
37+
push!(EXTRA_PKGS, Pkg.PackageSpec("SymbolicIndexingInterface"))
4838
end
49-
end
50-
if GROUP == "all" || GROUP == "cuda"
51-
# Only add CUDA for cuda group if not on prerelease Julia
52-
if isempty(VERSION.prerelease)
53-
push!(EXTRA_PKGS, Pkg.PackageSpec("CUDA"))
39+
if GROUP == "all" || GROUP == "nopre"
40+
# Only add Enzyme for nopre group if not on prerelease Julia and if enabled
41+
if isempty(VERSION.prerelease) && ENZYME_ENABLED
42+
push!(EXTRA_PKGS, Pkg.PackageSpec("Enzyme"))
43+
push!(EXTRA_PKGS, Pkg.PackageSpec("Mooncake"))
44+
push!(EXTRA_PKGS, Pkg.PackageSpec("SciMLSensitivity"))
45+
end
5446
end
55-
end
56-
57-
length(EXTRA_PKGS) 1 && Pkg.add(EXTRA_PKGS)
47+
if GROUP == "all" || GROUP == "cuda"
48+
# Only add CUDA for cuda group if not on prerelease Julia
49+
if isempty(VERSION.prerelease)
50+
push!(EXTRA_PKGS, Pkg.PackageSpec("CUDA"))
51+
end
52+
end
53+
length(EXTRA_PKGS) 1 && Pkg.add(EXTRA_PKGS)
5854

59-
# Use sequential execution for wrapper tests to avoid parallel initialization issues
60-
const RETESTITEMS_NWORKERS = if GROUP == "wrappers"
61-
0 # Sequential execution for wrapper tests
62-
else
63-
tmp = get(ENV, "RETESTITEMS_NWORKERS", "")
64-
isempty(tmp) &&
65-
(tmp = string(min(ifelse(Sys.iswindows(), 0, Hwloc.num_physical_cores()), 4)))
66-
parse(Int, tmp)
67-
end
68-
const RETESTITEMS_NWORKER_THREADS = begin
69-
tmp = get(ENV, "RETESTITEMS_NWORKER_THREADS", "")
70-
isempty(tmp) &&
71-
(tmp = string(max(Hwloc.num_virtual_cores() ÷ max(RETESTITEMS_NWORKERS, 1), 1)))
72-
parse(Int, tmp)
73-
end
55+
# Use sequential execution for wrapper tests to avoid parallel initialization issues
56+
const RETESTITEMS_NWORKERS = if GROUP == "wrappers"
57+
0 # Sequential execution for wrapper tests
58+
else
59+
tmp = get(ENV, "RETESTITEMS_NWORKERS", "")
60+
isempty(tmp) &&
61+
(tmp = string(min(ifelse(Sys.iswindows(), 0, Hwloc.num_physical_cores()), 4)))
62+
parse(Int, tmp)
63+
end
64+
const RETESTITEMS_NWORKER_THREADS = begin
65+
tmp = get(ENV, "RETESTITEMS_NWORKER_THREADS", "")
66+
isempty(tmp) &&
67+
(tmp = string(max(Hwloc.num_virtual_cores() ÷ max(RETESTITEMS_NWORKERS, 1), 1)))
68+
parse(Int, tmp)
69+
end
7470

75-
@info "Running tests for group: $(GROUP) with $(RETESTITEMS_NWORKERS) workers"
71+
@info "Running tests for group: $(GROUP) with $(RETESTITEMS_NWORKERS) workers"
7672

77-
if GROUP != "trim"
7873
ReTestItems.runtests(
7974
NonlinearSolve; tags = (GROUP == "all" ? nothing : [Symbol(GROUP)]),
8075
nworkers = RETESTITEMS_NWORKERS, nworker_threads = RETESTITEMS_NWORKER_THREADS,
8176
testitem_timeout = 3600
8277
)
8378
elseif GROUP == "trim" && VERSION >= v"1.12.0-rc1" # trimming has been introduced in julia 1.12
84-
activate_trim_env!()
79+
Pkg.activate(joinpath(dirname(@__FILE__), "trim"))
80+
Pkg.instantiate()
8581
include("trim/runtests.jl")
8682
end

0 commit comments

Comments
 (0)