Skip to content

Commit b992175

Browse files
authored
Eval the initialization code separately. (#8)
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 b992175

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
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/basic.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@test true

test/init.jl

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/runtests.jl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,21 @@ using ParallelTestRunner
22

33
pushfirst!(ARGS, "--verbose")
44

5+
runtests(ARGS)
6+
7+
# custom tests, and initialization code
58
init_code = quote
69
using Test
710
should_be_defined() = true
8-
end
9-
10-
runtests(ARGS; init_code)
1111

12+
macro should_also_be_defined()
13+
return :(true)
14+
end
15+
end
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)