Skip to content

Commit 8ae57f1

Browse files
authored
alignment: take nested testsets into account when verbose (#32)
1 parent 44cd3a1 commit 8ae57f1

File tree

2 files changed

+42
-5
lines changed

2 files changed

+42
-5
lines changed

src/testset.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,9 @@ function print_test_results(ts::ReTestSet, fmt::Format;
190190

191191
# Calculate the alignment of the test result counts by
192192
# recursively walking the tree of test sets
193-
if !ts.overall # otherwise, we don't print recursively
194-
align = get_alignment(ts, 0)
195-
end
193+
if !ts.overall # otherwise, we don't print recursively
194+
align = get_alignment(ts, 0)
195+
end
196196

197197
if !ts.overall && align > fmt.desc_align
198198
upd = true
@@ -282,7 +282,7 @@ function get_alignment(ts::ReTestSet, depth::Int)
282282
# The minimum width at this depth is
283283
ts_width = 2*depth + length(ts.description)
284284
# If all passing, no need to look at children
285-
!ts.anynonpass && return ts_width
285+
!ts.anynonpass && !ts.verbose && return ts_width
286286
# Return the maximum of this width and the minimum width
287287
# for all children (if they exist)
288288
isempty(ts.results) && return ts_width

test/runtests.jl

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1468,6 +1468,34 @@ Main.Alignment | 0
14681468
""")
14691469
end
14701470

1471+
module AlU # AlignmentUpdate, condensed to not contribute to the alignment
1472+
using ReTest
1473+
1474+
@testset "x" begin
1475+
@test true
1476+
end
1477+
@testset "a" begin
1478+
i = 2
1479+
# this testset alignment can't be computed in advance, but make sure that the
1480+
# alignment is updated (including printing "Pass" again)
1481+
@testset "b$('c'^(4j))" for j=i:-1:1
1482+
@test true
1483+
end
1484+
end
1485+
end # AlUpd
1486+
1487+
@chapter Alignment begin
1488+
check(AlU, verbose=9, [], output="""
1489+
Pass
1490+
x | 1
1491+
Pass
1492+
a | 2
1493+
bcccccccc | 1
1494+
bcccc | 1
1495+
Main.AlU | 3
1496+
""")
1497+
end
1498+
14711499

14721500
# * DryRun ...................................................................
14731501

@@ -1536,7 +1564,16 @@ end
15361564
end
15371565

15381566
@chapter Test_Testset begin
1539-
check(Test_Testset, verbose=4, ["a", "b", "c", "d1", "d2"])
1567+
check(Test_Testset, id=true, verbose=4, ["a", "b", "c", "d1", "d2"],
1568+
# check alignment with nested Test.@testset, and also id printing
1569+
# TODO: maybe for non-ReTest testsets, we should still print the
1570+
# vertical bar on the left, even if no id is printed?
1571+
output="""
1572+
Pass
1573+
1| a | 5
1574+
b | 1
1575+
c | 3
1576+
""")
15401577
end
15411578

15421579

0 commit comments

Comments
 (0)