JuliaTesting / ReferenceTests.jl

Utility package for comparing data against reference files
https://juliatesting.github.io/ReferenceTests.jl/latest/
Other
82 stars 14 forks source link

Allow forcing reading the reference file as raw txt/string #91

Closed IanButterworth closed 2 years ago

IanButterworth commented 3 years ago

In UnicodePlots's reference tests, some of the txt files were being erroneously detected as Gadget2 filetypes, where they just needed to be parsed as raw txt/string files.

This adds a kwarg to force that.

Used in the WIP https://github.com/Evizero/UnicodePlots.jl/pull/136

johnnychen94 commented 3 years ago

I also find this feature wanted when I try to develop Sixel.

https://github.com/JuliaImages/ImageInTerminal.jl/pull/50/files#diff-741a6a40557be43e1c66436f2e299d5dfbb2d84393475785888014f6fb036f83R6-R14

@test_reference "test.six" sixel_string

Given that FileIO queries the data format of test.six automatically and loads it as an image, @test_reference will eventually try to compare a colorant array with a string value and thus throw an error.

For this reason, I agree that letting users to explicitly choose a loading format can be quite useful.


Ideally, we would want to make query_extended smarter by dispatching also on the type of raw_actual, i.e., something like this:

query_extended(filename, ::AbstractString) = FileIO.format"TXT"
function query_extended(filename, ::Any)
    # the current query_extended implementation
end

But it's not a very trivial task with the current design because there's also a _convert function that converts to the queried format.


I'm fixing the CI failure in #92 so you might need to rebase on master when that's done.

t-bltg commented 2 years ago

@johnnychen94, I've applied your suggestions, and I think that this PR is ready.

Can you review it, and if everything is OK merge this so that we can move forward on https://github.com/Evizero/UnicodePlots.jl/pull/136 ?