Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add repl completion test #10799

Merged
merged 1 commit into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@
in pkgs.buildPackages.runCommand "test-rl-next-release-notes" { } ''
LANG=C.UTF-8 ${pkgs.changelog-d-nix}/bin/changelog-d ${./doc/manual/rl-next} >$out
'';
repl-completion = nixpkgsFor.${system}.native.callPackage ./tests/repl-completion.nix { };
} // (lib.optionalAttrs (builtins.elem system linux64BitSystems)) {
dockerImage = self.hydraJobs.dockerImage.${system};
} // (lib.optionalAttrs (!(builtins.elem system linux32BitSystems))) {
Expand Down
40 changes: 40 additions & 0 deletions tests/repl-completion.nix
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
''
Loading