Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

alignment: take nested testsets into account when verbose #32

Merged
merged 1 commit into from
Aug 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/testset.jl
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,9 @@ function print_test_results(ts::ReTestSet, fmt::Format;

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

if !ts.overall && align > fmt.desc_align
upd = true
Expand Down Expand Up @@ -282,7 +282,7 @@ function get_alignment(ts::ReTestSet, depth::Int)
# The minimum width at this depth is
ts_width = 2*depth + length(ts.description)
# If all passing, no need to look at children
!ts.anynonpass && return ts_width
!ts.anynonpass && !ts.verbose && return ts_width
# Return the maximum of this width and the minimum width
# for all children (if they exist)
isempty(ts.results) && return ts_width
Expand Down
39 changes: 38 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1468,6 +1468,34 @@ Main.Alignment | 0
""")
end

module AlU # AlignmentUpdate, condensed to not contribute to the alignment
using ReTest

@testset "x" begin
@test true
end
@testset "a" begin
i = 2
# this testset alignment can't be computed in advance, but make sure that the
# alignment is updated (including printing "Pass" again)
@testset "b$('c'^(4j))" for j=i:-1:1
@test true
end
end
end # AlUpd

@chapter Alignment begin
check(AlU, verbose=9, [], output="""
Pass
x | 1
Pass
a | 2
bcccccccc | 1
bcccc | 1
Main.AlU | 3
""")
end


# * DryRun ...................................................................

Expand Down Expand Up @@ -1536,7 +1564,16 @@ end
end

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


Expand Down