From 2dc29e0d932822baa50dbc3e81ae108382c39062 Mon Sep 17 00:00:00 2001 From: Alexander Bantyev Date: Tue, 28 Dec 2021 15:54:46 +0300 Subject: [PATCH] Add a test that nix repl --show-trace actually shows the trace --- tests/repl.sh | 10 +++++++++- tests/undefined-variable.nix | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 tests/undefined-variable.nix 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