about summary refs log tree commit diff stats
path: root/tests/infrastructure/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'tests/infrastructure/default.nix')
-rw-r--r--tests/infrastructure/default.nix22
1 files changed, 19 insertions, 3 deletions
diff --git a/tests/infrastructure/default.nix b/tests/infrastructure/default.nix
index 0e0408e7..e0ad6889 100644
--- a/tests/infrastructure/default.nix
+++ b/tests/infrastructure/default.nix
@@ -12,6 +12,8 @@
   description,
   hash,
   testData,
+  testShell ? pkgs.dash,
+  alternateScreen ? false,
 }:
 nixos-lib.runTest {
   hostPkgs = pkgs; # the Nixpkgs package set used outside the VMs
@@ -56,6 +58,7 @@ nixos-lib.runTest {
     testDir = "${nodes.machine.home-manager.users.soispha.home.homeDirectory}/test";
     goldenFile = "${testDir}/__test_golden";
     logFile = "${testDir}/__test_log";
+    testTmux = lib.getExe pkgs.tmux;
   in
     /*
     python
@@ -63,6 +66,8 @@ nixos-lib.runTest {
     ''
       start_all()
 
+      __TEST_TMUX="${testTmux}"
+
       machine.succeed("sudo -u soispha ${pkgs.writeShellScript "mkTestEnvironment" ''
         set -e
 
@@ -91,9 +96,15 @@ nixos-lib.runTest {
 
         cd "${testDir}"
 
-        __TEST_TMUX="${lib.getExe pkgs.tmux}"
+        __TEST_TMUX="${testTmux}"
+        __TEST_SHELL="${lib.getExe testShell}"
         __TEST_TMUX_PANE="__TEST_TMUX_PANE"
 
+        __TEST_EVAL_USE_ALTERNATE_SCREEN="${
+          if alternateScreen
+          then "true"
+          else "false"
+        }"
         __TEST_EVAL_AWK_CLEAN_FILE="${./clean.awk}"
         __TEST_EVAL_LOG_FILE="${logFile}"
         __TEST_EVAL_GOLDEN_FILE="$(mktemp)"
@@ -101,12 +112,17 @@ nixos-lib.runTest {
 
         . ${./driver.sh}
 
-        "$__TEST_TMUX" new-session -d -s "$__TEST_TMUX_PANE"
+        "$__TEST_TMUX" new-session -d -s "$__TEST_TMUX_PANE" "$__TEST_SHELL"
+
+        # Warm up the shell in the tmux sesssion
+        "$__TEST_TMUX" send-keys -t "$__TEST_TMUX_PANE" "echo hi" "Enter" "clear" "Enter"
+        sleep 2
+
         "$__TEST_TMUX" pipe-pane -t "$__TEST_TMUX_PANE" -o 'cat >>${goldenFile}'
 
         __test_eval "${description}"
 
-        # Clear the pipe again
+        # Remove the pipe
         "$__TEST_TMUX" pipe-pane -t "$__TEST_TMUX_PANE"
 
         # Check if the golden file was changed.