Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions base/test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -543,12 +543,15 @@ along with a summary of the test results.
type DefaultTestSet <: AbstractTestSet
description::AbstractString
results::Vector
n_passed::Int
anynonpass::Bool
end
DefaultTestSet(desc) = DefaultTestSet(desc, [], false)
DefaultTestSet(desc) = DefaultTestSet(desc, [], 0, false)

# For a passing or broken result, simply store the result
record(ts::DefaultTestSet, t::Union{Pass,Broken}) = (push!(ts.results, t); t)
# 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)

# For the other result types, immediately print the error message
# but do not terminate. Print a backtrace.
Expand Down Expand Up @@ -691,10 +694,9 @@ end
# Recursive function that counts the number of test results of each
# type directly in the testset, and totals across the child testsets
function get_test_counts(ts::DefaultTestSet)
passes, fails, errors, broken = 0, 0, 0, 0
passes, fails, errors, broken = ts.n_passed, 0, 0, 0
c_passes, c_fails, c_errors, c_broken = 0, 0, 0, 0
for t in ts.results
isa(t, Pass) && (passes += 1)
isa(t, Fail) && (fails += 1)
isa(t, Error) && (errors += 1)
isa(t, Broken) && (broken += 1)
Expand Down
8 changes: 4 additions & 4 deletions test/test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,13 @@ end
@test true
end
@test typeof(ts) == Base.Test.DefaultTestSet
@test typeof(ts.results[1]) == Base.Test.Pass
@test ts.n_passed == 1
tss = @testset "@testset/for should return an array of testsets: $i" for i in 1:3
@test true
end
@test length(tss) == 3
@test typeof(tss[1]) == Base.Test.DefaultTestSet
@test typeof(tss[1].results[1]) == Base.Test.Pass
@test tss[1].n_passed == 1
end
@testset "accounting" begin
local ts
Expand Down Expand Up @@ -205,14 +205,14 @@ ts = @testset "@testset should return the testset" begin
@test true
end
@test typeof(ts) == Base.Test.DefaultTestSet
@test typeof(ts.results[1]) == Base.Test.Pass
@test ts.n_passed == 1

tss = @testset "@testset/for should return an array of testsets: $i" for i in 1:3
@test true
end
@test length(tss) == 3
@test typeof(tss[1]) == Base.Test.DefaultTestSet
@test typeof(tss[1].results[1]) == Base.Test.Pass
@test tss[1].n_passed == 1

# Issue #17908 (return)
testset_depth17908 = Test.get_testset_depth()
Expand Down