|
1 | 1 | using Pkg |
2 | 2 | using SafeTestsets, Test |
| 3 | +using SciMLTesting |
3 | 4 |
|
4 | | -const GROUP = get(ENV, "GROUP", "All") |
| 5 | +const GROUP = current_group() |
| 6 | +const LIB_DIR = joinpath(dirname(@__DIR__), "lib") |
5 | 7 |
|
| 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. |
6 | 13 | function activate_qa_env() |
7 | 14 | Pkg.activate(joinpath(@__DIR__, "qa")) |
8 | 15 | return Pkg.instantiate() |
9 | 16 | end |
10 | 17 |
|
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 |
18 | 26 |
|
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) |
30 | 38 |
|
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)) |
33 | 41 | # On Julia < 1.11, the [sources] section in Project.toml is not supported. |
34 | 42 | # Manually Pkg.develop local path dependencies so CI tests the PR branch code. |
35 | 43 | # The transitive walk also develops each developed dependency's own [sources]. |
36 | 44 | if VERSION < v"1.11.0-DEV.0" |
37 | 45 | developed = Set{String}() |
38 | | - push!(developed, normpath(joinpath(lib_dir, base_group))) |
| 46 | + push!(developed, normpath(joinpath(LIB_DIR, base_group))) |
39 | 47 | specs = Pkg.PackageSpec[] |
40 | | - queue = [joinpath(lib_dir, base_group)] |
| 48 | + queue = [joinpath(LIB_DIR, base_group)] |
41 | 49 | while !isempty(queue) |
42 | 50 | pkg_dir = popfirst!(queue) |
43 | 51 | toml_path = joinpath(pkg_dir, "Project.toml") |
|
62 | 70 | withenv("DIFFEQPROBLEMLIBRARY_TEST_GROUP" => test_group) do |
63 | 71 | Pkg.test(base_group, julia_args = ["--check-bounds=auto", "--compiled-modules=yes", "--depwarn=yes"], force_latest_compatible_version = false, allow_reresolve = true) |
64 | 72 | 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 | + ) |
71 | 84 | end |
72 | 85 | end # @time |
0 commit comments