nixosTests.ydotool.{customGroup,headless,wayland,x11}: handleTest -> runTest

This commit is contained in:
Sizhe Zhao 2025-07-09 10:29:57 +08:00
parent 7b09056b8f
commit 1889fc8f2f
No known key found for this signature in database
GPG Key ID: ED1807251A7DA08F
2 changed files with 149 additions and 134 deletions

View File

@ -1555,7 +1555,10 @@ in
xterm = runTest ./xterm.nix;
xxh = runTest ./xxh.nix;
yarr = runTest ./yarr.nix;
ydotool = handleTest ./ydotool.nix { };
ydotool = import ./ydotool.nix {
inherit (pkgs) lib;
inherit runTest;
};
yggdrasil = runTest ./yggdrasil.nix;
your_spotify = runTest ./your_spotify.nix;
zammad = runTest ./zammad.nix;

View File

@ -1,14 +1,10 @@
{
system ? builtins.currentSystem,
config ? { },
pkgs ? import ../.. { inherit system config; },
lib ? pkgs.lib,
}:
{ runTest, lib }:
let
makeTest = import ./make-test-python.nix;
textInput = "This works.";
inputBoxText = "Enter input";
inputBox = pkgs.writeShellScript "zenity-input" ''
inputBox =
pkgs:
pkgs.writeShellScript "zenity-input" ''
${lib.getExe pkgs.zenity} --entry --text '${inputBoxText}:' > /tmp/output &
'';
asUser = ''
@ -20,7 +16,9 @@ let
'';
in
{
headless = makeTest {
headless = runTest (
{ lib, ... }:
{
name = "headless";
enableOCR = true;
@ -53,14 +51,19 @@ in
OPNA2608
quantenzitrone
];
};
}
);
x11 = makeTest {
x11 = runTest (
{ config, lib, ... }:
{
name = "x11";
enableOCR = true;
nodes.machine = {
nodes.machine =
{ lib, ... }:
{
imports = [
./common/user-account.nix
./common/auto.nix
@ -86,7 +89,7 @@ in
start_all()
machine.wait_for_x()
machine.execute(as_user("${inputBox}"))
machine.execute(as_user("${inputBox config.node.pkgs}"))
machine.wait_for_text("${inputBoxText}")
machine.succeed(as_user("ydotool type '${textInput}'")) # text input
machine.screenshot("x11_input")
@ -100,14 +103,19 @@ in
OPNA2608
quantenzitrone
];
};
}
);
wayland = makeTest {
wayland = runTest (
{ lib, ... }:
{
name = "wayland";
enableOCR = true;
nodes.machine = {
nodes.machine =
{ pkgs, ... }:
{
imports = [ ./common/user-account.nix ];
services.cage = {
@ -117,7 +125,7 @@ in
programs.ydotool.enable = true;
services.cage.program = inputBox;
services.cage.program = inputBox pkgs;
};
testScript = ''
@ -137,7 +145,8 @@ in
OPNA2608
quantenzitrone
];
};
}
);
customGroup =
let
@ -147,7 +156,9 @@ in
outsideGroupUsername = "other-user";
groupName = "custom-group";
in
makeTest {
runTest (
{ lib, ... }:
{
inherit name;
nodes."${nodeName}" = {
@ -180,5 +191,6 @@ in
'';
meta.maintainers = with lib.maintainers; [ l0b0 ];
};
}
);
}