Skip to content

Commit c9af808

Browse files
Print completion message when all tests are done
1 parent f3735d5 commit c9af808

File tree

3 files changed

+35
-17
lines changed

3 files changed

+35
-17
lines changed

src/ReTestItems.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -449,13 +449,13 @@ function _runtests_in_current_env(
449449
end
450450
end
451451
Test.TESTSET_PRINT_ENABLE[] = true # reenable printing so our `finish` prints
452+
# Let users know if tests are done, and if all of them ran (or if we failed fast).
453+
# Print this above the final report as there might have been other logs printed
454+
# since a failfast-cancellation was printed, but print it ASAP after tests finish
455+
# in case any of the recording/reporting steps have an issue.
456+
print_completion_summary(testitems; failedfast=(cfg.failfast && is_cancelled(testitems)))
452457
record_results!(testitems)
453458
cfg.report && write_junit_file(proj_name, dirname(projectfile), testitems.graph.junit)
454-
if cfg.failfast && is_cancelled(testitems)
455-
# Let users know if not all tests ran. Print this just above the final report as
456-
# there might have been other logs printed since the cancellation was printed.
457-
print_failfast_summary(testitems)
458-
end
459459
Test.finish(testitems) # print summary of total passes/failures/errors
460460
finally
461461
Test.TESTSET_PRINT_ENABLE[] = true

src/log_capture.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,9 +310,13 @@ end
310310
# So that the user is warned that not all tests were run.
311311
# We don't use loglock here, because this is only called once on the coordinator after all
312312
# tasks running tests have stopped and we're printing the final test report.
313-
function print_failfast_summary(t::TestItems)
313+
function print_completion_summary(t::TestItems; failedfast::Bool)
314314
io = DEFAULT_STDOUT[]
315-
printstyled(io, "[ Fail Fast: "; bold=true, color=Base.warn_color())
315+
if failedfast
316+
printstyled(io, "[ Fail Fast: "; bold=true, color=Base.warn_color())
317+
else
318+
printstyled(io, "[ Tests Completed: "; bold=true, color=Base.info_color())
319+
end
316320
println(io, "$(t.count)/$(length(t.testitems)) test items were run.")
317321
return nothing
318322
end

test/integrationtests.jl

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,24 @@ end
4545

4646
# test we can call runtests manually w/ directory
4747
@testset "manual `runtests(dir)`" begin
48-
results = encased_testset() do
49-
runtests(joinpath(TEST_PKG_DIR, "NoDeps.jl"))
48+
using IOCapture
49+
c = IOCapture.capture() do
50+
encased_testset(() -> runtests(joinpath(TEST_PKG_DIR, "NoDeps.jl")))
5051
end
52+
results = c.value
5153
@test n_passed(results) == 2 # NoDeps has two test files with a test each
54+
@test contains(c.output, "[ Tests Completed: 2/2 test items were run.")
5255
end
5356

5457
@testset "manual `runtests(file)`" begin
5558
# test we can point to a file at the base of the package (not just in `src` or `test`)
56-
results = encased_testset() do
57-
runtests(joinpath(TEST_PKG_DIR, "NoDeps.jl", "toplevel_tests.jl"))
59+
using IOCapture
60+
c = IOCapture.capture() do
61+
encased_testset(() -> runtests(joinpath(TEST_PKG_DIR, "NoDeps.jl", "toplevel_tests.jl")))
5862
end
63+
results = c.value
5964
@test n_passed(results) == 1
65+
@test contains(c.output, "[ Tests Completed: 1/1 test items were run.")
6066
end
6167

6268
@testset "`runtests(path)` auto finds testsetups" begin
@@ -273,20 +279,28 @@ end
273279
nworkers = 2
274280
@testset "runtests with nworkers = $nworkers" verbose=true begin
275281
@testset "Pkg.test() $pkg" for pkg in TEST_PKGS
276-
results = with_test_package(pkg) do
277-
withenv("RETESTITEMS_NWORKERS" => nworkers) do
278-
Pkg.test()
282+
c = IOCapture.capture() do
283+
with_test_package(pkg) do
284+
withenv("RETESTITEMS_NWORKERS" => nworkers) do
285+
Pkg.test()
286+
end
279287
end
280288
end
289+
results = c.value
281290
@test all_passed(results)
291+
@test contains(c.output, "[ Tests Completed")
282292
end
283293
@testset "Pkg.test() DontPass.jl" begin
284-
results = with_test_package("DontPass.jl") do
285-
withenv("RETESTITEMS_NWORKERS" => 2) do
286-
Pkg.test()
294+
c = IOCapture.capture() do
295+
with_test_package("DontPass.jl") do
296+
withenv("RETESTITEMS_NWORKERS" => 2) do
297+
Pkg.test()
298+
end
287299
end
288300
end
301+
results = c.value
289302
@test length(non_passes(results)) > 0
303+
@test contains(c.output, "[ Tests Completed")
290304
end
291305
end
292306

0 commit comments

Comments
 (0)