1# NixOS tests for gnome-desktop-testing-runner using software
2# See https://wiki.gnome.org/Initiatives/GnomeGoals/InstalledTests
3
4{ system ? builtins.currentSystem,
5 config ? {},
6 pkgs ? import ../../.. { inherit system config; }
7}:
8
9with import ../../lib/testing-python.nix { inherit system pkgs; };
10with pkgs.lib;
11
12let
13
14 callInstalledTest = pkgs.newScope { inherit makeInstalledTest; };
15
16 makeInstalledTest =
17 { # Package to test. Needs to have an installedTests output
18 tested
19
20 # Config to inject into machine
21 , testConfig ? {}
22
23 # Test script snippet to inject before gnome-desktop-testing-runner begins.
24 # This is useful for extra setup the environment may need before the runner begins.
25 , preTestScript ? ""
26
27 # Does test need X11?
28 , withX11 ? false
29
30 # Extra flags to pass to gnome-desktop-testing-runner.
31 , testRunnerFlags ? []
32
33 # Extra attributes to pass to makeTest.
34 # They will be recursively merged into the attrset created by this function.
35 , ...
36 }@args:
37 makeTest
38 (recursiveUpdate
39 rec {
40 name = tested.name;
41
42 meta = {
43 maintainers = tested.meta.maintainers or [];
44 };
45
46 nodes.machine = { ... }: {
47 imports = [
48 testConfig
49 ] ++ optional withX11 ../common/x11.nix;
50
51 environment.systemPackages = with pkgs; [ gnome-desktop-testing ];
52
53 # The installed tests need to be added to the test VM’s closure.
54 # Otherwise, their dependencies might not actually be registered
55 # as valid paths in the VM’s Nix store database,
56 # and `nix-store --query` commands run as part of the tests
57 # (for example when building Flatpak runtimes) will fail.
58 environment.variables.TESTED_PACKAGE_INSTALLED_TESTS = "${tested.installedTests}/share";
59 };
60
61 testScript =
62 optionalString withX11 ''
63 machine.wait_for_x()
64 '' +
65 optionalString (preTestScript != "") ''
66 ${preTestScript}
67 '' +
68 ''
69 machine.succeed(
70 "gnome-desktop-testing-runner ${escapeShellArgs testRunnerFlags} -d '${tested.installedTests}/share'"
71 )
72 '';
73 }
74
75 (removeAttrs args [
76 "tested"
77 "testConfig"
78 "preTestScript"
79 "withX11"
80 "testRunnerFlags"
81 ])
82 );
83
84in
85
86{
87 appstream = callInstalledTest ./appstream.nix {};
88 appstream-qt = callInstalledTest ./appstream-qt.nix {};
89 colord = callInstalledTest ./colord.nix {};
90 flatpak = callInstalledTest ./flatpak.nix {};
91 flatpak-builder = callInstalledTest ./flatpak-builder.nix {};
92 fwupd = callInstalledTest ./fwupd.nix {};
93 gcab = callInstalledTest ./gcab.nix {};
94 gdk-pixbuf = callInstalledTest ./gdk-pixbuf.nix {};
95 geocode-glib = callInstalledTest ./geocode-glib.nix {};
96 gjs = callInstalledTest ./gjs.nix {};
97 glib-networking = callInstalledTest ./glib-networking.nix {};
98 gnome-photos = callInstalledTest ./gnome-photos.nix {};
99 graphene = callInstalledTest ./graphene.nix {};
100 gsconnect = callInstalledTest ./gsconnect.nix {};
101 json-glib = callInstalledTest ./json-glib.nix {};
102 ibus = callInstalledTest ./ibus.nix {};
103 libgdata = callInstalledTest ./libgdata.nix {};
104 glib-testing = callInstalledTest ./glib-testing.nix {};
105 libjcat = callInstalledTest ./libjcat.nix {};
106 libxmlb = callInstalledTest ./libxmlb.nix {};
107 malcontent = callInstalledTest ./malcontent.nix {};
108 ostree = callInstalledTest ./ostree.nix {};
109 pipewire = callInstalledTest ./pipewire.nix {};
110 upower = callInstalledTest ./upower.nix {};
111 xdg-desktop-portal = callInstalledTest ./xdg-desktop-portal.nix {};
112}