forked from mirrors/nixpkgs
2bfa6aa848
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.
106 lines
3.3 KiB
Nix
106 lines
3.3 KiB
Nix
# NixOS tests for gnome-desktop-testing-runner using software
|
||
# See https://wiki.gnome.org/Initiatives/GnomeGoals/InstalledTests
|
||
|
||
{ system ? builtins.currentSystem,
|
||
config ? {},
|
||
pkgs ? import ../../.. { inherit system config; }
|
||
}:
|
||
|
||
with import ../../lib/testing-python.nix { inherit system pkgs; };
|
||
with pkgs.lib;
|
||
|
||
let
|
||
|
||
callInstalledTest = pkgs.newScope { inherit makeInstalledTest; };
|
||
|
||
makeInstalledTest =
|
||
{ # Package to test. Needs to have an installedTests output
|
||
tested
|
||
|
||
# Config to inject into machine
|
||
, testConfig ? {}
|
||
|
||
# Test script snippet to inject before gnome-desktop-testing-runner begins.
|
||
# This is useful for extra setup the environment may need before the runner begins.
|
||
, preTestScript ? ""
|
||
|
||
# Does test need X11?
|
||
, withX11 ? false
|
||
|
||
# Extra flags to pass to gnome-desktop-testing-runner.
|
||
, testRunnerFlags ? ""
|
||
|
||
# Extra attributes to pass to makeTest.
|
||
# They will be recursively merged into the attrset created by this function.
|
||
, ...
|
||
}@args:
|
||
makeTest
|
||
(recursiveUpdate
|
||
rec {
|
||
name = tested.name;
|
||
|
||
meta = {
|
||
maintainers = tested.meta.maintainers;
|
||
};
|
||
|
||
machine = { ... }: {
|
||
imports = [
|
||
testConfig
|
||
] ++ optional withX11 ../common/x11.nix;
|
||
|
||
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 =
|
||
optionalString withX11 ''
|
||
machine.wait_for_x()
|
||
'' +
|
||
optionalString (preTestScript != "") ''
|
||
${preTestScript}
|
||
'' +
|
||
''
|
||
machine.succeed(
|
||
"gnome-desktop-testing-runner ${testRunnerFlags} -d '${tested.installedTests}/share'"
|
||
)
|
||
'';
|
||
}
|
||
|
||
(removeAttrs args [
|
||
"tested"
|
||
"testConfig"
|
||
"preTestScript"
|
||
"withX11"
|
||
"testRunnerFlags"
|
||
])
|
||
);
|
||
|
||
in
|
||
|
||
{
|
||
colord = callInstalledTest ./colord.nix {};
|
||
flatpak = callInstalledTest ./flatpak.nix {};
|
||
flatpak-builder = callInstalledTest ./flatpak-builder.nix {};
|
||
fwupd = callInstalledTest ./fwupd.nix {};
|
||
gcab = callInstalledTest ./gcab.nix {};
|
||
gdk-pixbuf = callInstalledTest ./gdk-pixbuf.nix {};
|
||
gjs = callInstalledTest ./gjs.nix {};
|
||
glib-networking = callInstalledTest ./glib-networking.nix {};
|
||
gnome-photos = callInstalledTest ./gnome-photos.nix {};
|
||
graphene = callInstalledTest ./graphene.nix {};
|
||
ibus = callInstalledTest ./ibus.nix {};
|
||
libgdata = callInstalledTest ./libgdata.nix {};
|
||
glib-testing = callInstalledTest ./glib-testing.nix {};
|
||
libjcat = callInstalledTest ./libjcat.nix {};
|
||
libxmlb = callInstalledTest ./libxmlb.nix {};
|
||
malcontent = callInstalledTest ./malcontent.nix {};
|
||
ostree = callInstalledTest ./ostree.nix {};
|
||
xdg-desktop-portal = callInstalledTest ./xdg-desktop-portal.nix {};
|
||
}
|