tests/functional: test both clis warn on unknown settings

This commit is contained in:
Cole Helbling 2024-05-14 12:13:14 -07:00
parent 2f0031aedc
commit 06e13465c5
2 changed files with 13 additions and 0 deletions

View file

@ -52,3 +52,7 @@ fi
# Test --arg-from-stdin. # Test --arg-from-stdin.
[[ "$(echo bla | nix eval --raw --arg-from-stdin foo --expr '{ foo }: { inherit foo; }' foo)" = bla ]] [[ "$(echo bla | nix eval --raw --arg-from-stdin foo --expr '{ foo }: { inherit foo; }' foo)" = bla ]]
# Test that unknown settings are warned about
out="$(expectStderr 0 nix eval --option foobar baz --expr '""' --raw)"
[[ "$(echo "$out" | grep foobar | wc -l)" = 1 ]]

View file

@ -30,3 +30,12 @@ expectStderr 1 nix-instantiate --eval -E '[]' -A 'x' | grepQuiet "should be a se
expectStderr 1 nix-instantiate --eval -E '{}' -A '1' | grepQuiet "should be a list" expectStderr 1 nix-instantiate --eval -E '{}' -A '1' | grepQuiet "should be a list"
expectStderr 1 nix-instantiate --eval -E '{}' -A '.' | grepQuiet "empty attribute name" expectStderr 1 nix-instantiate --eval -E '{}' -A '.' | grepQuiet "empty attribute name"
expectStderr 1 nix-instantiate --eval -E '[]' -A '1' | grepQuiet "out of range" expectStderr 1 nix-instantiate --eval -E '[]' -A '1' | grepQuiet "out of range"
# Unknown setting warning
# NOTE(cole-h): behavior is different depending on the order, which is why we test an unknown option
# before and after the `'{}'`!
out="$(expectStderr 0 nix-instantiate --option foobar baz --expr '{}')"
[[ "$(echo "$out" | grep foobar | wc -l)" = 1 ]]
out="$(expectStderr 0 nix-instantiate '{}' --option foobar baz --expr )"
[[ "$(echo "$out" | grep foobar | wc -l)" = 1 ]]