aboutsummaryrefslogtreecommitdiff
path: root/tests/functional
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 /tests/functional
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 'tests/functional')
-rw-r--r--tests/functional/ca/meson.build6
-rw-r--r--tests/functional/common/meson.build6
-rw-r--r--tests/functional/dyn-drv/meson.build6
-rw-r--r--tests/functional/meson.build180
4 files changed, 198 insertions, 0 deletions
diff --git a/tests/functional/ca/meson.build b/tests/functional/ca/meson.build
new file mode 100644
index 000000000..f3f4a3b2b
--- /dev/null
+++ b/tests/functional/ca/meson.build
@@ -0,0 +1,6 @@
+# test_confdata set from tests/functional/meson.build
+configure_file(
+ input : 'config.nix.in',
+ output : 'config.nix',
+ configuration : test_confdata,
+)
diff --git a/tests/functional/common/meson.build b/tests/functional/common/meson.build
new file mode 100644
index 000000000..74a8986e9
--- /dev/null
+++ b/tests/functional/common/meson.build
@@ -0,0 +1,6 @@
+# test_confdata set from tests/functional/meson.build
+vars_and_functions = configure_file(
+ input : 'vars-and-functions.sh.in',
+ output : 'vars-and-functions.sh',
+ configuration : test_confdata,
+)
diff --git a/tests/functional/dyn-drv/meson.build b/tests/functional/dyn-drv/meson.build
new file mode 100644
index 000000000..f3f4a3b2b
--- /dev/null
+++ b/tests/functional/dyn-drv/meson.build
@@ -0,0 +1,6 @@
+# test_confdata set from tests/functional/meson.build
+configure_file(
+ input : 'config.nix.in',
+ output : 'config.nix',
+ configuration : test_confdata,
+)
diff --git a/tests/functional/meson.build b/tests/functional/meson.build
new file mode 100644
index 000000000..53dc21af5
--- /dev/null
+++ b/tests/functional/meson.build
@@ -0,0 +1,180 @@
+test_confdata = {
+ 'bindir': bindir,
+ 'coreutils': fs.parent(coreutils.full_path()),
+ 'lsof': lsof.full_path(),
+ 'dot': dot.found() ? dot.full_path() : '',
+ 'bash': bash.full_path(),
+ 'sandbox_shell': busybox.found() ? busybox.full_path() : '',
+ 'PACKAGE_VERSION': meson.project_version(),
+ 'system': host_system,
+ 'BUILD_SHARED_LIBS': '1', # XXX(Qyriad): detect this!
+}
+
+# Just configures `common/vars-and-functions.sh.in`.
+# Done as a subdir() so Meson places it under `common` in the build directory as well.
+subdir('common')
+
+config_nix_in = configure_file(
+ input : 'config.nix.in',
+ output : 'config.nix',
+ configuration : test_confdata,
+)
+
+# Just configures `ca/config.nix.in`. Done as a subdir() for the same reason as above.
+subdir('ca')
+# Just configures `dyn-drv/config.nix.in`. Same as above.
+subdir('dyn-drv')
+
+functional_tests_scripts = [
+ 'init.sh',
+ 'test-infra.sh',
+ 'flakes/flakes.sh',
+ 'flakes/develop.sh',
+ 'flakes/develop-r8854.sh',
+ 'flakes/run.sh',
+ 'flakes/mercurial.sh',
+ 'flakes/circular.sh',
+ 'flakes/init.sh',
+ 'flakes/inputs.sh',
+ 'flakes/follow-paths.sh',
+ 'flakes/bundle.sh',
+ 'flakes/check.sh',
+ 'flakes/unlocked-override.sh',
+ 'flakes/absolute-paths.sh',
+ 'flakes/build-paths.sh',
+ 'flakes/flake-in-submodule.sh',
+ 'gc.sh',
+ 'nix-collect-garbage-d.sh',
+ 'remote-store.sh',
+ 'legacy-ssh-store.sh',
+ 'lang.sh',
+ 'lang-test-infra.sh',
+ 'experimental-features.sh',
+ 'fetchMercurial.sh',
+ 'gc-auto.sh',
+ 'user-envs.sh',
+ 'user-envs-migration.sh',
+ 'binary-cache.sh',
+ 'multiple-outputs.sh',
+ 'nix-build.sh',
+ 'gc-concurrent.sh',
+ 'repair.sh',
+ 'fixed.sh',
+ 'export-graph.sh',
+ 'timeout.sh',
+ 'fetchGitRefs.sh',
+ 'gc-runtime.sh',
+ 'tarball.sh',
+ 'fetchGit.sh',
+ 'fetchurl.sh',
+ 'fetchPath.sh',
+ 'fetchTree-file.sh',
+ 'simple.sh',
+ 'referrers.sh',
+ 'optimise-store.sh',
+ 'substitute-with-invalid-ca.sh',
+ 'signing.sh',
+ 'hash.sh',
+ 'gc-non-blocking.sh',
+ 'check.sh',
+ 'nix-shell.sh',
+ 'check-refs.sh',
+ 'build-remote-input-addressed.sh',
+ 'secure-drv-outputs.sh',
+ 'restricted.sh',
+ 'fetchGitSubmodules.sh',
+ 'flakes/search-root.sh',
+ 'readfile-context.sh',
+ 'nix-channel.sh',
+ 'recursive.sh',
+ 'dependencies.sh',
+ 'check-reqs.sh',
+ 'build-remote-content-addressed-fixed.sh',
+ 'build-remote-content-addressed-floating.sh',
+ 'build-remote-trustless-should-pass-0.sh',
+ 'build-remote-trustless-should-pass-1.sh',
+ 'build-remote-trustless-should-pass-2.sh',
+ 'build-remote-trustless-should-pass-3.sh',
+ 'build-remote-trustless-should-fail-0.sh',
+ 'nar-access.sh',
+ 'impure-eval.sh',
+ 'pure-eval.sh',
+ 'eval.sh',
+ 'repl.sh',
+ 'binary-cache-build-remote.sh',
+ 'search.sh',
+ 'logging.sh',
+ 'export.sh',
+ 'config.sh',
+ 'add.sh',
+ 'local-store.sh',
+ 'filter-source.sh',
+ 'misc.sh',
+ 'dump-db.sh',
+ 'linux-sandbox.sh',
+ 'supplementary-groups.sh',
+ 'build-dry.sh',
+ 'structured-attrs.sh',
+ 'shell.sh',
+ 'brotli.sh',
+ 'zstd.sh',
+ 'compression-levels.sh',
+ 'nix-copy-ssh.sh',
+ 'nix-copy-ssh-ng.sh',
+ 'post-hook.sh',
+ 'function-trace.sh',
+ 'flakes/config.sh',
+ 'fmt.sh',
+ 'eval-store.sh',
+ 'why-depends.sh',
+ 'derivation-json.sh',
+ 'import-derivation.sh',
+ 'nix_path.sh',
+ 'case-hack.sh',
+ 'placeholders.sh',
+ 'ssh-relay.sh',
+ 'build.sh',
+ 'build-delete.sh',
+ 'output-normalization.sh',
+ 'selfref-gc.sh',
+ 'db-migration.sh',
+ 'bash-profile.sh',
+ 'pass-as-file.sh',
+ 'nix-profile.sh',
+ 'suggestions.sh',
+ 'store-ping.sh',
+ 'fetchClosure.sh',
+ 'completions.sh',
+ 'flakes/show.sh',
+ 'impure-derivations.sh',
+ 'path-from-hash-part.sh',
+ 'toString-path.sh',
+ 'read-only-store.sh',
+ 'nested-sandboxing.sh',
+ 'debugger.sh',
+]
+
+# TODO(Qyriad): this will hopefully be able to be removed when we remove the autoconf+Make
+# buildsystem. See the comments at the top of setup-functional-tests.py for why this is here.
+meson.add_install_script(
+ python,
+ meson.project_source_root() / 'meson/setup-functional-tests.py',
+)
+
+foreach script : functional_tests_scripts
+ # Turns, e.g., `tests/functional/flakes/show.sh` into a Meson test target called
+ # `functional-flakes-show`.
+ name = 'functional-@0@'.format(fs.replace_suffix(script, '')).replace('/', '-')
+ test(
+ name,
+ python,
+ args: [
+ meson.project_source_root() / 'meson/run-test.py',
+ script,
+ ],
+ suite : 'installcheck',
+ env : {
+ 'MESON_BUILD_ROOT': meson.project_build_root(),
+ },
+ )
+endforeach