Skip to content

Commit 20347a6

Browse files
authored
fix testset printing and add test (#20232)
* bring back testset printing * fix nested testset printing
1 parent ad8b477 commit 20347a6

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

base/test.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@ function print_counts(ts::DefaultTestSet, depth, align,
730730
subtotal = passes + fails + errors + broken + c_passes + c_fails + c_errors + c_broken
731731
# Print test set header, with an alignment that ensures all
732732
# the test results appear above each other
733-
print(rpad(string(lpad(" ",depth), ts.description), align, " "), " | ")
733+
print(rpad(string(" "^depth, ts.description), align, " "), " | ")
734734

735735
np = passes + c_passes
736736
if np > 0

test/test.jl

+30
Original file line numberDiff line numberDiff line change
@@ -426,3 +426,33 @@ let io = IOBuffer()
426426
@test contains(str, "msg")
427427
@test !contains(str, "backtrace()")
428428
end
429+
430+
msg = readstring(ignorestatus(`$(Base.julia_cmd()) --startup-file=no --color=no -e '
431+
using Base.Test
432+
433+
foo(x) = length(x)^2
434+
435+
@testset "Foo Tests" begin
436+
@testset "Animals" begin
437+
@testset "Felines" begin
438+
@test foo("cat") == 9
439+
end
440+
@testset "Canines" begin
441+
@test foo("dog") == 11
442+
end
443+
end
444+
@testset "Arrays" begin
445+
@test foo(zeros(2)) == 4
446+
@test foo(ones(4)) == 15
447+
end
448+
end'`))
449+
450+
@test contains(msg,
451+
"""
452+
Test Summary: | Pass Fail Total
453+
Foo Tests | 2 2 4
454+
Animals | 1 1 2
455+
Felines | 1 1
456+
Canines | 1 1
457+
Arrays | 1 1 2
458+
""")

0 commit comments

Comments
 (0)