Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

helper for reference file name #93

Closed
goretkin opened this issue May 19, 2021 · 1 comment
Closed

helper for reference file name #93

goretkin opened this issue May 19, 2021 · 1 comment

Comments

@goretkin
Copy link

I have the following defined in e.g. MyModule.jl:

function pathof_test()
    normpath(joinpath(@__FILE__, "..", "..", "test"))
end

macro testref(name)
    quote
        $(joinpath)(
            pathof_test(),
            "references",
            $(relpath)($(String(__source__.file)), pathof_test()),
            $(name)
        )
    end
end

Which means I can do

using ReferenceTests: @test_reference
using MyModule: @testref
@test_reference @testref("data.txt") [(1, 2), (3, 4)]

in a few different test files, and only have to worry about choosing a unique name per test file.

I'm just giving this a shot now and thought I'd mention it here.

@johnnychen94
Copy link
Member

Even though people use "test/references" as a convention to place the files, I don't really like to have this into the package -- people can just very easily create their own path generators without using macros at all.

refpath(filename) = joinpath(@__DIR__, "references", filename)

there's very little need to maintain a copy of such one-liners here and document it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants