aboutsummaryrefslogtreecommitdiff
path: root/meson.build
diff options
context:
space:
mode:
authorQyriad <qyriad@qyriad.me>2024-03-25 12:12:56 -0600
committerQyriad <qyriad@qyriad.me>2024-03-27 18:37:50 -0600
commit038daad2182a22c81861ee7cbb5f0c85f6bb16ba (patch)
tree653f303e26bd99106a4d39d5cb9f880d4ba0a0a3 /meson.build
parentedba570664b952facde43fd0414e60f0a42851da (diff)
meson: implement functional tests
Functional tests can be run with `meson test -C build --suite installcheck`. Notably, functional tests must be run *after* running `meson install` (Lix's derivation runs the installcheck suite in installCheckPhase so it does this correctly), due to some quirks between Meson and the testing system. As far as I can tell the functional tests are meant to be run after installing anyway, but unfortunately I can't transparently make `meson test --suite installcheck` depend on the install targets. The script that runs the functional tests, meson/run-test.py, checks that `meson install` has happened and fails fast with a (hopefully) helpful error message if any of the functional tests are run before installing. TODO: this change needs reflection in developer documentation Change-Id: I8dcb5fdfc0b6cb17580973d24ad930abd57018f6
Diffstat (limited to 'meson.build')
-rw-r--r--meson.build23
1 files changed, 23 insertions, 0 deletions
diff --git a/meson.build b/meson.build
index 0a6a6b4b1..e58ea06d9 100644
--- a/meson.build
+++ b/meson.build
@@ -18,6 +18,12 @@
# Finally, src/nix/meson.build defines the Nix command itself, relying on all prior meson files.
#
# Unit tests are setup in tests/unit/meson.build, under the test suite "check".
+#
+# Functional tests are a bit more complicated. Generally they're defined in
+# tests/functional/meson.build, and rely on helper scripts meson/setup-functional-tests.py
+# and meson/run-test.py. Scattered around also are configure_file() invocations, which must
+# be placed in specific directories' meson.build files to create the right directory tree
+# in the build directory.
project('lix', 'cpp',
version : run_command('bash', '-c', 'echo -n $(cat ./.version)$VERSION_SUFFIX', check : true).stdout().strip(),
@@ -27,6 +33,7 @@ project('lix', 'cpp',
'warning_level=1',
'debug=true',
'optimization=2',
+ 'errorlogs=true', # Please print logs for tests that fail
],
)
@@ -48,6 +55,11 @@ path_opts = [
'state-dir',
'log-dir',
]
+# For your grepping pleasure, this loop sets the following variables that aren't mentioned
+# literally above:
+# store_dir
+# state_dir
+# log_dir
foreach optname : path_opts
varname = optname.replace('-', '_')
path = get_option(optname)
@@ -203,6 +215,10 @@ deps += gtest
# Build-time tools
#
bash = find_program('bash')
+coreutils = find_program('coreutils')
+dot = find_program('dot', required : false)
+pymod = import('python')
+python = pymod.find_installation('python3')
# Used to workaround https://github.com/mesonbuild/meson/issues/2320 in src/nix/meson.build.
installcmd = find_program('install')
@@ -316,6 +332,13 @@ if get_option('profile-build').require(meson.get_compiler('cpp').get_id() == 'cl
endif
subdir('src')
+
if enable_tests
+ # Just configures `scripts/nix-profile.sh.in` (and copies the original to the build directory).
+ # Done as a subdirectory to convince Meson to put the configured files
+ # in `build/scripts` instead of just `build`.
+ subdir('scripts')
+
subdir('tests/unit')
+ subdir('tests/functional')
endif