Testing using pre-existing input files

I wonder what the “standard” approach might be to the following problem:

A package has tests which refer to pre-existing input files in the package/test folder. When the package is tested within a different folder, the input files would not be found when the tests are run unless they were referred to with a full relative or absolute path. How would that be done?

Use @__DIR__ in the code to get the directory containing the source code file:

path_to_inputfile = joinpath(@__DIR__, "input.txt")
1 Like