Add a test that nix repl --show-trace actually shows the trace

This commit is contained in:
Alexander Bantyev 2021-12-28 15:54:46 +03:00
parent 581f774284
commit 2dc29e0d93
No known key found for this signature in database
GPG Key ID: E081FF12ADCB4AD5
2 changed files with 10 additions and 1 deletions

View File

@ -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

View File

@ -0,0 +1 @@
let f = builtins.toFile "test-file.nix" "asd"; in import f