diff --git a/stdlib/Test/src/Test.jl b/stdlib/Test/src/Test.jl index e8d670b3d7d00..9674123aa223f 100644 --- a/stdlib/Test/src/Test.jl +++ b/stdlib/Test/src/Test.jl @@ -43,6 +43,10 @@ const DISPLAY_FAILED = ( const FAIL_FAST = Ref{Bool}(false) +const record_passes = OncePerProcess{Bool}() do + return Base.get_bool_env("JULIA_TEST_RECORD_PASSES", false) +end + #----------------------------------------------------------------------- # Backtrace utility functions @@ -1101,7 +1105,11 @@ struct FailFastError <: Exception end # For a broken result, simply store the result record(ts::DefaultTestSet, t::Broken) = (push!(ts.results, t); t) # For a passed result, do not store the result since it uses a lot of memory -record(ts::DefaultTestSet, t::Pass) = (ts.n_passed += 1; t) +function record(ts::DefaultTestSet, t::Pass) + ts.n_passed += 1 + record_passes() && push!(ts.results, t) + return t +end # For the other result types, immediately print the error message # but do not terminate. Print a backtrace. diff --git a/test/testdefs.jl b/test/testdefs.jl index eb0bf570b11fd..e581bad245f5f 100644 --- a/test/testdefs.jl +++ b/test/testdefs.jl @@ -4,7 +4,9 @@ using Test, Random function runtests(name, path, isolate=true; seed=nothing) old_print_setting = Test.TESTSET_PRINT_ENABLE[] + old_record_passes = get(ENV, "JULIA_TEST_RECORD_PASSES", nothing) Test.TESTSET_PRINT_ENABLE[] = false + ENV["JULIA_TEST_RECORD_PASSES"] = Base.get_bool_env("CI", false) # remove all hint_handlers, so that errorshow tests are not changed by which packages have been loaded on this worker already # packages that call register_error_hint should also call this again, and then re-add any hooks they want to test empty!(Base.Experimental._hint_handlers) @@ -97,6 +99,12 @@ function runtests(name, path, isolate=true; seed=nothing) Test.TESTSET_PRINT_ENABLE[] = old_print_setting ex isa TestSetException || rethrow() return Any[ex] + finally + if old_record_passes === nothing + delete!(ENV, "JULIA_TEST_RECORD_PASSES") + else + ENV["JULIA_TEST_RECORD_PASSES"] = old_record_passes + end end end