Skip to content

Commit 11fbc45

Browse files
committed
runtests: eval testsets in a loop rather than all in one block
This is quite faster. Also, this shows the result of testsets as soon as they are compiled, rather than having to wait for everything to be compiled before starting to print.
1 parent 272f61e commit 11fbc45

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/InlineTest.jl

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,16 +76,20 @@ in which it was written (e.g. `m`, when specified).
7676
"""
7777
function runtests(m::Module, regex::Regex = r""; wrap::Bool=false)
7878
partial = partialize(regex)
79-
ex = Expr(:let,
80-
Expr(:(=), Testset.REGEX[], (partial, regex)),
81-
Expr(:block, tests(m)...))
82-
8379
if wrap
84-
ex = :(InlineTest.Test.@testset $("Tests for module $m") begin
85-
$ex
86-
end)
80+
Core.eval(m, :(InlineTest.Test.@testset $("Tests for module $m") begin
81+
let $(Testset.REGEX[]) = ($partial, $regex)
82+
$(tests(m)...)
83+
end
84+
end))
85+
else
86+
for ts in tests(m)
87+
# it's faster to evel in a loop than to eval a block containing tests(m)
88+
Core.eval(m, :(let $(Testset.REGEX[]) = ($partial, $regex)
89+
$ts
90+
end))
91+
end
8792
end
88-
Core.eval(m, ex)
8993
nothing
9094
end
9195

0 commit comments

Comments
 (0)