mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-18 03:30:45 +00:00
lib.fileset: Make expectEqual check more
This commit is contained in:
parent
efbcf5938f
commit
ac2c8d321c
|
@ -57,18 +57,35 @@ with lib.fileset;'
|
|||
expectEqual() {
|
||||
local actualExpr=$1
|
||||
local expectedExpr=$2
|
||||
if ! actualResult=$(nix-instantiate --eval --strict --show-trace \
|
||||
if actualResult=$(nix-instantiate --eval --strict --show-trace 2>"$tmp"/actualStderr \
|
||||
--expr "$prefixExpression ($actualExpr)"); then
|
||||
die "$actualExpr failed to evaluate, but it was expected to succeed"
|
||||
actualExitCode=$?
|
||||
else
|
||||
actualExitCode=$?
|
||||
fi
|
||||
if ! expectedResult=$(nix-instantiate --eval --strict --show-trace \
|
||||
actualStderr=$(< "$tmp"/actualStderr)
|
||||
|
||||
if expectedResult=$(nix-instantiate --eval --strict --show-trace 2>"$tmp"/expectedStderr \
|
||||
--expr "$prefixExpression ($expectedExpr)"); then
|
||||
die "$expectedExpr failed to evaluate, but it was expected to succeed"
|
||||
expectedExitCode=$?
|
||||
else
|
||||
expectedExitCode=$?
|
||||
fi
|
||||
expectedStderr=$(< "$tmp"/expectedStderr)
|
||||
|
||||
if [[ "$actualExitCode" != "$expectedExitCode" ]]; then
|
||||
echo "$actualStderr" >&2
|
||||
echo "$actualResult" >&2
|
||||
die "$actualExpr should have exited with $expectedExitCode, but it exited with $actualExitCode"
|
||||
fi
|
||||
|
||||
if [[ "$actualResult" != "$expectedResult" ]]; then
|
||||
die "$actualExpr should have evaluated to $expectedExpr:\n$expectedResult\n\nbut it evaluated to\n$actualResult"
|
||||
fi
|
||||
|
||||
if [[ "$actualStderr" != "$expectedStderr" ]]; then
|
||||
die "$actualExpr should have had this on stderr:\n$expectedStderr\n\nbut it was\n$actualStderr"
|
||||
fi
|
||||
}
|
||||
|
||||
# Check that a nix expression evaluates successfully to a store path and returns it (without quotes).
|
||||
|
|
Loading…
Reference in a new issue