aboutsummaryrefslogtreecommitdiff
path: root/tests/repl.sh
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2022-03-10 15:48:14 +0000
committerJohn Ericson <John.Ericson@Obsidian.Systems>2022-03-10 15:48:14 +0000
commit8ba089597fa19bfd49ba5f22a5e821740ca4eb5d (patch)
treeb4f2299b9c973ef7636f8ce1bab0299dee4cc389 /tests/repl.sh
parent13b6b645897fd2edaa0f09fa48d6fe8dd6287b55 (diff)
parent4d98143914120d0163f5c50f30ce8a5289433f8f (diff)
Merge remote-tracking branch 'upstream/master' into path-info
Diffstat (limited to 'tests/repl.sh')
-rw-r--r--tests/repl.sh49
1 files changed, 48 insertions, 1 deletions
diff --git a/tests/repl.sh b/tests/repl.sh
index 4e3059517..6505f1741 100644
--- a/tests/repl.sh
+++ b/tests/repl.sh
@@ -1,18 +1,65 @@
source common.sh
replCmds="
+simple = 1
simple = import ./simple.nix
:b simple
+:log simple
+"
+
+replFailingCmds="
+failing = import ./simple-failing.nix
+:b failing
+:log failing
+"
+
+replUndefinedVariable="
+import ./undefined-variable.nix
"
testRepl () {
local nixArgs=("$@")
- local outPath=$(nix repl "${nixArgs[@]}" <<< "$replCmds" |&
+ local replOutput="$(nix repl "${nixArgs[@]}" <<< "$replCmds")"
+ echo "$replOutput"
+ local outPath=$(echo "$replOutput" |&
grep -o -E "$NIX_STORE_DIR/\w*-simple")
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" 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
testRepl
# Same thing (kind-of), but with a remote store.
testRepl --store "$TEST_ROOT/store?real=$NIX_STORE_DIR"
+
+testReplResponse () {
+ local response="$(nix repl <<< "$1")"
+ echo "$response" | grep -qs "$2" \
+ || fail "repl command set:
+
+$1
+
+does not respond with:
+
+$2
+
+but with:
+
+$response"
+}
+
+# :a uses the newest version of a symbol
+testReplResponse '
+:a { a = "1"; }
+:a { a = "2"; }
+"result: ${a}"
+' "result: 2"