|
Boost : |
Subject: Re: [boost] [test] [build] best practices for looking up data files from test executables
From: Robert Ramey (ramey_at_[hidden])
Date: 2017-11-13 20:54:11
On 11/13/17 12:31 PM, Stefan Seefeld via Boost wrote:
> Hi there,
>
> I'm trying to write a test that needs to access a data file. As I'm
> surely not the first wanting to use external data in my tests, I wonder
> whether there are established "best practices" or idioms when using
> Boost.Build and Boost.Test.
>
> My first attempt was to compute the relative path using the test
> source's `__FILE__`, until I realized the path was invalid due to the
> build logic moving executables before running them. Then I considered
> using a command-line option to point at the data directory, but that
> seems quite involved when using boost::test (and BOOST_TEST_MODULE)...
>
> Any suggestions for how to approach this ?
Hmm - I do this in serialization library. My believe is that the tests
are run while the current directory is set to the test directory. So if
you put a copy of your external data as file in your test directory, you
should be able to just open it without including any prefix.
Robert Ramey
>
> Thanks,
>
>
> Stefan
>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk