tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
lol
0
fork
atom
overview
issues
pulls
pipelines
nixosTests.xmonad: migrate to runTest
Part Of #386873
Martin Weinelt
10 months ago
ead8dabd
4ada7d81
+110
-112
2 changed files
expand all
collapse all
unified
split
nixos
tests
all-tests.nix
xmonad.nix
+1
-1
nixos/tests/all-tests.nix
···
1289
xautolock = handleTest ./xautolock.nix {};
1290
xfce = handleTest ./xfce.nix {};
1291
xfce-wayland = handleTest ./xfce-wayland.nix {};
1292
-
xmonad = handleTest ./xmonad.nix {};
1293
xmonad-xdg-autostart = runTest ./xmonad-xdg-autostart.nix;
1294
xpadneo = runTest ./xpadneo.nix;
1295
xrdp = runTest ./xrdp.nix;
···
1289
xautolock = handleTest ./xautolock.nix {};
1290
xfce = handleTest ./xfce.nix {};
1291
xfce-wayland = handleTest ./xfce-wayland.nix {};
1292
+
xmonad = runTest ./xmonad.nix;
1293
xmonad-xdg-autostart = runTest ./xmonad-xdg-autostart.nix;
1294
xpadneo = runTest ./xpadneo.nix;
1295
xrdp = runTest ./xrdp.nix;
+109
-111
nixos/tests/xmonad.nix
···
1
-
import ./make-test-python.nix (
2
-
{ pkgs, ... }:
3
4
-
let
5
-
mkConfig = name: keys: ''
6
-
import XMonad
7
-
import XMonad.Operations (restart)
8
-
import XMonad.Util.EZConfig
9
-
import XMonad.Util.SessionStart
10
-
import Control.Monad (when)
11
-
import Text.Printf (printf)
12
-
import System.Posix.Process (executeFile)
13
-
import System.Info (arch,os)
14
-
import System.Environment (getArgs)
15
-
import System.FilePath ((</>))
16
17
-
main = do
18
-
dirs <- getDirectories
19
-
launch (def { startupHook = startup } `additionalKeysP` myKeys) dirs
20
21
-
startup = isSessionStart >>= \sessInit ->
22
-
spawn "touch /tmp/${name}"
23
-
>> if sessInit then setSessionStarted else spawn "xterm"
24
25
-
myKeys = [${builtins.concatStringsSep ", " keys}]
26
27
-
compiledConfig = printf "xmonad-%s-%s" arch os
28
29
-
compileRestart resume = do
30
-
dirs <- asks directories
31
32
-
whenX (recompile dirs True) $
33
-
when resume writeStateToFile
34
-
*> catchIO
35
-
( do
36
-
args <- getArgs
37
-
executeFile (cacheDir dirs </> compiledConfig) False args Nothing
38
-
)
39
-
'';
40
41
-
oldKeys = [
42
-
''("M-C-x", spawn "xterm")''
43
-
''("M-q", restart "xmonad" True)''
44
-
''("M-C-q", compileRestart True)''
45
-
''("M-C-t", spawn "touch /tmp/somefile")'' # create somefile
46
-
];
47
48
-
newKeys = [
49
-
''("M-C-x", spawn "xterm")''
50
-
''("M-q", restart "xmonad" True)''
51
-
''("M-C-q", compileRestart True)''
52
-
''("M-C-r", spawn "rm /tmp/somefile")'' # delete somefile
0
0
0
0
0
0
0
0
0
0
53
];
0
54
55
-
newConfig = pkgs.writeText "xmonad.hs" (mkConfig "newXMonad" newKeys);
56
-
in
57
-
{
58
-
name = "xmonad";
59
-
meta = with pkgs.lib.maintainers; {
60
-
maintainers = [
61
-
nequissimus
62
-
ivanbrennan
63
];
0
0
0
0
0
0
0
0
0
64
};
65
66
-
nodes.machine =
67
-
{ pkgs, ... }:
68
-
{
69
-
imports = [
70
-
./common/x11.nix
71
-
./common/user-account.nix
72
-
];
73
-
test-support.displayManager.auto.user = "alice";
74
-
services.displayManager.defaultSession = "none+xmonad";
75
-
services.xserver.windowManager.xmonad = {
76
-
enable = true;
77
-
enableConfiguredRecompile = true;
78
-
enableContribAndExtras = true;
79
-
extraPackages = with pkgs.haskellPackages; haskellPackages: [ xmobar ];
80
-
config = mkConfig "oldXMonad" oldKeys;
81
-
};
82
-
};
83
-
84
-
testScript =
85
-
{ nodes, ... }:
86
-
let
87
-
user = nodes.machine.config.users.users.alice;
88
-
in
89
-
''
90
-
machine.wait_for_x()
91
-
machine.wait_for_file("${user.home}/.Xauthority")
92
-
machine.succeed("xauth merge ${user.home}/.Xauthority")
93
-
machine.send_key("alt-ctrl-x")
94
-
machine.wait_for_window("${user.name}.*machine")
95
-
machine.sleep(1)
96
-
machine.screenshot("terminal1")
97
-
machine.succeed("rm /tmp/oldXMonad")
98
-
machine.send_key("alt-q")
99
-
machine.wait_for_file("/tmp/oldXMonad")
100
-
machine.wait_for_window("${user.name}.*machine")
101
-
machine.sleep(1)
102
-
machine.screenshot("terminal2")
103
104
-
# /tmp/somefile should not exist yet
105
-
machine.fail("stat /tmp/somefile")
106
107
-
# original config has a keybinding that creates somefile
108
-
machine.send_key("alt-ctrl-t")
109
-
machine.wait_for_file("/tmp/somefile")
110
111
-
# set up the new config
112
-
machine.succeed("mkdir -p ${user.home}/.xmonad")
113
-
machine.copy_from_host("${newConfig}", "${user.home}/.config/xmonad/xmonad.hs")
114
115
-
# recompile xmonad using the new config
116
-
machine.send_key("alt-ctrl-q")
117
-
machine.wait_for_file("/tmp/newXMonad")
118
119
-
# new config has a keybinding that deletes somefile
120
-
machine.send_key("alt-ctrl-r")
121
-
machine.wait_until_fails("stat /tmp/somefile", timeout=30)
122
123
-
# restart with the old config, and confirm the old keybinding is back
124
-
machine.succeed("rm /tmp/oldXMonad")
125
-
machine.send_key("alt-q")
126
-
machine.wait_for_file("/tmp/oldXMonad")
127
-
machine.send_key("alt-ctrl-t")
128
-
machine.wait_for_file("/tmp/somefile")
129
-
'';
130
-
}
131
-
)
···
1
+
{ pkgs, ... }:
0
2
3
+
let
4
+
mkConfig = name: keys: ''
5
+
import XMonad
6
+
import XMonad.Operations (restart)
7
+
import XMonad.Util.EZConfig
8
+
import XMonad.Util.SessionStart
9
+
import Control.Monad (when)
10
+
import Text.Printf (printf)
11
+
import System.Posix.Process (executeFile)
12
+
import System.Info (arch,os)
13
+
import System.Environment (getArgs)
14
+
import System.FilePath ((</>))
15
16
+
main = do
17
+
dirs <- getDirectories
18
+
launch (def { startupHook = startup } `additionalKeysP` myKeys) dirs
19
20
+
startup = isSessionStart >>= \sessInit ->
21
+
spawn "touch /tmp/${name}"
22
+
>> if sessInit then setSessionStarted else spawn "xterm"
23
24
+
myKeys = [${builtins.concatStringsSep ", " keys}]
25
26
+
compiledConfig = printf "xmonad-%s-%s" arch os
27
28
+
compileRestart resume = do
29
+
dirs <- asks directories
30
31
+
whenX (recompile dirs True) $
32
+
when resume writeStateToFile
33
+
*> catchIO
34
+
( do
35
+
args <- getArgs
36
+
executeFile (cacheDir dirs </> compiledConfig) False args Nothing
37
+
)
38
+
'';
39
40
+
oldKeys = [
41
+
''("M-C-x", spawn "xterm")''
42
+
''("M-q", restart "xmonad" True)''
43
+
''("M-C-q", compileRestart True)''
44
+
''("M-C-t", spawn "touch /tmp/somefile")'' # create somefile
45
+
];
46
47
+
newKeys = [
48
+
''("M-C-x", spawn "xterm")''
49
+
''("M-q", restart "xmonad" True)''
50
+
''("M-C-q", compileRestart True)''
51
+
''("M-C-r", spawn "rm /tmp/somefile")'' # delete somefile
52
+
];
53
+
54
+
newConfig = pkgs.writeText "xmonad.hs" (mkConfig "newXMonad" newKeys);
55
+
in
56
+
{
57
+
name = "xmonad";
58
+
meta = with pkgs.lib.maintainers; {
59
+
maintainers = [
60
+
nequissimus
61
+
ivanbrennan
62
];
63
+
};
64
65
+
nodes.machine =
66
+
{ pkgs, ... }:
67
+
{
68
+
imports = [
69
+
./common/x11.nix
70
+
./common/user-account.nix
0
0
71
];
72
+
test-support.displayManager.auto.user = "alice";
73
+
services.displayManager.defaultSession = "none+xmonad";
74
+
services.xserver.windowManager.xmonad = {
75
+
enable = true;
76
+
enableConfiguredRecompile = true;
77
+
enableContribAndExtras = true;
78
+
extraPackages = with pkgs.haskellPackages; haskellPackages: [ xmobar ];
79
+
config = mkConfig "oldXMonad" oldKeys;
80
+
};
81
};
82
83
+
testScript =
84
+
{ nodes, ... }:
85
+
let
86
+
user = nodes.machine.users.users.alice;
87
+
in
88
+
''
89
+
machine.wait_for_x()
90
+
machine.wait_for_file("${user.home}/.Xauthority")
91
+
machine.succeed("xauth merge ${user.home}/.Xauthority")
92
+
machine.send_key("alt-ctrl-x")
93
+
machine.wait_for_window("${user.name}.*machine")
94
+
machine.sleep(1)
95
+
machine.screenshot("terminal1")
96
+
machine.succeed("rm /tmp/oldXMonad")
97
+
machine.send_key("alt-q")
98
+
machine.wait_for_file("/tmp/oldXMonad")
99
+
machine.wait_for_window("${user.name}.*machine")
100
+
machine.sleep(1)
101
+
machine.screenshot("terminal2")
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
102
103
+
# /tmp/somefile should not exist yet
104
+
machine.fail("stat /tmp/somefile")
105
106
+
# original config has a keybinding that creates somefile
107
+
machine.send_key("alt-ctrl-t")
108
+
machine.wait_for_file("/tmp/somefile")
109
110
+
# set up the new config
111
+
machine.succeed("mkdir -p ${user.home}/.xmonad")
112
+
machine.copy_from_host("${newConfig}", "${user.home}/.config/xmonad/xmonad.hs")
113
114
+
# recompile xmonad using the new config
115
+
machine.send_key("alt-ctrl-q")
116
+
machine.wait_for_file("/tmp/newXMonad")
117
118
+
# new config has a keybinding that deletes somefile
119
+
machine.send_key("alt-ctrl-r")
120
+
machine.wait_until_fails("stat /tmp/somefile", timeout=30)
121
122
+
# restart with the old config, and confirm the old keybinding is back
123
+
machine.succeed("rm /tmp/oldXMonad")
124
+
machine.send_key("alt-q")
125
+
machine.wait_for_file("/tmp/oldXMonad")
126
+
machine.send_key("alt-ctrl-t")
127
+
machine.wait_for_file("/tmp/somefile")
128
+
'';
129
+
}
0