Skip to content

Commit

Permalink
runtests: uniquify modules in Base.loaded_modules + TESTED_MODULES
Browse files Browse the repository at this point in the history
  • Loading branch information
rfourquet committed Nov 2, 2020
1 parent 9073398 commit f623e9f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/ReTest.jl
Original file line number Diff line number Diff line change
Expand Up @@ -221,15 +221,13 @@ function wrap_ts(partial, regex, ts::TestsetExpr, loopvals=nothing)
end

function runtests(pattern::Union{AbstractString,Regex} = r""; wrap::Bool=true)
for mods in (values(Base.loaded_modules), TESTED_MODULES)
# TESTED_MODULES is not up-to-date w.r.t. package modules which have
# precompilation, so we have to also look in Base.loaded_modules
# TODO: look recursively in "loaded modules" which use ReTest for sub-modules
foreach(mods) do m
if isdefined(m, INLINE_TEST[])
# will automatically skip ReTest and ReTest.ReTestTest
runtests(m, pattern, wrap=wrap)
end
# TESTED_MODULES is not up-to-date w.r.t. package modules which have
# precompilation, so we have to also look in Base.loaded_modules
# TODO: look recursively in "loaded modules" which use ReTest for sub-modules
for m in unique(Iterators.flatten((values(Base.loaded_modules), TESTED_MODULES)))
if isdefined(m, INLINE_TEST[])
# will automatically skip ReTest and ReTest.ReTestTest
runtests(m, pattern, wrap=wrap)
end
end
end
Expand Down
11 changes: 11 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -156,5 +156,16 @@ if VERSION >= v"1.3"
P.check("b|c", ["a", "b|c"]) # "b" is not matched
end

RUN = []
@testset "toplevel" begin
# this tests that the testset is run exactly once
# Main is special here, as it's both in Base.loaded_modules
# and it gets registered automatically in ReTest.TESTED_MODULES
push!(RUN, "toplevel")
@test true
end

runtests()
@test RUN == ["toplevel"]

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

2 comments on commit f623e9f

@rfourquet
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/24034

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.0 -m "<description of version>" f623e9fa10ecaa0afe557d54ede05f8cd8cb0a80
git push origin v0.1.0

Please sign in to comment.