1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-08 19:23:54 +02:00

Merge pull request #10305 from hercules-ci/addErrorContext-is-great

Always print addErrorContext
This commit is contained in:
Théophane Hufschmitt 2024-03-29 09:10:09 +01:00 committed by GitHub
commit de101417eb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 96 additions and 20 deletions

View file

@ -68,8 +68,16 @@ done
for i in lang/eval-fail-*.nix; do
echo "evaluating $i (should fail)";
i=$(basename "$i" .nix)
flags="$(
if [[ -e "lang/$i.flags" ]]; then
sed -e 's/#.*//' < "lang/$i.flags"
else
# note that show-trace is also set by init.sh
echo "--eval --strict --show-trace"
fi
)"
if
expectStderr 1 nix-instantiate --eval --strict --show-trace "lang/$i.nix" \
expectStderr 1 nix-instantiate $flags "lang/$i.nix" \
| sed "s!$(pwd)!/pwd!g" > "lang/$i.err"
then
diffAndAccept "$i" err err.exp

View file

@ -0,0 +1,24 @@
error:
… while counting down; n = 10
… while counting down; n = 9
… while counting down; n = 8
… while counting down; n = 7
… while counting down; n = 6
… while counting down; n = 5
… while counting down; n = 4
… while counting down; n = 3
… while counting down; n = 2
… while counting down; n = 1
(stack trace truncated; use '--show-trace' to show the full, detailed trace)
error: kaboom

View file

@ -0,0 +1 @@
--eval --strict --no-show-trace

View file

@ -0,0 +1,9 @@
let
countDown = n:
if n == 0
then throw "kaboom"
else
builtins.addErrorContext
"while counting down; n = ${toString n}"
("x" + countDown (n - 1));
in countDown 10