Skip to content

Commit adfefa4

Browse files
add option to record passes
1 parent c7a28b2 commit adfefa4

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

stdlib/Test/src/Test.jl

+16-2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ const DISPLAY_FAILED = (
4343

4444
const FAIL_FAST = Ref{Bool}(false)
4545

46+
const record_passes = OncePerProcess{Bool}() do
47+
return Base.get_bool_env("JULIA_TEST_RECORD_PASSES", false)
48+
end
49+
4650
#-----------------------------------------------------------------------
4751

4852
# Backtrace utility functions
@@ -1100,8 +1104,18 @@ struct FailFastError <: Exception end
11001104

11011105
# For a broken result, simply store the result
11021106
record(ts::DefaultTestSet, t::Broken) = (push!(ts.results, t); t)
1103-
# For a passed result, do not store the result since it uses a lot of memory
1104-
record(ts::DefaultTestSet, t::Pass) = (ts.n_passed += 1; t)
1107+
# For a passed result, do not store the result since it uses a lot of memory, unless
1108+
# `record_passes()` is true. i.e. set env var `JULIA_TEST_RECORD_PASSES=true` before running any testsets
1109+
function record(ts::DefaultTestSet, t::Pass)
1110+
ts.n_passed += 1
1111+
if record_passes()
1112+
# throw away the captured data so it can be GC-ed
1113+
t_nodata = Pass(t.test_type, t.orig_expr, nothing, t.value, t.source, t.message_only)
1114+
push!(ts.results, t_nodata)
1115+
return t_nodata
1116+
end
1117+
return t
1118+
end
11051119

11061120
# For the other result types, immediately print the error message
11071121
# but do not terminate. Print a backtrace.

0 commit comments

Comments
 (0)