Skip to content
Closed
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
6 changes: 6 additions & 0 deletions src/test_reference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ function test_reference(
rendermode=nothing;
kw...) where {F <: DataFormat, T}

return_bool = get(kw, :return_bool, false)::Bool
kw = filter(p -> p[1] != :return_bool, kw)

reference_path = reference_file.filename
reference_dir, reference_filename = splitdir(reference_path)

Expand Down Expand Up @@ -153,6 +156,7 @@ function test_reference(
end

if equiv(reference, actual)
return_bool && return true
@test true # to increase test counter if reached
else # When test fails
# Saving actual file so user can look at it
Expand All @@ -168,6 +172,8 @@ function test_reference(
)
render(rendermode, reference, actual)

return_bool && return false

if !isinteractive() && !force_update()
error("""
To update the reference images either run the tests interactively with 'include(\"test/runtests.jl\")',
Expand Down
8 changes: 8 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -180,4 +180,12 @@ end
@test_reference file Dict(:ar=>arr_float) by=comp
end

@testset "`return_bool` kwarg" begin
@testset begin
x = @test_reference "references/string1.nottxt" "This is not a .txt file, but it should be treated as such.\n" return_bool=true
println("Hello world - the value of x is: $(x)") # TODO: delete this line
@test x
end
end

end # top level testset