From fd6e5ad2ee733809225e1eadb3da16df55faa6ea Mon Sep 17 00:00:00 2001 From: ChrisRackauckas-Claude Date: Sun, 14 Jun 2026 09:30:42 -0400 Subject: [PATCH] Use SciMLTesting v1.2 run_tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Convert test/runtests.jl to SciMLTesting v1.2. Core is an explicit thunk that includes core_tests.jl into Main (NOT an isolated @safetestset module): the serialization round-trip test deserializes RuntimeGeneratedFunctions whose module tag is Main.#_RGF_ModTag, so the body must run where RuntimeGeneratedFunctions.init initializes Main — folder-discovery's @safetestset isolation cannot express this. QA uses the standard test/qa/ sub-env. The subprocess helper serialize_rgf.jl is moved to test/shared/ (a non-group folder) so it is not mistaken for a Core test file, and core_tests.jl references it by absolute path. core_tests.jl gains the using statements the old runtests.jl provided (Test, RuntimeGeneratedFunctions, BenchmarkTools, Serialization). precomp/ is untouched. Added SciMLTesting + SafeTestsets to the test target and SciMLTesting to test/qa/Project.toml; dropped Pkg (the harness owns all Pkg ops; no test file uses Pkg). test_groups.toml unchanged. Verified locally on Julia 1.11: GROUP=Core and GROUP=QA both pass. Co-Authored-By: Chris Rackauckas Co-Authored-By: Claude Opus 4.8 (1M context) --- Project.toml | 8 +++++--- test/core_tests.jl | 7 ++++++- test/qa/Project.toml | 4 ++++ test/runtests.jl | 27 +++++++++++---------------- test/{ => shared}/serialize_rgf.jl | 0 5 files changed, 26 insertions(+), 20 deletions(-) rename test/{ => shared}/serialize_rgf.jl (100%) diff --git a/Project.toml b/Project.toml index cd08394..1b995bb 100644 --- a/Project.toml +++ b/Project.toml @@ -12,8 +12,9 @@ Serialization = "9e88b42a-f829-5b0c-bbe9-9e923198166b" Aqua = "0.8" BenchmarkTools = "1" ExprTools = "0.1" -Pkg = "1" SHA = "0.7, 1" +SafeTestsets = "0.1, 1" +SciMLTesting = "1" Serialization = "1.10" Test = "1" julia = "1.10" @@ -21,8 +22,9 @@ julia = "1.10" [extras] Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" -Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" +SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f" +SciMLTesting = "09d9d899-5365-40a9-917a-5f67fddea283" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [targets] -test = ["Aqua", "BenchmarkTools", "Pkg", "Test"] +test = ["Aqua", "BenchmarkTools", "SafeTestsets", "SciMLTesting", "Test"] diff --git a/test/core_tests.jl b/test/core_tests.jl index 454f7a4..ca0473d 100644 --- a/test/core_tests.jl +++ b/test/core_tests.jl @@ -1,3 +1,7 @@ +using Test +using RuntimeGeneratedFunctions, BenchmarkTools +using Serialization + RuntimeGeneratedFunctions.init(@__MODULE__) function f(_du, _u, _p, _t) @@ -199,7 +203,8 @@ ex = :(x -> [2i for i in 1:x]) # Serialization proj = dirname(Base.active_project()) -buf = IOBuffer(read(`$(Base.julia_cmd()) --startup-file=no --project=$proj "serialize_rgf.jl"`)) +serialize_script = joinpath(@__DIR__, "shared", "serialize_rgf.jl") +buf = IOBuffer(read(`$(Base.julia_cmd()) --startup-file=no --project=$proj $serialize_script`)) deserialized_f, deserialized_g = deserialize(buf) @test deserialized_f(11) == "Hi from a separate process. x=11" @test deserialized_f.body isa Expr diff --git a/test/qa/Project.toml b/test/qa/Project.toml index 02c5d4a..ec9a1a5 100644 --- a/test/qa/Project.toml +++ b/test/qa/Project.toml @@ -1,6 +1,8 @@ [deps] Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" RuntimeGeneratedFunctions = "7e49a35a-f44a-4d26-94aa-eba1b4ca6b47" +SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f" +SciMLTesting = "09d9d899-5365-40a9-917a-5f67fddea283" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [sources] @@ -8,5 +10,7 @@ RuntimeGeneratedFunctions = {path = ".."} [compat] Aqua = "0.8" +SafeTestsets = "0.1, 1" +SciMLTesting = "1" Test = "1" julia = "1.10" diff --git a/test/runtests.jl b/test/runtests.jl index f2c394a..fe5fd5f 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,17 +1,12 @@ -using Test -using RuntimeGeneratedFunctions, BenchmarkTools -using Serialization +using SciMLTesting -const GROUP = get(ENV, "GROUP", "All") - -if GROUP == "QA" - using Pkg - Pkg.activate(joinpath(@__DIR__, "qa")) - Pkg.develop(PackageSpec(path = joinpath(@__DIR__, ".."))) - Pkg.instantiate() - include(joinpath(@__DIR__, "qa", "qa.jl")) -end - -if GROUP == "All" || GROUP == "Core" - include(joinpath(@__DIR__, "core_tests.jl")) -end +# core_tests.jl must run in `Main` (not an isolated @safetestset module): it +# deserializes RuntimeGeneratedFunctions produced by a separate process whose +# module tag is `Main.#_RGF_ModTag`, so the body must be evaluated where +# `RuntimeGeneratedFunctions.init(@__MODULE__)` initializes `Main`. A thunk runs +# in the caller's (Main) scope; folder-discovery's @safetestset isolation cannot +# express this, so Core is an explicit thunk while QA uses the standard sub-env. +run_tests(; + core = () -> include(joinpath(@__DIR__, "core_tests.jl")), + qa = (; env = joinpath(@__DIR__, "qa"), body = joinpath(@__DIR__, "qa", "qa.jl")), +) diff --git a/test/serialize_rgf.jl b/test/shared/serialize_rgf.jl similarity index 100% rename from test/serialize_rgf.jl rename to test/shared/serialize_rgf.jl