nixos/tests: add gnome-installed-tests with builder function
The test script is also ported to python.
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
{ pkgs, makeInstalledTest, ... }:
|
||||
|
||||
makeInstalledTest {
|
||||
tested = pkgs.colord;
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
# 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 ? ""
|
||||
}:
|
||||
makeTest rec {
|
||||
name = tested.name;
|
||||
|
||||
meta = {
|
||||
maintainers = tested.meta.maintainers;
|
||||
};
|
||||
|
||||
machine = { ... }: {
|
||||
imports = [
|
||||
testConfig
|
||||
] ++ optional withX11 ../common/x11.nix;
|
||||
|
||||
environment.systemPackages = with pkgs; [ gnome-desktop-testing ];
|
||||
|
||||
};
|
||||
|
||||
testScript =
|
||||
optionalString withX11 ''
|
||||
machine.wait_for_x()
|
||||
'' +
|
||||
optionalString (preTestScript != "") ''
|
||||
${preTestScript}
|
||||
'' +
|
||||
''
|
||||
machine.succeed(
|
||||
"gnome-desktop-testing-runner ${testRunnerFlags} -d '${tested.installedTests}/share'"
|
||||
)
|
||||
'';
|
||||
};
|
||||
|
||||
in
|
||||
|
||||
{
|
||||
colord = callInstalledTest ./colord.nix {};
|
||||
flatpak = callInstalledTest ./flatpak.nix {};
|
||||
flatpak-builder = callInstalledTest ./flatpak-builder.nix {};
|
||||
fwupd = callInstalledTest ./fwupd.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 {};
|
||||
ostree = callInstalledTest ./ostree.nix {};
|
||||
xdg-desktop-portal = callInstalledTest ./xdg-desktop-portal.nix {};
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
{ pkgs, makeInstalledTest, ... }:
|
||||
|
||||
makeInstalledTest {
|
||||
tested = pkgs.flatpak-builder;
|
||||
|
||||
testConfig = {
|
||||
services.flatpak.enable = true;
|
||||
xdg.portal.enable = true;
|
||||
environment.systemPackages = with pkgs; [ flatpak-builder ] ++ flatpak-builder.installedTestsDependencies;
|
||||
virtualisation.diskSize = 2048;
|
||||
};
|
||||
|
||||
testRunnerFlags = "--timeout 3600";
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
{ pkgs, makeInstalledTest, ... }:
|
||||
|
||||
makeInstalledTest {
|
||||
tested = pkgs.flatpak;
|
||||
withX11 = true;
|
||||
|
||||
testConfig = {
|
||||
services.xserver.desktopManager.gnome3.enable = true; # TODO: figure out minimal environment where the tests work
|
||||
# common/x11.nix enables the auto display manager (lightdm)
|
||||
services.xserver.displayManager.gdm.enable = false;
|
||||
environment.gnome3.excludePackages = pkgs.gnome3.optionalPackages;
|
||||
services.flatpak.enable = true;
|
||||
environment.systemPackages = with pkgs; [ gnupg ostree python2 ];
|
||||
virtualisation.memorySize = 2047;
|
||||
virtualisation.diskSize = 1024;
|
||||
};
|
||||
|
||||
testRunnerFlags = "--timeout 3600";
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
{ pkgs, makeInstalledTest, ... }:
|
||||
|
||||
makeInstalledTest {
|
||||
tested = pkgs.fwupd;
|
||||
|
||||
testConfig = {
|
||||
services.fwupd.enable = true;
|
||||
services.fwupd.blacklistPlugins = []; # don't blacklist test plugin
|
||||
services.fwupd.enableTestRemote = true;
|
||||
virtualisation.memorySize = 768;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
{ pkgs, makeInstalledTest, ... }:
|
||||
|
||||
makeInstalledTest {
|
||||
tested = pkgs.gdk-pixbuf;
|
||||
|
||||
testConfig = {
|
||||
# Tests allocate a lot of memory trying to exploit a CVE
|
||||
# but qemu-system-i386 has a 2047M memory limit
|
||||
virtualisation.memorySize = if pkgs.stdenv.isi686 then 2047 else 4096;
|
||||
};
|
||||
|
||||
testRunnerFlags = "--timeout 1800";
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{ pkgs, makeInstalledTest, ... }:
|
||||
|
||||
makeInstalledTest {
|
||||
tested = pkgs.gjs;
|
||||
withX11 = true;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{ pkgs, makeInstalledTest, ... }:
|
||||
|
||||
makeInstalledTest {
|
||||
tested = pkgs.glib-networking;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
{ pkgs, makeInstalledTest, ... }:
|
||||
|
||||
makeInstalledTest {
|
||||
tested = pkgs.gnome-photos;
|
||||
|
||||
withX11 = true;
|
||||
|
||||
testConfig = {
|
||||
programs.dconf.enable = true;
|
||||
services.gnome3.at-spi2-core.enable = true; # needed for dogtail
|
||||
environment.systemPackages = with pkgs; [
|
||||
# gsettings tool with access to gsettings-desktop-schemas
|
||||
(stdenv.mkDerivation {
|
||||
name = "desktop-gsettings";
|
||||
dontUnpack = true;
|
||||
nativeBuildInputs = [ glib wrapGAppsHook ];
|
||||
buildInputs = [ gsettings-desktop-schemas ];
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
mkdir -p $out/bin
|
||||
ln -s ${glib.bin}/bin/gsettings $out/bin/desktop-gsettings
|
||||
runHook postInstall
|
||||
'';
|
||||
})
|
||||
];
|
||||
services.dbus.packages = with pkgs; [ gnome-photos ];
|
||||
};
|
||||
|
||||
preTestScript = ''
|
||||
# dogtail needs accessibility enabled
|
||||
machine.succeed(
|
||||
"desktop-gsettings set org.gnome.desktop.interface toolkit-accessibility true 2>&1"
|
||||
)
|
||||
'';
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{ pkgs, makeInstalledTest, ... }:
|
||||
|
||||
makeInstalledTest {
|
||||
tested = pkgs.graphene;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
{ pkgs, lib, makeInstalledTest, ... }:
|
||||
|
||||
makeInstalledTest {
|
||||
tested = pkgs.ostree;
|
||||
|
||||
# TODO: Wrap/patch the tests directly in the package
|
||||
testConfig = {
|
||||
environment.systemPackages = with pkgs; [
|
||||
(python3.withPackages (p: with p; [ pyyaml ]))
|
||||
gnupg
|
||||
ostree
|
||||
];
|
||||
|
||||
# for GJS tests
|
||||
environment.variables.GI_TYPELIB_PATH = lib.makeSearchPath "lib/girepository-1.0" (with pkgs; [
|
||||
gtk3
|
||||
pango.out
|
||||
ostree
|
||||
gdk-pixbuf
|
||||
atk
|
||||
]);
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{ pkgs, makeInstalledTest, ... }:
|
||||
|
||||
makeInstalledTest {
|
||||
tested = pkgs.xdg-desktop-portal;
|
||||
}
|
||||
Reference in New Issue
Block a user