Skip to content

Commit f623e9f

Browse files
committed
runtests: uniquify modules in Base.loaded_modules + TESTED_MODULES
1 parent 9073398 commit f623e9f

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

src/ReTest.jl

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -221,15 +221,13 @@ function wrap_ts(partial, regex, ts::TestsetExpr, loopvals=nothing)
221221
end
222222

223223
function runtests(pattern::Union{AbstractString,Regex} = r""; wrap::Bool=true)
224-
for mods in (values(Base.loaded_modules), TESTED_MODULES)
225-
# TESTED_MODULES is not up-to-date w.r.t. package modules which have
226-
# precompilation, so we have to also look in Base.loaded_modules
227-
# TODO: look recursively in "loaded modules" which use ReTest for sub-modules
228-
foreach(mods) do m
229-
if isdefined(m, INLINE_TEST[])
230-
# will automatically skip ReTest and ReTest.ReTestTest
231-
runtests(m, pattern, wrap=wrap)
232-
end
224+
# TESTED_MODULES is not up-to-date w.r.t. package modules which have
225+
# precompilation, so we have to also look in Base.loaded_modules
226+
# TODO: look recursively in "loaded modules" which use ReTest for sub-modules
227+
for m in unique(Iterators.flatten((values(Base.loaded_modules), TESTED_MODULES)))
228+
if isdefined(m, INLINE_TEST[])
229+
# will automatically skip ReTest and ReTest.ReTestTest
230+
runtests(m, pattern, wrap=wrap)
233231
end
234232
end
235233
end

test/runtests.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,5 +156,16 @@ if VERSION >= v"1.3"
156156
P.check("b|c", ["a", "b|c"]) # "b" is not matched
157157
end
158158

159+
RUN = []
160+
@testset "toplevel" begin
161+
# this tests that the testset is run exactly once
162+
# Main is special here, as it's both in Base.loaded_modules
163+
# and it gets registered automatically in ReTest.TESTED_MODULES
164+
push!(RUN, "toplevel")
165+
@test true
166+
end
167+
159168
runtests()
169+
@test RUN == ["toplevel"]
170+
160171
runtests(r"^/f1") # just test that a regex can be passed

0 commit comments

Comments
 (0)