From b052e7e71ddf85921580415039a5a86a98ce042c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophane=20Hufschmitt?= Date: Wed, 13 Jul 2022 10:29:47 +0200 Subject: [PATCH] Add some more completion tests - Test another command than `build` - Test with two input flakes --- tests/completions.sh | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/tests/completions.sh b/tests/completions.sh index 75b56714684..522aa1c8649 100644 --- a/tests/completions.sh +++ b/tests/completions.sh @@ -2,25 +2,32 @@ source common.sh cd "$TEST_ROOT" -mkdir -p dep && pushd dep -cat < flake.nix +mkdir -p dep +cat < dep/flake.nix { outputs = i: { }; } EOF -popd -mkdir -p foo && pushd foo -cat < flake.nix +mkdir -p foo +cat < foo/flake.nix { - inputs.a.url = "path:$(realpath ../dep)"; + inputs.a.url = "path:$(realpath dep)"; outputs = i: { sampleOutput = 1; }; } EOF +mkdir -p bar +cat < bar/flake.nix +{ + inputs.b.url = "path:$(realpath dep)"; -popd + outputs = i: { + sampleOutput = 1; + }; +} +EOF # Test the completion of a subcommand [[ "$(NIX_GET_COMPLETIONS=1 nix buil)" == $'normal\nbuild\t' ]] @@ -32,10 +39,14 @@ popd # Input override completion [[ "$(NIX_GET_COMPLETIONS=4 nix build ./foo --override-input '')" == $'normal\na\t' ]] +[[ "$(NIX_GET_COMPLETIONS=5 nix flake show ./foo --override-input '')" == $'normal\na\t' ]] +## With multiple input flakes +[[ "$(NIX_GET_COMPLETIONS=5 nix build ./foo ./bar --override-input '')" == $'normal\na\t\nb\t' ]] ## With tilde expansion [[ "$(HOME=$PWD NIX_GET_COMPLETIONS=4 nix build '~/foo' --override-input '')" == $'normal\na\t' ]] ## Out of order [[ "$(NIX_GET_COMPLETIONS=3 nix build --update-input '' ./foo)" == $'normal\na\t' ]] +[[ "$(NIX_GET_COMPLETIONS=4 nix build ./foo --update-input '' ./bar)" == $'normal\na\t\nb\t' ]] # Cli flag completion NIX_GET_COMPLETIONS=2 nix build --log-form | grep -- "--log-format" @@ -46,7 +57,6 @@ NIX_GET_COMPLETIONS=3 nix build --option allow-import-from | grep -- "allow-impo ## As a cli flag – not working atm # NIX_GET_COMPLETIONS=2 nix build --allow-import-from | grep -- "allow-import-from-derivation" - # Attr path completions [[ "$(NIX_GET_COMPLETIONS=2 nix eval ./foo\#sam)" == $'attrs\n./foo#sampleOutput\t' ]] [[ "$(NIX_GET_COMPLETIONS=4 nix eval --file ./foo/flake.nix outp)" == $'attrs\noutputs\t' ]]