Skip to content

Commit 361b44b

Browse files
committed
runtests: keep track of tested modules
Instead of using `Base.loaded_modules`, which doesn't seem to list "local" modules (which are not associated to a package), including nested modules.
1 parent fe471c6 commit 361b44b

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/InlineTest.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ using Test: Test,
1919

2020

2121
const INLINE_TEST = Ref{Symbol}(:__INLINE_TEST__)
22+
const TESTED_MODULES = Module[]
2223

2324
include("testset.jl")
2425

@@ -34,10 +35,11 @@ struct TestsetExpr
3435
final::Bool
3536
end
3637

37-
function tests(m)
38+
function tests(m::Module)
3839
inline_test::Symbol = m (InlineTest, InlineTest.InlineTestTest) ? :__INLINE_TEST__ : INLINE_TEST[]
3940
if !isdefined(m, inline_test)
4041
@eval m $inline_test = []
42+
push!(TESTED_MODULES, m)
4143
end
4244
getfield(m, inline_test)
4345
end
@@ -213,7 +215,7 @@ function wrap_ts(partial, regex, ts::TestsetExpr, loopvals=nothing)
213215
end
214216

215217
function runtests(pattern::Union{AbstractString,Regex} = r""; wrap::Bool=true)
216-
foreach(values(Base.loaded_modules)) do m
218+
foreach(TESTED_MODULES) do m
217219
if isdefined(m, INLINE_TEST[])
218220
# will automatically skip InlineTest and InlineTest.InlineTestTest
219221
runtests(m, pattern, wrap=wrap)

test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,4 +154,4 @@ P.check("b", ["a", "b", "b|c"]) # an implicit prefix r".*" is added
154154
P.check("b|c", ["a", "b|c"]) # "b" is not matched
155155

156156
runtests()
157-
runtests(r"/a") # just test that a regex can be passed
157+
runtests(r"^/f1") # just test that a regex can be passed

0 commit comments

Comments
 (0)