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 ] 54 ++ optional withX11 ../common/x11.nix; 55 56 environment.systemPackages = with pkgs; [ gnome-desktop-testing ]; 57 58 # The installed tests need to be added to the test VM’s closure. 59 # Otherwise, their dependencies might not actually be registered 60 # as valid paths in the VM’s Nix store database, 61 # and `nix-store --query` commands run as part of the tests 62 # (for example when building Flatpak runtimes) will fail. 63 environment.variables.TESTED_PACKAGE_INSTALLED_TESTS = "${tested.installedTests}/share"; 64 }; 65 66 testScript = 67 optionalString withX11 '' 68 machine.wait_for_x() 69 '' 70 + optionalString (preTestScript != "") '' 71 ${preTestScript} 72 '' 73 + '' 74 machine.succeed( 75 "gnome-desktop-testing-runner ${escapeShellArgs testRunnerFlags} -d '${tested.installedTests}/share'" 76 ) 77 ''; 78 } 79 80 ( 81 removeAttrs args [ 82 "tested" 83 "testConfig" 84 "preTestScript" 85 "withX11" 86 "testRunnerFlags" 87 ] 88 ) 89 ); 90 91in 92 93{ 94 appstream = callInstalledTest ./appstream.nix { }; 95 appstream-qt = callInstalledTest ./appstream-qt.nix { }; 96 colord = callInstalledTest ./colord.nix { }; 97 flatpak = callInstalledTest ./flatpak.nix { }; 98 flatpak-builder = callInstalledTest ./flatpak-builder.nix { }; 99 fwupd = callInstalledTest ./fwupd.nix { }; 100 gcab = callInstalledTest ./gcab.nix { }; 101 gdk-pixbuf = callInstalledTest ./gdk-pixbuf.nix { }; 102 geocode-glib = callInstalledTest ./geocode-glib.nix { }; 103 gjs = callInstalledTest ./gjs.nix { }; 104 glib-networking = callInstalledTest ./glib-networking.nix { }; 105 gnome-photos = callInstalledTest ./gnome-photos.nix { }; 106 graphene = callInstalledTest ./graphene.nix { }; 107 gsconnect = callInstalledTest ./gsconnect.nix { }; 108 json-glib = callInstalledTest ./json-glib.nix { }; 109 ibus = callInstalledTest ./ibus.nix { }; 110 libgdata = callInstalledTest ./libgdata.nix { }; 111 glib-testing = callInstalledTest ./glib-testing.nix { }; 112 libjcat = callInstalledTest ./libjcat.nix { }; 113 libxmlb = callInstalledTest ./libxmlb.nix { }; 114 malcontent = callInstalledTest ./malcontent.nix { }; 115 ostree = callInstalledTest ./ostree.nix { }; 116 pipewire = callInstalledTest ./pipewire.nix { }; 117 upower = callInstalledTest ./upower.nix { }; 118 xdg-desktop-portal = callInstalledTest ./xdg-desktop-portal.nix { }; 119}