As explained in Tests, for every program some simple tests are written to check the various independent features of the program. All the tests are placed in the tests/ directory. The tests/prepconf.sh script is the first ‘test’ that will be run. It will copy all the configuration files from the various directories to a tests/.gnuastro directory (which it will make) so the various tests can set the default values. This script will also make sure the programs don’t go searching for user and system wide configuration files to avoid the mixing of values with different Gnuastro version on the system.
For each program, the tests are placed inside directories with the
program name. Each test is written as a shell script. The last line of
this script is the test which runs the program with certain
parameters. The return value of this script determines the fate of the
test, see the “Support for test suites” chapter of the Automake
manual for a very nice and complete explanation. In every script, two
variables are defined at first:
first specifies the program name and the second the location of the
The most important thing to have in mind about all the test scripts is that they are run from inside the tests/ directory in the “build tree”. Which can be different from the directory they are stored in (known as the “source tree”)209. This distinction is made by GNU Autoconf and Automake (which configure, build and install Gnuastro) so that you can install the program even if you don’t have write access to the directory keeping the source files. See the “Parallel build trees (a.k.a VPATH builds)” in the Automake manual for a nice explanation.
Because of this, any necessary inputs that are distributed in the
tarball210, for example the
catalogs necessary for checks in MakeProfiles and Crop, must be identified
$topsrc prefix instead of
../ (for the top
source directory that is unpacked). This
$topsrc variable points
to the source tree where the script can find the source data (it is defined
in tests/Makefile.am). The executables and other test products were
built in the build tree (where they are being run), so they don’t need to
be prefixed with that variable. This is also true for images or files that
were produced by other tests.
The developer-build script also uses this feature to keep the source and build directories separate (see Separate build and source directories).
In many cases, the inputs of a test are outputs of previous tests, this doesn’t apply to this class of inputs. Because all outputs of previous tests are in the “build tree”.