Skip to content

Instantly share code, notes, and snippets.

@ronisbr
Created May 14, 2018 00:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ronisbr/2b973adc074e5a176b124a6886aee23b to your computer and use it in GitHub Desktop.
Save ronisbr/2b973adc074e5a176b124a6886aee23b to your computer and use it in GitHub Desktop.
Proposed patch to print reports every time
diff -rNu julia-orig/base/test.jl julia/base/test.jl
--- julia-orig/base/test.jl 2018-05-13 21:04:52.000000000 -0300
+++ julia/base/test.jl 2018-05-13 21:16:51.000000000 -0300
@@ -546,11 +546,13 @@
"""
mutable struct DefaultTestSet <: AbstractTestSet
description::AbstractString
+ always_print_report::Bool
results::Vector
n_passed::Int
anynonpass::Bool
end
-DefaultTestSet(desc) = DefaultTestSet(desc, [], 0, false)
+DefaultTestSet(desc) = DefaultTestSet(desc, false, [], 0, false)
+DefaultTestSet(desc, always_print_report) = DefaultTestSet(desc, always_print_report, [], 0, false)
# For a broken result, simply store the result
record(ts::DefaultTestSet, t::Broken) = (push!(ts.results, t); t)
@@ -776,8 +778,8 @@
end
println()
- # Only print results at lower levels if we had failures
- if np + nb != subtotal
+ # Only print results at lower levels if we had failures or if the user wants
+ if (ts.always_print_report) || (np + nb != subtotal)
for t in ts.results
if isa(t, DefaultTestSet)
print_counts(t, depth + 1, align,
@@ -836,7 +838,7 @@
Generate the code for a `@testset` with a `begin`/`end` argument
"""
function testset_beginend(args, tests)
- desc, testsettype, options = parse_testset_args(args[1:end-1])
+ desc, testsettype, always_print_report, options = parse_testset_args(args[1:end-1])
if desc === nothing
desc = "test set"
end
@@ -851,7 +853,7 @@
# finally removing the testset and giving it a chance to take
# action (such as reporting the results)
quote
- ts = $(testsettype)($desc; $options...)
+ ts = $(testsettype)($desc, $always_print_report; $options...)
# this empty loop is here to force the block to be compiled,
# which is needed for backtrace scrubbing to work correctly.
while false; end
@@ -887,7 +889,7 @@
error("Unexpected argument to @testset")
end
- desc, testsettype, options = parse_testset_args(args[1:end-1])
+ desc, testsettype, always_print_report, options = parse_testset_args(args[1:end-1])
if desc === nothing
# No description provided. Generate from the loop variable names
@@ -914,7 +916,7 @@
pop_testset()
push!(arr, finish(ts))
end
- ts = $(testsettype)($desc; $options...)
+ ts = $(testsettype)($desc, $always_print_report; $options...)
push_testset(ts)
first_iteration = false
try
@@ -950,11 +952,15 @@
function parse_testset_args(args)
desc = nothing
testsettype = nothing
+ always_print_report = false
options = :(Dict{Symbol, Any}())
for arg in args
# a standalone symbol is assumed to be the test set we should use
if isa(arg, Symbol)
testsettype = esc(arg)
+ # a boolean is assumed to be the option to print reports even on failure
+ elseif isa(arg, Bool)
+ always_print_report = arg
# a string is the description
elseif isa(arg, AbstractString) || (isa(arg, Expr) && arg.head == :string)
desc = esc(arg)
@@ -968,7 +974,7 @@
end
end
- (desc, testsettype, options)
+ (desc, testsettype, always_print_report, options)
end
#-----------------------------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment