aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorregnat <rg@regnat.ovh>2022-03-08 06:16:51 +0100
committerregnat <rg@regnat.ovh>2022-03-08 06:21:45 +0100
commit0c6e46e34965ba0db4e0b755ee473868a4fef21f (patch)
tree33e8a2ee4beb267a84819af46c1966427e351093 /tests
parent92b8d4d8861b908a7ec500526a84155c597d6d2b (diff)
Add some suggestions to the evaluator
Make the evaluator show some suggestions when trying to access an invalid field from an attrset. ```console $ nix eval --expr '{ foo = 1; }.foa' error: attribute 'foa' missing at «string»:1:1: 1| { foo = 1; }.foa | ^ Did you mean foo? ```
Diffstat (limited to 'tests')
-rw-r--r--tests/suggestions.sh4
1 files changed, 4 insertions, 0 deletions
diff --git a/tests/suggestions.sh b/tests/suggestions.sh
index 16a5a7004..29d5b364b 100644
--- a/tests/suggestions.sh
+++ b/tests/suggestions.sh
@@ -34,3 +34,7 @@ NIX_BUILD_STDERR_WITH_SUGGESTIONS=$(! nix build .\#fob 2>&1 1>/dev/null)
NIX_BUILD_STDERR_WITH_NO_CLOSE_SUGGESTION=$(! nix build .\#bar 2>&1 1>/dev/null)
[[ ! "$NIX_BUILD_STDERR_WITH_NO_CLOSE_SUGGESTION" =~ "Did you mean" ]] || \
fail "The nix build stderr shouldn’t suggest anything if there’s nothing relevant to suggest"
+
+NIX_EVAL_STDERR_WITH_SUGGESTIONS=$(! nix build --impure --expr '(builtins.getFlake (builtins.toPath ./.)).packages.'$system'.fob' 2>&1 1>/dev/null)
+[[ "$NIX_EVAL_STDERR_WITH_SUGGESTIONS" =~ "Did you mean one of fo1, fo2, foo or fooo?" ]] || \
+ fail "The evaluator should suggest the three closest possiblities"