Skip to content

Commit c9d0acb

Browse files
Also report time for failed tests (#34)
1 parent f38c67a commit c9d0acb

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/ParallelTestRunner.jl

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,15 +165,23 @@ function print_test_finished(test, wrkr, record::TestRecord, ctx::TestIOContext)
165165
end
166166
end
167167

168-
function print_test_errorred(::Type{TestRecord}, wrkr, test, ctx::TestIOContext)
168+
function print_test_errorred(::Type{TestRecord}, wrkr, test, ctx::TestIOContext, test_time)
169169
lock(ctx.lock)
170170
try
171171
printstyled(ctx.stderr, test, color = :red)
172172
printstyled(
173173
ctx.stderr,
174-
lpad("($wrkr)", ctx.name_align - textwidth(test) + 1, " "), " |",
175-
" "^ctx.elapsed_align, " failed at $(now())\n", color = :red
174+
lpad("($wrkr)", ctx.name_align - textwidth(test) + 1, " "), " |"
175+
, color = :red
176176
)
177+
time_str = @sprintf("%7.2f", test_time)
178+
printstyled(ctx.stderr, lpad(time_str, ctx.elapsed_align + 1, " "), "", color = :red)
179+
180+
failed_str = "failed at $(now())\n"
181+
# 11 -> 3 from " | " 3x and 2 for each " " on either side
182+
fail_align = (11 + ctx.gc_align + ctx.percent_align + ctx.alloc_align + ctx.rss_align - textwidth(failed_str)) ÷ 2 + textwidth(failed_str)
183+
failed_str = lpad(failed_str, fail_align, " ")
184+
printstyled(ctx.stderr, failed_str, color = :red)
177185

178186
flush(ctx.stderr)
179187
finally
@@ -684,10 +692,10 @@ function runtests(mod::Module, ARGS; test_filter = Returns(true), RecordType = T
684692
print_test_finished(test_name, wrkr, record, io_ctx)
685693

686694
elseif msg_type == :errored
687-
test_name, wrkr = msg[2], msg[3]
695+
test_name, wrkr, test_time = msg[2], msg[3], msg[4]
688696

689697
clear_status()
690-
print_test_errorred(RecordType, wrkr, test_name, io_ctx)
698+
print_test_errorred(RecordType, wrkr, test_name, io_ctx, test_time)
691699
end
692700
end
693701

@@ -773,7 +781,7 @@ function runtests(mod::Module, ARGS; test_filter = Returns(true), RecordType = T
773781
end
774782
else
775783
@assert result isa Exception
776-
put!(printer_channel, (:errored, test, wrkr))
784+
put!(printer_channel, (:errored, test, wrkr, test_t1-test_t0))
777785
if do_quickfail
778786
stop_work()
779787
end

0 commit comments

Comments
 (0)