Custom global equality selector#135
Open
jkrumbiegel wants to merge 4 commits intoJuliaTesting:masterfrom
Open
Conversation
|
Maybe a - for ReferenceTests simpler - alternative would to not increase the API here but tell downstream packages to use custom functions or macros in their test that set |
Author
|
Yeah that would be the alternative. I thought for the average user it would be a bit complex to set up a macro correctly that forwards everything but |
|
It could be documented in ReferenceTests how it can be done. |
|
For instance, I think the following would work (untested): julia> macro test_ref(ref, actual, kwargs...)
return esc(:($ReferenceTests.@test_reference($ref, $actual, by = $isequal, $(kwargs...))))
end
@test_ref (macro with 1 method)
julia> @macroexpand @test_ref "test" img
:(ReferenceTests.test_reference(ReferenceTests.abspath(ReferenceTests.joinpath("/Users/david", "test")), img, by = isequal))
julia> @macroexpand @test_ref "test" img a = 5 b = 2
:(ReferenceTests.test_reference(ReferenceTests.abspath(ReferenceTests.joinpath("/Users/david", "test")), img, by = isequal, a = 5, b = 2))
julia> @macroexpand @test_ref "test" img a = 5 b = x
:(ReferenceTests.test_reference(ReferenceTests.abspath(ReferenceTests.joinpath("/Users/david", "test")), img, by = isequal, a = 5, b = x))
julia> @macroexpand @test_ref "test" img a = 5 b = x by = isapprox
:(ReferenceTests.test_reference(ReferenceTests.abspath(ReferenceTests.joinpath("/Users/david", "test")), img, by = isequal, a = 5, b = x, by = isapprox)) |
Member
|
indeed I often create such functions/macros anyway to map to where in the directory structure the test files live etc. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a way to globally change the function which determines the equality function to use for a given pair of
reference, actualarguments. The reason is that it's currently annoying to annotate every image reference test withbyif you don't want to use the defaultpsnr_equalitycomparison which is too insensitive for my purposes.You can either change it permanently with
default_equality_selector!or temporarily withwith_default_equality_selector. The setting is implemented as a simpleRefas the Julia compat is too low for ScopedValues. But ScopedValues might be overkill anyway.Example: