Skip to content

Commit 0070305

Browse files
committed
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).
1 parent b229504 commit 0070305

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

src/ParallelTestRunner.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,10 @@ function runtest(::Type{TestRecord}, f, name, init_code)
146146
wait(@spawnat 1 print_testworker_started(name, id))
147147
end
148148

149+
Core.eval(mod, init_code)
149150
data = @eval mod begin
150151
GC.gc(true)
151152
Random.seed!(1)
152-
$init_code
153153

154154
res = @timed @testset $name begin
155155
$f

test/init.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
@test should_be_defined()
2+
@test @should_also_be_defined()

test/runtests.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,18 @@ pushfirst!(ARGS, "--verbose")
55
init_code = quote
66
using Test
77
should_be_defined() = true
8+
9+
macro should_also_be_defined()
10+
return :(true)
11+
end
812
end
913

1014
runtests(ARGS; init_code)
1115

1216
custom_tests = Dict(
1317
"custom" => quote
1418
@test should_be_defined()
19+
@test @should_also_be_defined()
1520
end
1621
)
1722
runtests(ARGS; init_code, custom_tests)

0 commit comments

Comments
 (0)