Skip to content

Commit 009aee1

Browse files
committed
fix alignment when only one testset-for is run
1 parent dc2c59f commit 009aee1

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

src/ReTest.jl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ function retest(@nospecialize(args::ArgType...);
711711
module_ts = Testset.ReTestSet(Main, string(mod) * ':', overall=true)
712712
push!(root.results, module_ts)
713713

714-
many = length(tests) > 1 || isfor(tests[1]) # FIXME: isfor when only one iteration
714+
many = hasmany(tests)
715715

716716
printlock = ReentrantLock()
717717
previewchan =
@@ -1298,10 +1298,11 @@ function fetchtests((mod, pat), verbose, module_header, maxidw; static, strict,
12981298
maxidw[] = max(maxidw[], ndigits(id-1))
12991299

13001300
tests = filter(ts -> ts.run, tests)
1301-
many = length(tests) > 1
1302-
indented = isindented(verbose, module_header, many)
13031301

13041302
if !isempty(tests)
1303+
many = hasmany(tests)
1304+
indented = isindented(verbose, module_header, many)
1305+
13051306
if indented
13061307
descwidth += 2
13071308
end
@@ -1315,6 +1316,10 @@ end
13151316
isindented(verbose, module_header, many) = (verbose > 0) & module_header
13161317
module_summary(verbose, many) = many | iszero(verbose)
13171318

1319+
# assumes !isempty(tests)
1320+
# FIXME: isfor when only one iteration
1321+
hasmany(tests) = length(tests) > 1 || isfor(tests[1])
1322+
13181323
function dryrun(mod::Module, ts::TestsetExpr, pat::Pattern, align::Int=0, parentsubj=""
13191324
; maxidw::Int, marks::Bool, # external calls
13201325
# only recursive calls:

test/runtests.jl

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,6 +1057,27 @@ end # NoTests
10571057
end
10581058

10591059

1060+
# * Alignment ................................................................
1061+
1062+
module Alignment
1063+
using ReTest, ..Trace
1064+
1065+
@testset "l$i" for i=1:2
1066+
end
1067+
end # Alignment
1068+
1069+
@chapter Alignment begin
1070+
# here, there is only one testset, but it's a loop, make sure the alignment takes
1071+
# into account that a "testset summary" will be printed
1072+
check(Alignment, [], output="""
1073+
Pass
1074+
l1 | 0
1075+
l2 | 0
1076+
Main.Alignment | 0
1077+
""")
1078+
end
1079+
1080+
10601081
# * DryRun ...................................................................
10611082

10621083
module DryRun

0 commit comments

Comments
 (0)