tests/functional: add assertStderr function

Currently there isn't a convenient way to check for multiline output. In
addition, these outputs will easily change and having a diff between the
expected an the actual output upon failures is convenient.
This commit is contained in:
Bob van der Linden 2024-02-28 23:35:10 +01:00
parent 87741dbd21
commit 9fac62435c
No known key found for this signature in database

View file

@ -216,6 +216,17 @@ expectStderr() {
return 0
}
# Run a command and check whether the stderr matches stdin.
# Show a diff when output does not match.
# Usage:
#
# assertStderr nix profile remove nothing << EOF
# error: This error is expected
# EOF
assertStderr() {
diff -u /dev/stdin <($@ 2>/dev/null 2>&1)
}
needLocalStore() {
if [[ "$NIX_REMOTE" == "daemon" ]]; then
skipTest "Cant run through the daemon ($1)"