diff options
-rw-r--r-- | flake.nix | 6 | ||||
-rw-r--r-- | tests/repl-completion.nix | 40 |
2 files changed, 46 insertions, 0 deletions
@@ -233,6 +233,11 @@ } ); + # Completion tests for the Nix REPL. + repl-completion = forAllSystems ( + system: nixpkgsFor.${system}.native.callPackage ./tests/repl-completion.nix { } + ); + # Perl bindings for various platforms. perlBindings = forAllSystems (system: nixpkgsFor.${system}.native.nix.passthru.perl-bindings); @@ -330,6 +335,7 @@ rl-next = self.hydraJobs.rl-next.${system}.user; # Will be empty attr set on i686-linux, and filtered out by forAvailableSystems. pre-commit = self.hydraJobs.pre-commit.${system}; + repl-completion = self.hydraJobs.repl-completion.${system}; } // (lib.optionalAttrs (builtins.elem system linux64BitSystems)) { dockerImage = self.hydraJobs.dockerImage.${system}; 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 +'' |