forked from mirrors/nixpkgs
nixosTests.xmonad: test configured recompilation
Add test coverage for the enableConfiguredRecompile option, checking that we can compile and exec a new xmonad from a user's local config, as well as restart the originally configured xmonad. As I needed a reliable way to wait for recompilation to finish before proceeding with subsequent test steps, I adjusted the startup behavior to write a file ("oldXMonad" or "newXMonad") to /etc upon startup, and replaced some "sleep" calls with "wait_for_file".
This commit is contained in:
parent
6c72deb51b
commit
44af29e6f5
|
@ -1,4 +1,55 @@
|
|||
import ./make-test-python.nix ({ pkgs, ...} : {
|
||||
import ./make-test-python.nix ({ pkgs, ...}:
|
||||
|
||||
let
|
||||
mkConfig = name: keys: ''
|
||||
import XMonad
|
||||
import XMonad.Operations (restart)
|
||||
import XMonad.Util.EZConfig
|
||||
import XMonad.Util.SessionStart
|
||||
import Control.Monad (when)
|
||||
import Text.Printf (printf)
|
||||
import System.Posix.Process (executeFile)
|
||||
import System.Info (arch,os)
|
||||
import System.Environment (getArgs)
|
||||
import System.FilePath ((</>))
|
||||
|
||||
main = launch $ def { startupHook = startup } `additionalKeysP` myKeys
|
||||
|
||||
startup = isSessionStart >>= \sessInit ->
|
||||
spawn "touch /tmp/${name}"
|
||||
>> if sessInit then setSessionStarted else spawn "xterm"
|
||||
|
||||
myKeys = [${builtins.concatStringsSep ", " keys}]
|
||||
|
||||
compiledConfig = printf "xmonad-%s-%s" arch os
|
||||
|
||||
compileRestart resume =
|
||||
whenX (recompile True) $
|
||||
when resume writeStateToFile
|
||||
*> catchIO
|
||||
( do
|
||||
dir <- getXMonadDataDir
|
||||
args <- getArgs
|
||||
executeFile (dir </> compiledConfig) False args Nothing
|
||||
)
|
||||
'';
|
||||
|
||||
oldKeys =
|
||||
[ ''("M-C-x", spawn "xterm")''
|
||||
''("M-q", restart "xmonad" True)''
|
||||
''("M-C-q", compileRestart True)''
|
||||
''("M-C-t", spawn "touch /tmp/somefile")'' # create somefile
|
||||
];
|
||||
|
||||
newKeys =
|
||||
[ ''("M-C-x", spawn "xterm")''
|
||||
''("M-q", restart "xmonad" True)''
|
||||
''("M-C-q", compileRestart True)''
|
||||
''("M-C-r", spawn "rm /tmp/somefile")'' # delete somefile
|
||||
];
|
||||
|
||||
newConfig = pkgs.writeText "xmonad.hs" (mkConfig "newXMonad" newKeys);
|
||||
in {
|
||||
name = "xmonad";
|
||||
meta = with pkgs.lib.maintainers; {
|
||||
maintainers = [ nequissimus ];
|
||||
|
@ -10,21 +61,10 @@ import ./make-test-python.nix ({ pkgs, ...} : {
|
|||
services.xserver.displayManager.defaultSession = "none+xmonad";
|
||||
services.xserver.windowManager.xmonad = {
|
||||
enable = true;
|
||||
enableConfiguredRecompile = true;
|
||||
enableContribAndExtras = true;
|
||||
extraPackages = with pkgs.haskellPackages; haskellPackages: [ xmobar ];
|
||||
config = ''
|
||||
import XMonad
|
||||
import XMonad.Operations (restart)
|
||||
import XMonad.Util.EZConfig
|
||||
import XMonad.Util.SessionStart
|
||||
|
||||
main = launch $ def { startupHook = startup } `additionalKeysP` myKeys
|
||||
|
||||
startup = isSessionStart >>= \sessInit ->
|
||||
if sessInit then setSessionStarted else spawn "xterm"
|
||||
|
||||
myKeys = [ ("M-C-x", spawn "xterm"), ("M-q", restart "xmonad" True) ]
|
||||
'';
|
||||
config = mkConfig "oldXMonad" oldKeys;
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -38,10 +78,40 @@ import ./make-test-python.nix ({ pkgs, ...} : {
|
|||
machine.wait_for_window("${user.name}.*machine")
|
||||
machine.sleep(1)
|
||||
machine.screenshot("terminal1")
|
||||
machine.succeed("rm /tmp/oldXMonad")
|
||||
machine.send_key("alt-q")
|
||||
machine.sleep(3)
|
||||
machine.wait_for_file("/tmp/oldXMonad")
|
||||
machine.wait_for_window("${user.name}.*machine")
|
||||
machine.sleep(1)
|
||||
machine.screenshot("terminal2")
|
||||
|
||||
# /tmp/somefile should not exist yet
|
||||
machine.fail("stat /tmp/somefile")
|
||||
|
||||
# original config has a keybinding that creates somefile
|
||||
machine.send_key("alt-ctrl-t")
|
||||
machine.sleep(1)
|
||||
machine.succeed("stat /tmp/somefile")
|
||||
|
||||
# set up the new config
|
||||
machine.succeed("mkdir -p ${user.home}/.xmonad")
|
||||
machine.copy_from_host("${newConfig}", "${user.home}/.xmonad/xmonad.hs")
|
||||
|
||||
# recompile xmonad using the new config
|
||||
machine.send_key("alt-ctrl-q")
|
||||
machine.wait_for_file("/tmp/newXMonad")
|
||||
|
||||
# new config has a keybinding that deletes somefile
|
||||
machine.send_key("alt-ctrl-r")
|
||||
machine.sleep(1)
|
||||
machine.fail("stat /tmp/somefile")
|
||||
|
||||
# restart with the old config, and confirm the old keybinding is back
|
||||
machine.succeed("rm /tmp/oldXMonad")
|
||||
machine.send_key("alt-q")
|
||||
machine.wait_for_file("/tmp/oldXMonad")
|
||||
machine.send_key("alt-ctrl-t")
|
||||
machine.sleep(1)
|
||||
machine.succeed("stat /tmp/somefile")
|
||||
'';
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue