diff --git a/tests/repl.sh b/tests/repl.sh index 995db869c..0e23a98db 100644 --- a/tests/repl.sh +++ b/tests/repl.sh @@ -13,6 +13,10 @@ failing = import ./simple-failing.nix :log failing " +replUndefinedVariable=" +import ./undefined-variable.nix +" + testRepl () { local nixArgs=("$@") local replOutput="$(nix repl "${nixArgs[@]}" <<< "$replCmds")" @@ -22,10 +26,14 @@ testRepl () { nix path-info "${nixArgs[@]}" "$outPath" # simple.nix prints a PATH during build echo "$replOutput" | grep -qs 'PATH=' || fail "nix repl :log doesn't output logs" - local replOutput="$(nix repl "${nixArgs[@]}" <<< "$replFailingCmds")" + local replOutput="$(nix repl "${nixArgs[@]}" <<< "$replFailingCmds" 2>&1)" echo "$replOutput" echo "$replOutput" | grep -qs 'This should fail' \ || fail "nix repl :log doesn't output logs for a failed derivation" + local replOutput="$(nix repl --show-trace "${nixArgs[@]}" <<< "$replUndefinedVariable" 2>&1)" + echo "$replOutput" + echo "$replOutput" | grep -qs "while evaluating the file" \ + || fail "nix repl --show-trace doesn't show the trace" } # Simple test, try building a drv diff --git a/tests/undefined-variable.nix b/tests/undefined-variable.nix new file mode 100644 index 000000000..579985497 --- /dev/null +++ b/tests/undefined-variable.nix @@ -0,0 +1 @@ +let f = builtins.toFile "test-file.nix" "asd"; in import f