Re: Re: Updating dpkg-buildflags to enable reproducible=+fixfilepath by default
On Mon, 11 Jan 2021 at 00:48:42 +1100, Stuart Prescott wrote:
> Looking to the future, tests using SOURCE_BASE_DIR to locate test data would
> allow build-time tests to be repurposed as autopkgtest tests too, as the
> autopkgtest could tell the tests where the test input data is to be found.
Prior art that would be worth looking at: GLib's test infrastructure uses
$G_TEST_SRCDIR and $G_TEST_BUILDDIR. These are usually used via a function
g_test_build_filename() whose first argument is a constant (enum value),
either G_TEST_DIST or G_TEST_BUILT, indicating whether the test data is
found in the source directory or the build directory.
If $G_TEST_SRCDIR and $G_TEST_BUILDDIR aren't set, g_test_build_filename()
defaults both to the directory where the currently-running test executable
was found (by looking at argv, /proc/self/exe or similar), which is
enough to make it unnecessary to set those variables for autopkgtests
in at least some cases.
If you intend to propose this as a feature in Qt or other libraries,
it's probably best to distinguish between the equivalent of G_TEST_SRCDIR
and the equivalent of G_TEST_BUILDDIR, so that tests in srcdir != builddir
builds can use test data and helper scripts that are distributed in
git/tarballs (GLib code would use G_TEST_DIST), and also use test data
and helper executables that are generated by the build (GLib code would
$G_TEST_SRCDIR and $G_TEST_BUILDDIR are usually defined in terms of the
directory containing the test (so typically you'd have something like
G_TEST_BUILDDIR=$HOME/src/glib/_build/gobject/tests for tests in the
gobject/tests subdirectory of a srcdir != builddir build), but it
would also be reasonable to have a pair of variables that is defined in
terms of the root directory, like the abs_top_srcdir=$HOME/src/glib and
abs_top_builddir=$HOME/src/glib/_build defined by Autotools.
In the non-GLib world, dbus has a similar setup, although instead of
separating the two sets of test data, it copies test files from the
equivalent of $G_TEST_SRCDIR into the equivalent of $G_TEST_BUILDDIR,
so that the tests can look in one location for everything.