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

Default to plain text load/save? #27

Closed christopher-dG closed 4 years ago

christopher-dG commented 5 years ago

What I want is to do reference tests on plain text files that can have arbitrary file extensions, or no file extension at all (for PkgTemplates), but they fail whenever there isn't a FIleIO format defined for the extension.

I've worked around this by renaming all my fixtures to .txt files, as @oxinabox suggested. But could we perhaps default to treating anything not recognized by FileIO as a plain text file?

oxinabox commented 5 years ago

I think just change https://github.com/Evizero/ReferenceTests.jl/blob/06c74645dcf474b12daf6e9732cdc2ab3927453e/src/test_reference.jl#L64-L75

to

function query_extended(filename)
    file, ext = splitext(filename)
    if uppercase(ext) == ".SHA256"
        res = File{format"SHA256"}(filename)
    else
        res = query(filename)
        if res isa File{DataFormat{:UNKNOWN}}
            res = File{format"TXT"}(filename)
        end
    end
    res
end

Plus add tests.

PR?