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