From 0070305dcf7088afb1e645ff57607891e1be9fbc Mon Sep 17 00:00:00 2001 From: Tim Besard Date: Fri, 10 Oct 2025 08:56:23 +0200 Subject: [PATCH 1/2] Eval the initialization code separately. If we put it in a block of expressions, it can't define things that need to happen at top level (e.g. macros). --- src/ParallelTestRunner.jl | 2 +- test/init.jl | 1 + test/runtests.jl | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ParallelTestRunner.jl b/src/ParallelTestRunner.jl index ea4abed..bec95ff 100644 --- a/src/ParallelTestRunner.jl +++ b/src/ParallelTestRunner.jl @@ -146,10 +146,10 @@ function runtest(::Type{TestRecord}, f, name, init_code) wait(@spawnat 1 print_testworker_started(name, id)) end + Core.eval(mod, init_code) data = @eval mod begin GC.gc(true) Random.seed!(1) - $init_code res = @timed @testset $name begin $f diff --git a/test/init.jl b/test/init.jl index c83a2af..23b0d93 100644 --- a/test/init.jl +++ b/test/init.jl @@ -1 +1,2 @@ @test should_be_defined() +@test @should_also_be_defined() diff --git a/test/runtests.jl b/test/runtests.jl index e5b2257..7a5e0a8 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -5,6 +5,10 @@ pushfirst!(ARGS, "--verbose") init_code = quote using Test should_be_defined() = true + + macro should_also_be_defined() + return :(true) + end end runtests(ARGS; init_code) @@ -12,6 +16,7 @@ runtests(ARGS; init_code) custom_tests = Dict( "custom" => quote @test should_be_defined() + @test @should_also_be_defined() end ) runtests(ARGS; init_code, custom_tests) From 28943afa79fe673aa4b41b928d075b500e1e8e27 Mon Sep 17 00:00:00 2001 From: Tim Besard Date: Fri, 10 Oct 2025 09:10:09 +0200 Subject: [PATCH 2/2] Simplify tests, covering the absolute basic case. --- test/basic.jl | 1 + test/init.jl | 2 -- test/runtests.jl | 6 +++--- 3 files changed, 4 insertions(+), 5 deletions(-) create mode 100644 test/basic.jl delete mode 100644 test/init.jl diff --git a/test/basic.jl b/test/basic.jl new file mode 100644 index 0000000..8a617b3 --- /dev/null +++ b/test/basic.jl @@ -0,0 +1 @@ +@test true diff --git a/test/init.jl b/test/init.jl deleted file mode 100644 index 23b0d93..0000000 --- a/test/init.jl +++ /dev/null @@ -1,2 +0,0 @@ -@test should_be_defined() -@test @should_also_be_defined() diff --git a/test/runtests.jl b/test/runtests.jl index 7a5e0a8..71f9757 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -2,6 +2,9 @@ using ParallelTestRunner pushfirst!(ARGS, "--verbose") +runtests(ARGS) + +# custom tests, and initialization code init_code = quote using Test should_be_defined() = true @@ -10,9 +13,6 @@ init_code = quote return :(true) end end - -runtests(ARGS; init_code) - custom_tests = Dict( "custom" => quote @test should_be_defined()