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