summary refs log tree commit diff
path: root/nixos/tests/starship.nix
diff options
context:
space:
mode:
authorDaniel Thwaites <danthwaites30@btinternet.com>2022-01-12 19:43:52 +0000
committerDaniel Thwaites <danthwaites30@btinternet.com>2022-01-13 07:56:52 +0000
commit7dc24c092332a6313309926028656915d676e10e (patch)
tree66502e94490f2f1bdf587ad553adef6d3ecaf270 /nixos/tests/starship.nix
parent123844971c40d64580af87a2688494ffa511e7e6 (diff)
downloadnixpkgs-7dc24c092332a6313309926028656915d676e10e.tar
nixpkgs-7dc24c092332a6313309926028656915d676e10e.tar.gz
nixpkgs-7dc24c092332a6313309926028656915d676e10e.tar.bz2
nixpkgs-7dc24c092332a6313309926028656915d676e10e.tar.lz
nixpkgs-7dc24c092332a6313309926028656915d676e10e.tar.xz
nixpkgs-7dc24c092332a6313309926028656915d676e10e.tar.zst
nixpkgs-7dc24c092332a6313309926028656915d676e10e.zip
nixos/starship: use expect for testing
Accidentally reverted this while fixing merge conflicts on #149423.
Diffstat (limited to 'nixos/tests/starship.nix')
-rw-r--r--nixos/tests/starship.nix27
1 files changed, 19 insertions, 8 deletions
diff --git a/nixos/tests/starship.nix b/nixos/tests/starship.nix
index f21da1e6e25..33e9a72f700 100644
--- a/nixos/tests/starship.nix
+++ b/nixos/tests/starship.nix
@@ -13,19 +13,30 @@ import ./make-test-python.nix ({ pkgs, ... }: {
       };
     };
 
-    services.getty.autologinUser = "root";
+    environment.systemPackages = map
+      (shell: pkgs.writeScriptBin "expect-${shell}" ''
+        #!${pkgs.expect}/bin/expect -f
+
+        spawn env TERM=xterm ${shell} -i
+
+        expect "<starship>" {
+          send "exit\n"
+        } timeout {
+          send_user "\n${shell} failed to display Starship\n"
+          exit 1
+        }
+
+        expect eof
+      '')
+      [ "bash" "fish" "zsh" ];
   };
 
   testScript = ''
     start_all()
     machine.wait_for_unit("default.target")
 
-    for shell in ["bash", "fish", "zsh"]:
-      machine.send_chars(f"script -c {shell} /tmp/{shell}.txt\n")
-      machine.wait_until_tty_matches(1, f"Script started.*{shell}.txt")
-      machine.send_chars("exit\n")
-      machine.wait_until_tty_matches(1, "Script done")
-      machine.sleep(1)
-      machine.succeed(f"grep -q '<starship>' /tmp/{shell}.txt")
+    machine.succeed("expect-bash")
+    machine.succeed("expect-fish")
+    machine.succeed("expect-zsh")
   '';
 })