Skip to content

Commit 3a4a8b4

Browse files
committed
Fix #18739, Make testset results printing better
Now results come in one by one and print their memory/timing data as they come in. We will no longer print rss results twice. Also, each test now prints which worker it ran on.
1 parent ae1b30b commit 3a4a8b4

File tree

3 files changed

+31
-30
lines changed

3 files changed

+31
-30
lines changed

base/test.jl

+5-3
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ immutable Pass <: Result
4444
end
4545
function Base.show(io::IO, t::Pass)
4646
print_with_color(:green, io, "Test Passed\n")
47-
print(io, " Expression: ", t.orig_expr)
47+
if !(t.orig_expr === nothing)
48+
print(io, " Expression: ", t.orig_expr)
49+
end
4850
if t.test_type == :test_throws
4951
# The correct type of exception was thrown
5052
print(io, "\n Thrown: ", typeof(t.value))
@@ -139,9 +141,9 @@ type Broken <: Result
139141
end
140142
function Base.show(io::IO, t::Broken)
141143
print_with_color(:yellow, io, "Test Broken\n")
142-
if t.test_type == :skipped
144+
if t.test_type == :skipped && !(t.orig_expr === nothing)
143145
println(io, " Skipped: ", t.orig_expr)
144-
else
146+
elseif !(t.orig_expr === nothing)
145147
println(io, "Expression: ", t.orig_expr)
146148
end
147149
end

test/runtests.jl

+26-25
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,16 @@ cd(dirname(@__FILE__)) do
4444
end
4545

4646
@everywhere include("testdefs.jl")
47+
48+
#pretty print the information about gc and mem usage
49+
name_align = max(length("Test (Worker)"), maximum(map(x -> length(x) + 3 + ndigits(nworkers()), tests)))
50+
elapsed_align = length("Time (s)")
51+
gc_align = length("GC (s)")
52+
percent_align = length("GC %")
53+
alloc_align = length("Alloc (MB)")
54+
rss_align = length("RSS (MB)")
55+
print_with_color(:white, rpad("Test (Worker)",name_align," "), " | ")
56+
print_with_color(:white, "Time (s) | GC (s) | GC % | Alloc (MB) | RSS (MB)\n")
4757
results=[]
4858
@sync begin
4959
for p in workers()
@@ -67,6 +77,22 @@ cd(dirname(@__FILE__)) do
6777
isa(resp, Exception) ? rethrow(resp) : error("Halting tests. Memory limit reached : $resp > $max_worker_rss")
6878
end
6979
end
80+
if !isa(resp[1], Exception)
81+
print_with_color(:white, rpad(test*" ($p)", name_align, " "), " | ")
82+
time_str = @sprintf("%7.2f",resp[2])
83+
print_with_color(:white, rpad(time_str,elapsed_align," "), " | ")
84+
gc_str = @sprintf("%5.2f",resp[5].total_time/10^9)
85+
print_with_color(:white, rpad(gc_str,gc_align," "), " | ")
86+
87+
# since there may be quite a few digits in the percentage,
88+
# the left-padding here is less to make sure everything fits
89+
percent_str = @sprintf("%4.1f",100*resp[5].total_time/(10^9*resp[2]))
90+
print_with_color(:white, rpad(percent_str,percent_align," "), " | ")
91+
alloc_str = @sprintf("%5.2f",resp[3]/2^20)
92+
print_with_color(:white, rpad(alloc_str,alloc_align," "), " | ")
93+
rss_str = @sprintf("%5.2f",resp[6]/2^20)
94+
print_with_color(:white, rpad(rss_str,rss_align," "), "\n")
95+
end
7096
end
7197
end
7298
end
@@ -161,31 +187,6 @@ cd(dirname(@__FILE__)) do
161187
end
162188
println()
163189
Base.Test.print_test_results(o_ts,1)
164-
#pretty print the information about gc and mem usage
165-
name_align = maximum(map(x -> length(x[1]), results))
166-
elapsed_align = length("Total time (s):")
167-
gc_align = length("GC time (s):")
168-
percent_align = length("Percent in gc:")
169-
alloc_align = length("Allocated (MB):")
170-
rss_align = length("RSS (MB):")
171-
print_with_color(:white, rpad("Test:",name_align," "), " | ")
172-
print_with_color(:white, "Total time (s): | GC time (s): | Percent in gc: | Allocated (MB): | RSS (MB):\n")
173-
for res in results
174-
if !isa(res[2][1], Exception)
175-
print_with_color(:white, rpad("$(res[1])",name_align," "), " | ")
176-
time_str = @sprintf("%7.2f",res[2][2])
177-
print_with_color(:white, rpad(time_str,elapsed_align," "), " | ")
178-
gc_str = @sprintf("%7.2f",res[2][5].total_time/10^9)
179-
print_with_color(:white, rpad(gc_str,gc_align," "), " | ")
180-
percent_str = @sprintf("%7.2f",100*res[2][5].total_time/(10^9*res[2][2]))
181-
print_with_color(:white, rpad(percent_str,percent_align," "), " | ")
182-
alloc_str = @sprintf("%7.2f",res[2][3]/2^20)
183-
print_with_color(:white, rpad(alloc_str,alloc_align," "), " | ")
184-
rss_str = @sprintf("%7.2f",res[2][6]/2^20)
185-
print_with_color(:white, rpad(rss_str,rss_align," "), "\n")
186-
end
187-
end
188-
189190
if !o_ts.anynonpass
190191
println(" \033[32;1mSUCCESS\033[0m")
191192
else

test/testdefs.jl

-2
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,13 @@ function runtests(name, isolate=true)
88
m = Main
99
end
1010
eval(m, :(using Base.Test))
11-
@printf(" \033[1m*\033[0m \033[31m%-21s\033[0m", name)
1211
ex = quote
1312
@timed @testset $"$name" begin
1413
include($"$name.jl")
1514
end
1615
end
1716
res_and_time_data = eval(m, ex)
1817
rss = Sys.maxrss()
19-
@printf(" maxrss %7.2f MB\n", rss / 2^20)
2018
#res_and_time_data[1] is the testset
2119
passes,fails,error,broken,c_passes,c_fails,c_errors,c_broken = Base.Test.get_test_counts(res_and_time_data[1])
2220
if res_and_time_data[1].anynonpass == false

0 commit comments

Comments
 (0)