summary refs log tree commit diff
path: root/nixos/tests/installed-tests
diff options
context:
space:
mode:
authorJan Tojnar <jtojnar@gmail.com>2020-07-24 15:17:42 +0200
committerJan Tojnar <jtojnar@gmail.com>2020-07-24 16:30:49 +0200
commit2bfa6aa848a89e4ba8308128801812e5018dcd44 (patch)
tree1751949b3d5659a4f54da8b4ef55a4b718253cc0 /nixos/tests/installed-tests
parent5717d9d2f7ca0662291910c52f1d7b95b568fec2 (diff)
downloadnixpkgs-2bfa6aa848a89e4ba8308128801812e5018dcd44.tar
nixpkgs-2bfa6aa848a89e4ba8308128801812e5018dcd44.tar.gz
nixpkgs-2bfa6aa848a89e4ba8308128801812e5018dcd44.tar.bz2
nixpkgs-2bfa6aa848a89e4ba8308128801812e5018dcd44.tar.lz
nixpkgs-2bfa6aa848a89e4ba8308128801812e5018dcd44.tar.xz
nixpkgs-2bfa6aa848a89e4ba8308128801812e5018dcd44.tar.zst
nixpkgs-2bfa6aa848a89e4ba8308128801812e5018dcd44.zip
nixosTests.installed-tests: Add the test data to VM closure
Flatpak’s installed tests build Flatpak runtimes, among other things.
Upstream code does this by copying some programs on `PATH`
as well as some possible dependencies from host’s /usr.
We patch the code to use `nix-store --query --requisites`
to make the dependency discovery easier.

The Flatpak’s installed tests add `socat` to `PATH` and later run
`nix-store --query --requisites` on its location but it was failing with

    error: path '/nix/store/qcyf7nq5vvfw32967sv4j6z190inrbrc-socat-1.7.3.4' is not valid

The issue occurred because, while the host Nix store is bind mounted into the test VM,
the VM’s store uses its own database that only contains the packages in the VM’s closure.
Since the test commands are not actually part of the VM but only passed through PTY,
the `flatpak.installedTests` derivation was not part of the VM’s closure, so `nix-store`
in the VM could not get information about its dependency `socat`.

Let’s make the `installedTests` of the tested package part of the test VM’s closure
by passing it as a global environment variable. This will also have the added benefit
that user no longer has to type the path when running the installed tests manually in the VM;
they can just use `gnome-desktop-testing-runner -d $TESTED_PACKAGE_INSTALLED_TESTS`,
which is much more conducive to tab completion.
Diffstat (limited to 'nixos/tests/installed-tests')
-rw-r--r--nixos/tests/installed-tests/default.nix6
1 files changed, 6 insertions, 0 deletions
diff --git a/nixos/tests/installed-tests/default.nix b/nixos/tests/installed-tests/default.nix
index b6bdfea2277..889a00d4b56 100644
--- a/nixos/tests/installed-tests/default.nix
+++ b/nixos/tests/installed-tests/default.nix
@@ -50,6 +50,12 @@ let
 
             environment.systemPackages = with pkgs; [ gnome-desktop-testing ];
 
+            # The installed tests need to be added to the test VM’s closure.
+            # Otherwise, their dependencies might not actually be registered
+            # as valid paths in the VM’s Nix store database,
+            # and `nix-store --query` commands run as part of the tests
+            # (for example when building Flatpak runtimes) will fail.
+            environment.variables.TESTED_PACKAGE_INSTALLED_TESTS = "${tested.installedTests}/share";
           };
 
           testScript =