-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10799 from hercules-ci/safer-tab-completion
Add repl completion test
- Loading branch information
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
'' |