Skip to content

Commit ff9d114

Browse files
ChrisRackauckas-ClaudeChrisRackauckasclaude
authored
Use SciMLTesting v1.2 folder-based run_tests (#200)
Convert the root umbrella test harness to SciMLTesting v1.2. The monorepo sublibrary routing pre-step (detect_sublibrary_group + < 1.11 transitive [sources] develop walk + Pkg.test handoff via DIFFEQPROBLEMLIBRARY_TEST_GROUP) is kept verbatim so the sublibrary Pkg.test invocation is byte-for-byte identical. The root-package dispatch (which ran the same ExplicitImports QA body for GROUP=All, Core, and QA) is delegated to run_tests via the qa body, all = ["QA"], and a "Core" umbrella expanding to "QA". Adds SciMLTesting to the root and qa test envs. test/test_groups.toml is unchanged. Co-authored-by: ChrisRackauckas-Claude <accounts@chrisrackauckas.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 078bf12 commit ff9d114

3 files changed

Lines changed: 49 additions & 30 deletions

File tree

Project.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,16 @@ JumpProblemLibrary = "1, 2.0"
2929
NonlinearProblemLibrary = "0.1"
3030
ODEProblemLibrary = "1"
3131
SafeTestsets = "0.1"
32+
SciMLTesting = "1"
3233
SDEProblemLibrary = "1"
3334
Test = "1.10"
3435
julia = "1.10"
3536

3637
[extras]
3738
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
3839
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
40+
SciMLTesting = "09d9d899-5365-40a9-917a-5f67fddea283"
3941
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
4042

4143
[targets]
42-
test = ["Pkg", "SafeTestsets", "Test"]
44+
test = ["Pkg", "SafeTestsets", "SciMLTesting", "Test"]

test/qa/Project.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
[deps]
22
DiffEqProblemLibrary = "a077e3f3-b75c-5d7f-a0c6-6bc4c8ec64a9"
33
ExplicitImports = "7d51a73a-1435-4ff3-83d9-f097790105c7"
4+
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
5+
SciMLTesting = "09d9d899-5365-40a9-917a-5f67fddea283"
46
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
57

68
[sources]
@@ -16,5 +18,7 @@ SDEProblemLibrary = {path = "../../lib/SDEProblemLibrary"}
1618
[compat]
1719
DiffEqProblemLibrary = "5"
1820
ExplicitImports = "1"
21+
SafeTestsets = "0.0.1, 0.1"
22+
SciMLTesting = "1"
1923
Test = "1.10"
2024
julia = "1.10"

test/runtests.jl

Lines changed: 42 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,51 @@
11
using Pkg
22
using SafeTestsets, Test
3+
using SciMLTesting
34

4-
const GROUP = get(ENV, "GROUP", "All")
5+
const GROUP = current_group()
6+
const LIB_DIR = joinpath(dirname(@__DIR__), "lib")
57

8+
# The root umbrella package's own QA env activation. It is kept as an explicit
9+
# helper (rather than `run_tests`'s `env =` group spec) so the activate/instantiate
10+
# behavior — in particular NOT `Pkg.develop`-ing the root or transitively developing
11+
# the env's `[sources]` on Julia < 1.11 — stays byte-for-byte identical to the
12+
# previous hand-written runtests.jl.
613
function activate_qa_env()
714
Pkg.activate(joinpath(@__DIR__, "qa"))
815
return Pkg.instantiate()
916
end
1017

11-
@time begin
12-
# Detect sublibrary test groups.
13-
# GROUP can be a bare sublibrary name (Core test group) or
14-
# "{sublibrary}_{TEST_GROUP}" for any custom group (e.g., QA).
15-
# Sublibraries declare their groups in test/test_groups.toml (when they
16-
# differ from the default Core + QA).
17-
lib_dir = joinpath(dirname(@__DIR__), "lib")
18+
# The root umbrella package's own test: it re-exports each sublibrary, so the test
19+
# is that the whole thing builds with no implicit or stale explicit imports. The old
20+
# runtests.jl ran this body for GROUP=All, GROUP=Core, and GROUP=QA alike, so it is
21+
# wired as the `qa` body, listed in `all`, and reached for GROUP=Core via an umbrella.
22+
function qa_group()
23+
activate_qa_env()
24+
return @time @safetestset "ExplicitImports" include("qa/qa.jl")
25+
end
1826

19-
# Scan underscores right-to-left to find the longest matching sublibrary prefix.
20-
function _detect_sublibrary_group(group, lib_dir)
21-
isdir(joinpath(lib_dir, group)) && return (group, "Core")
22-
for i in length(group):-1:1
23-
if group[i] == '_' && isdir(joinpath(lib_dir, group[1:(i - 1)]))
24-
return (group[1:(i - 1)], group[(i + 1):end])
25-
end
26-
end
27-
return (group, "Core")
28-
end
29-
base_group, test_group = _detect_sublibrary_group(GROUP, lib_dir)
27+
@time begin
28+
# Monorepo sublibrary routing. The root reads GROUP to pick a `lib/<sub>`
29+
# sublibrary, transitively develops its `[sources]` on Julia < 1.11, then
30+
# `Pkg.test`s it with the sub-group handed off via DIFFEQPROBLEMLIBRARY_TEST_GROUP.
31+
# This is kept as an explicit pre-step (rather than delegated to `run_tests`'s
32+
# built-in `lib_dir` path) so the sublibrary `Pkg.test` invocation — `julia_args`,
33+
# `force_latest_compatible_version = false`, `allow_reresolve = true` — stays
34+
# byte-for-byte identical to the previous runtests.jl. (`run_tests`'s sublibrary
35+
# path only passes `allow_reresolve`, which would silently drop `--depwarn=yes` /
36+
# `force_latest_compatible_version`.)
37+
base_group, test_group = detect_sublibrary_group(GROUP, LIB_DIR)
3038

31-
if isdir(joinpath(lib_dir, base_group))
32-
Pkg.activate(joinpath(lib_dir, base_group))
39+
if !isempty(base_group) && isdir(joinpath(LIB_DIR, base_group))
40+
Pkg.activate(joinpath(LIB_DIR, base_group))
3341
# On Julia < 1.11, the [sources] section in Project.toml is not supported.
3442
# Manually Pkg.develop local path dependencies so CI tests the PR branch code.
3543
# The transitive walk also develops each developed dependency's own [sources].
3644
if VERSION < v"1.11.0-DEV.0"
3745
developed = Set{String}()
38-
push!(developed, normpath(joinpath(lib_dir, base_group)))
46+
push!(developed, normpath(joinpath(LIB_DIR, base_group)))
3947
specs = Pkg.PackageSpec[]
40-
queue = [joinpath(lib_dir, base_group)]
48+
queue = [joinpath(LIB_DIR, base_group)]
4149
while !isempty(queue)
4250
pkg_dir = popfirst!(queue)
4351
toml_path = joinpath(pkg_dir, "Project.toml")
@@ -62,11 +70,16 @@ end
6270
withenv("DIFFEQPROBLEMLIBRARY_TEST_GROUP" => test_group) do
6371
Pkg.test(base_group, julia_args = ["--check-bounds=auto", "--compiled-modules=yes", "--depwarn=yes"], force_latest_compatible_version = false, allow_reresolve = true)
6472
end
65-
elseif GROUP == "All" || GROUP == "Core" || GROUP == "QA"
66-
# The root umbrella package's own test: it re-exports each sublibrary,
67-
# so the test is that the whole thing builds with no implicit or stale
68-
# explicit imports.
69-
activate_qa_env()
70-
@time @safetestset "ExplicitImports" include("qa/qa.jl")
73+
else
74+
# Root-package group dispatch. The previous runtests.jl ran the same
75+
# ExplicitImports QA body for GROUP=All, GROUP=Core, and GROUP=QA. `run_tests`
76+
# owns that routing: `qa` is the body, `all = ["QA"]` runs it under "All", and
77+
# the "Core" umbrella expands to "QA" so GROUP=Core runs it too.
78+
run_tests(;
79+
core = () -> nothing,
80+
qa = qa_group,
81+
all = ["QA"],
82+
umbrellas = Dict("Core" => ["QA"]),
83+
)
7184
end
7285
end # @time

0 commit comments

Comments
 (0)