From 04bc28c6802cbf564f83708b7983f12fd39a9bfa Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Fri, 14 Mar 2025 22:41:04 +0100 Subject: [PATCH] nixosTests.zsh-history: migrate to runTest Part Of #386873 --- nixos/tests/all-tests.nix | 2 +- nixos/tests/zsh-history.nix | 68 ++++++++++++++++++------------------- 2 files changed, 34 insertions(+), 36 deletions(-) diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 50e2bd0c70b4..ea62bfbdc521 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -1319,7 +1319,7 @@ in { zookeeper = handleTest ./zookeeper.nix {}; zram-generator = handleTest ./zram-generator.nix {}; zrepl = handleTest ./zrepl.nix {}; - zsh-history = handleTest ./zsh-history.nix {}; + zsh-history = runTest ./zsh-history.nix; zwave-js = runTest ./zwave-js.nix; zwave-js-ui = runTest ./zwave-js-ui.nix; } diff --git a/nixos/tests/zsh-history.nix b/nixos/tests/zsh-history.nix index 539729e32039..fe3dd44a25e2 100644 --- a/nixos/tests/zsh-history.nix +++ b/nixos/tests/zsh-history.nix @@ -1,40 +1,38 @@ -import ./make-test-python.nix ( - { pkgs, ... }: - { - name = "zsh-history"; - meta = with pkgs.lib.maintainers; { - maintainers = [ ]; +{ pkgs, ... }: +{ + name = "zsh-history"; + meta = with pkgs.lib.maintainers; { + maintainers = [ ]; + }; + + nodes.default = + { ... }: + { + programs = { + zsh.enable = true; + }; + environment.systemPackages = [ pkgs.zsh-history ]; + programs.zsh.interactiveShellInit = '' + source ${pkgs.zsh-history.out}/share/zsh/init.zsh + ''; + users.users.root.shell = "${pkgs.zsh}/bin/zsh"; }; - nodes.default = - { ... }: - { - programs = { - zsh.enable = true; - }; - environment.systemPackages = [ pkgs.zsh-history ]; - programs.zsh.interactiveShellInit = '' - source ${pkgs.zsh-history.out}/share/zsh/init.zsh - ''; - users.users.root.shell = "${pkgs.zsh}/bin/zsh"; - }; + testScript = '' + start_all() + default.wait_for_unit("multi-user.target") + default.wait_until_succeeds("pgrep -f 'agetty.*tty1'") - testScript = '' - start_all() - default.wait_for_unit("multi-user.target") - default.wait_until_succeeds("pgrep -f 'agetty.*tty1'") + # Login + default.wait_until_tty_matches("1", "login: ") + default.send_chars("root\n") + default.wait_until_tty_matches("1", r"\nroot@default\b") - # Login - default.wait_until_tty_matches("1", "login: ") - default.send_chars("root\n") - default.wait_until_tty_matches("1", r"\nroot@default\b") + # Generate some history + default.send_chars("echo foobar\n") + default.wait_until_tty_matches("1", "foobar") - # Generate some history - default.send_chars("echo foobar\n") - default.wait_until_tty_matches("1", "foobar") - - # Ensure that command was recorded in history - default.succeed("/run/current-system/sw/bin/history list | grep -q foobar") - ''; - } -) + # Ensure that command was recorded in history + default.succeed("/run/current-system/sw/bin/history list | grep -q foobar") + ''; +}