Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests/functional/repl.sh: fail test on wrong stdout #11110

Merged
merged 1 commit into from
Jul 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions tests/functional/repl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,21 +74,31 @@ testReplResponseGeneral () {
local grepMode commands expectedResponse response
grepMode="$1"; shift
commands="$1"; shift
expectedResponse="$1"; shift
response="$(nix repl "$@" <<< "$commands" | stripColors)"
echo "$response" | grepQuiet "$grepMode" -s "$expectedResponse" \
|| fail "repl command set:
# Expected response can contain newlines.
# grep can't handle multiline patterns, so replace newlines with TEST_NEWLINE
# in both expectedResponse and response.
# awk ORS always adds a trailing record separator, so we strip it with sed.
expectedResponse="$(printf '%s' "$1" | awk 1 ORS=TEST_NEWLINE | sed 's/TEST_NEWLINE$//')"; shift
# We don't need to strip trailing record separator here, since extra data is ok.
response="$(nix repl "$@" <<< "$commands" 2>&1 | stripColors | awk 1 ORS=TEST_NEWLINE)"
printf '%s' "$response" | grepQuiet "$grepMode" -s "$expectedResponse" \
|| fail "$(echo "repl command set:

$commands

does not respond with:

---
$expectedResponse
---

but with:

---
$response
"
---

" | sed 's/TEST_NEWLINE/\n/g')"
}

testReplResponse () {
Expand Down Expand Up @@ -190,7 +200,7 @@ testReplResponseNoRegex '
let x = { y = { a = 1; }; inherit x; }; in x
' \
'{
x = { ... };
x = «repeated»;
y = { ... };
}
'
Expand Down Expand Up @@ -242,7 +252,7 @@ testReplResponseNoRegex '
' \
'{
x = «repeated»;
y = { a = 1 };
y = { a = 1; };
}
'

Expand All @@ -256,7 +266,7 @@ runRepl () {

# That is right, we are also filtering out the testdir _without underscores_.
# This is crazy, but without it, GHA will fail to run the tests, showing paths
# _with_ underscores in the set -x log, but _without_ underscores in the
# _with_ underscores in the set -x log, but _without_ underscores in the
# supposed nix repl output. I have looked in a number of places, but I cannot
# find a mechanism that could cause this to happen.
local testDirNoUnderscores
Expand Down
Loading