Skip to content

Commit fb0db68

Browse files
committed
print module header when it doesn't match the passed module
We don't print the module header when only one module is tested, and this module is passed explicitly as an argument to `retest`. But we were wrongly not printing this header when one module not containing tests was passed, which was containing a submodule with tests, and `recursive=true`. In this case, we want to print the submodule header, as this submodule was no passed explicitly to `retest` (idem with `MyPackageTests` and `load=true`).
1 parent 6430782 commit fb0db68

File tree

3 files changed

+28
-7
lines changed

3 files changed

+28
-7
lines changed

src/ReTest.jl

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -658,11 +658,8 @@ function retest(@nospecialize(args::ArgType...);
658658
dry, stats, shuffle, group, verbose, recursive, id, strict, dup, static, marks, spin =
659659
update_keywords(args, dry, stats, shuffle, group, verbose, recursive, id, strict, dup, static, marks, spin)
660660

661-
implicitmodules, modules, verbose = process_args(args; verbose=verbose, shuffle=shuffle,
662-
recursive=recursive, load=load)
663-
# overall: print header for each module, and probably "Overall" summary for all modules
664-
overall = length(modules) > 1
665-
module_header = overall | implicitmodules
661+
module_header, modules, verbose = process_args(args; verbose=verbose, shuffle=shuffle,
662+
recursive=recursive, load=load)
666663
root = Testset.ReTestSet(Main, "Overall", overall=true)
667664

668665
maxidw = Ref{Int}(0) # visual width for showing IDs (Ref for mutability in hack below)
@@ -1273,6 +1270,13 @@ function process_args(@nospecialize(args);
12731270
end
12741271
end
12751272

1273+
# module_header: whether to print module header before testsets belonging to that module
1274+
# we compute module_header before filtering out modules without tests, so that
1275+
# if a parent module with no tests is explicitly passed, which contains a submodule
1276+
# and recursive==true, then the submodule name is printed (and similarly for
1277+
# printing `MyPackageTests` when `MyPackage` is passed and `load==true`)
1278+
module_header = length(modules) > 1 | implicitmodules
1279+
12761280
# remove modules which don't have tests, which can happen when a parent module without
12771281
# tests is passed to retest in order to run tests in its submodules
12781282
filter!(m -> isdefined(m, INLINE_TEST), modules)
@@ -1288,7 +1292,7 @@ function process_args(@nospecialize(args);
12881292
end
12891293
verbose = Int(verbose)
12901294

1291-
(implicitmodules=implicitmodules, modules=[mod => modpats[mod] for mod in modules],
1295+
(module_header=module_header, modules=[mod => modpats[mod] for mod in modules],
12921296
verbose=verbose)
12931297
end
12941298

test/runtests.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,23 @@ end
835835
# TODO: test in a distributed setting
836836
end
837837

838+
module MiscSubmoduleHeader
839+
module Sub
840+
using ReTest
841+
@testset "a" begin end
842+
end
843+
end
844+
845+
@chapter MiscSubmoduleHeader begin
846+
check(MiscSubmoduleHeader, recursive=true, dry=true, [], output="""
847+
Main.MiscSubmoduleHeader.Sub
848+
1| a
849+
""")
850+
check(MiscSubmoduleHeader.Sub, recursive=true, dry=true, [], output="""
851+
1| a
852+
""")
853+
end
854+
838855
module Bugs
839856
using ReTest
840857
@testset "macros with nothing" begin

test/setup.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function trace(x)
1010
push!(RUN, x)
1111
@test true
1212
end
13-
end
13+
end # module Trace
1414

1515
# NOTE: all keywords have the same defaults as `retest`, except `marks`
1616
# Also, not sure why ReTest.def has to be qualified, when we just import def from ReTest

0 commit comments

Comments
 (0)