diff options
author | Robert Hensing <robert@roberthensing.nl> | 2024-05-27 09:58:49 +0200 |
---|---|---|
committer | Jörg Thalheim <joerg@thalheim.io> | 2024-06-16 04:03:32 +0000 |
commit | b588a761febc62bd6f3a224c0eb8d181b44dbe3c (patch) | |
tree | 35587635ff0a5795200a6bd70c2313d4f7763cb8 /tests | |
parent | 4734ce7831daf6e7e976029017b1cc2e7e615f30 (diff) |
Merge pull request #10799 from hercules-ci/safer-tab-completion
Add repl completion test
(cherry picked from commit 1e2b26734b4da101247678aec405c9dcfdc33f98)
Change-Id: Ic3de39e71960a05a8676190b1ec9a7f0bb6057f5
Signed-off-by: Jörg Thalheim <joerg@thalheim.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/repl-completion.nix | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/repl-completion.nix b/tests/repl-completion.nix new file mode 100644 index 000000000..234ef9466 --- /dev/null +++ b/tests/repl-completion.nix @@ -0,0 +1,40 @@ +{ runCommand, nix, expect }: + +# We only use expect when necessary, e.g. for testing tab completion in nix repl. +# See also tests/functional/repl.sh + +runCommand "repl-completion" { + nativeBuildInputs = [ + expect + nix + ]; + expectScript = '' + # Regression https://github.com/NixOS/nix/pull/10778 + spawn nix repl --offline --extra-experimental-features nix-command + expect "nix-repl>" + send "foo = import ./does-not-exist.nix\n" + expect "nix-repl>" + send "foo.\t" + expect { + "nix-repl>" { + puts "Got another prompt. Good." + } + eof { + puts "Got EOF. Bad." + exit 1 + } + } + exit 0 + ''; + passAsFile = [ "expectScript" ]; +} +'' + export NIX_STORE=$TMPDIR/store + export NIX_STATE_DIR=$TMPDIR/state + export HOME=$TMPDIR/home + mkdir $HOME + + nix-store --init + expect $expectScriptPath + touch $out +'' |