summary refs log tree commit diff
diff options
context:
space:
mode:
authorivanbrennan <ivan.brennan@gmail.com>2022-01-20 09:58:05 -0500
committerivanbrennan <ivan.brennan@gmail.com>2022-01-20 09:58:05 -0500
commit51ff3add1a464f69c560908b897f285bc83cd3dc (patch)
treeaac5ef4e7428b6da9b68f02144c50dfea40ea647
parente7d2f4f8dd9e31c6d6d232dfcc049248886d3ea0 (diff)
downloadnixpkgs-51ff3add1a464f69c560908b897f285bc83cd3dc.tar
nixpkgs-51ff3add1a464f69c560908b897f285bc83cd3dc.tar.gz
nixpkgs-51ff3add1a464f69c560908b897f285bc83cd3dc.tar.bz2
nixpkgs-51ff3add1a464f69c560908b897f285bc83cd3dc.tar.lz
nixpkgs-51ff3add1a464f69c560908b897f285bc83cd3dc.tar.xz
nixpkgs-51ff3add1a464f69c560908b897f285bc83cd3dc.tar.zst
nixpkgs-51ff3add1a464f69c560908b897f285bc83cd3dc.zip
nixosTests.xmonad: avoid sleep()
Replace sleep() calls where possible, using wait_for_* methods. This
should provide more robustness in cases where tests are running on a
congested system.
-rw-r--r--nixos/tests/xmonad.nix9
1 files changed, 3 insertions, 6 deletions
diff --git a/nixos/tests/xmonad.nix b/nixos/tests/xmonad.nix
index a14d4b819eb..eb2e0563d7c 100644
--- a/nixos/tests/xmonad.nix
+++ b/nixos/tests/xmonad.nix
@@ -90,8 +90,7 @@ in {
 
     # original config has a keybinding that creates somefile
     machine.send_key("alt-ctrl-t")
-    machine.sleep(1)
-    machine.succeed("stat /tmp/somefile")
+    machine.wait_for_file("/tmp/somefile")
 
     # set up the new config
     machine.succeed("mkdir -p ${user.home}/.xmonad")
@@ -103,15 +102,13 @@ in {
 
     # new config has a keybinding that deletes somefile
     machine.send_key("alt-ctrl-r")
-    machine.sleep(1)
-    machine.fail("stat /tmp/somefile")
+    machine.wait_until_fails("stat /tmp/somefile", timeout=30)
 
     # 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")
+    machine.wait_for_file("/tmp/somefile")
   '';
 })