blob: 1ee8f42e69e59a4cadf1f8ba00f6f25534850241 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
{ pkgs, lib, ... }:
{
name = "miracle-wm";
meta = {
maintainers = with lib.maintainers; [ OPNA2608 ];
};
nodes.machine =
{ config, ... }:
{
imports = [
./common/auto.nix
./common/user-account.nix
];
# Seems to very rarely get interrupted by oom-killer
virtualisation.memorySize = 2047;
test-support.displayManager.auto = {
enable = true;
user = "alice";
};
programs.ydotool.enable = true;
services.xserver.enable = true;
services.displayManager.defaultSession = lib.mkForce "miracle-wm";
programs.wayland.miracle-wm.enable = true;
# To ensure a specific config for the tests
systemd.tmpfiles.rules =
let
testConfig = (pkgs.formats.yaml { }).generate "miracle-wm.yaml" {
terminal = "env WINIT_UNIX_BACKEND=x11 WAYLAND_DISPLAY= alacritty";
startup_apps = [
{
command = "foot";
restart_on_death = false;
}
];
};
in
[
"d ${config.users.users.alice.home}/.config 0700 alice users - -"
"L ${config.users.users.alice.home}/.config/miracle-wm.yaml - - - - ${testConfig}"
];
environment = {
shellAliases = {
test-wayland = "wayland-info | tee /tmp/test-wayland.out && touch /tmp/test-wayland-exit-ok";
test-x11 = "glinfo | tee /tmp/test-x11.out && touch /tmp/test-x11-exit-ok";
};
systemPackages = with pkgs; [
mesa-demos
wayland-utils
foot
alacritty
];
# To help with OCR
etc."xdg/foot/foot.ini".source = (pkgs.formats.ini { }).generate "foot.ini" {
main = {
font = "inconsolata:size=16";
};
colors = rec {
foreground = "000000";
background = "ffffff";
regular2 = foreground;
};
};
etc."xdg/alacritty/alacritty.toml".source = (pkgs.formats.toml { }).generate "alacritty.toml" {
font = rec {
normal.family = "Inconsolata";
bold.family = normal.family;
italic.family = normal.family;
bold_italic.family = normal.family;
size = 16;
};
colors = rec {
primary = {
foreground = "0x000000";
background = "0xffffff";
};
normal = {
green = primary.foreground;
};
};
};
};
fonts.packages = [ pkgs.inconsolata ];
};
enableOCR = true;
testScript =
{ ... }:
''
start_all()
machine.wait_for_unit("multi-user.target")
# Wait for Miriway to complete startup
machine.wait_for_file("/run/user/1000/wayland-0")
machine.succeed("pgrep miracle-wm")
machine.screenshot("miracle-wm_launched")
# Test Wayland
with subtest("wayland client works"):
# We let miracle-wm start the first terminal, as we might get stuck if it's not ready to process the first keybind
# machine.send_key("ctrl-alt-t")
machine.wait_for_text("alice@machine")
machine.send_chars("test-wayland\n")
machine.wait_for_file("/tmp/test-wayland-exit-ok")
machine.copy_from_machine("/tmp/test-wayland.out")
machine.screenshot("foot_wayland_info")
# please actually register that we want to close the window
machine.succeed("ydotool mousemove -- 10 10")
machine.sleep(3)
machine.send_chars("exit\n")
# please actually register that we want to close the window
machine.succeed("ydotool mousemove -- 10 10")
machine.sleep(3)
machine.wait_until_fails("pgrep foot")
# Test XWayland
with subtest("x11 client works"):
machine.send_key("meta_l-ret")
machine.wait_for_text("alice@machine")
machine.send_chars("test-x11\n")
machine.wait_for_file("/tmp/test-x11-exit-ok")
machine.copy_from_machine("/tmp/test-x11.out")
machine.screenshot("alacritty_glinfo")
# please actually register that we want to close the window
machine.succeed("ydotool mousemove -- 10 10")
machine.sleep(3)
machine.send_chars("exit\n")
# please actually register that we want to close the window
machine.succeed("ydotool mousemove -- 10 10")
machine.sleep(3)
machine.wait_until_fails("pgrep alacritty")
'';
}
|