From e9082b6c34976beddaf9dd57e72d1f89c826a97d Mon Sep 17 00:00:00 2001 From: Pratham Patel Date: Sun, 7 Dec 2025 12:29:03 +0530 Subject: [PATCH] nixosTests/cosmic: test more GUI packages A first party package (`cosmic-reader`) wasn't being tested up until now. This commit now tests if any changes in the DE itself (mainly the compositor) and/or the first party packages have an issue which can be easily caught by simple testing. --- nixos/tests/cosmic.nix | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/nixos/tests/cosmic.nix b/nixos/tests/cosmic.nix index d6b67c692d9d..0f244611af25 100644 --- a/nixos/tests/cosmic.nix +++ b/nixos/tests/cosmic.nix @@ -42,6 +42,8 @@ # infrastructure. jq lswt + + cosmic-reader ]; # So far, all COSMIC tests launch a few GUI applications. In doing @@ -64,6 +66,18 @@ DISPLAY = lib.strings.optionalString enableXWayland ( if enableAutologin then "DISPLAY=:0" else "DISPLAY=:1" ); + emptyPDF = config.node.pkgs.stdenvNoCC.mkDerivation { + name = "empty-pdf"; + dontUnpack = true; + nativeBuildInputs = [ config.node.pkgs.imagemagick ]; + buildPhase = '' + magick xc:none -page Letter empty.pdf + ''; + installPhase = '' + mkdir $out + mv empty.pdf $out/empty.pdf + ''; + }; in '' #testName: ${testName} @@ -107,6 +121,7 @@ gui_apps_to_launch['cosmic-edit'] = 'com.system76.CosmicEdit' gui_apps_to_launch['cosmic-files'] = 'com.system76.CosmicFiles' gui_apps_to_launch['cosmic-player'] = 'com.system76.CosmicPlayer' + gui_apps_to_launch['cosmic-reader'] = 'com.system76.CosmicReader' gui_apps_to_launch['cosmic-settings'] = 'com.system76.CosmicSettings' gui_apps_to_launch['cosmic-store'] = 'com.system76.CosmicStore' gui_apps_to_launch['cosmic-term'] = 'com.system76.CosmicTerm' @@ -114,10 +129,16 @@ for gui_app, app_id in gui_apps_to_launch.items(): # Don't fail the test if binary is absent if machine.execute(f"su - ${user.name} -c 'command -v {gui_app}'", timeout=5)[0] == 0: - machine.succeed(f"su - ${user.name} -c 'WAYLAND_DISPLAY=wayland-1 XDG_RUNTIME_DIR=/run/user/${toString user.uid} ${DISPLAY} {gui_app} >&2 &'", timeout=5) + match gui_app: + case 'cosmic-reader': + opt_arg = '${emptyPDF}/empty.pdf' + case _: + opt_arg = "" + + machine.succeed(f"su - ${user.name} -c 'WAYLAND_DISPLAY=wayland-1 XDG_RUNTIME_DIR=/run/user/${toString user.uid} ${DISPLAY} {gui_app} {opt_arg} >&2 &'", timeout=5) # Nix builds the following non-commented expression to the following: # `su - alice -c 'WAYLAND_DISPLAY=wayland-1 XDG_RUNTIME_DIR=/run/user/1000 lswt --json | jq ".toplevels" | grep "^ \\"app-id\\": \\"{app_id}\\"$"' ` - machine.wait_until_succeeds(f''''su - ${user.name} -c 'WAYLAND_DISPLAY=wayland-1 XDG_RUNTIME_DIR=/run/user/${toString user.uid} lswt --json | jq ".toplevels" | grep "^ \\"app-id\\": \\"{app_id}\\"$"' '''', timeout=30) + machine.wait_until_succeeds(f''''su - ${user.name} -c 'WAYLAND_DISPLAY=wayland-1 XDG_RUNTIME_DIR=/run/user/${toString user.uid} lswt --json | jq ".toplevels" | grep "^ \\"app-id\\": \\"{app_id}\\"$"' '''', timeout=60) machine.succeed(f"pkill {gui_app}", timeout=5) machine.succeed("echo 'test completed succeessfully' > /${testName}", timeout=5)