testers.testEqualArrayOrMap: move argument check from bash to Nix
This commit is contained in:
@@ -2,13 +2,10 @@
|
||||
|
||||
set -eu
|
||||
|
||||
preScript() {
|
||||
# If neither expectedArray nor expectedMap are declared, the test is meaningless.
|
||||
if ! isDeclaredArray expectedArray && ! isDeclaredMap expectedMap; then
|
||||
nixErrorLog "neither expectedArray nor expectedMap were set, so test is meaningless!"
|
||||
exit 1
|
||||
fi
|
||||
# NOTE: If neither expectedArray nor expectedMap are declared, the test is meaningless.
|
||||
# This precondition is checked in the Nix expression through an assert.
|
||||
|
||||
preScript() {
|
||||
if isDeclaredArray valuesArray; then
|
||||
# shellcheck disable=SC2154
|
||||
nixLog "using valuesArray: $(declare -p valuesArray)"
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
stdenvNoCC,
|
||||
}:
|
||||
let
|
||||
inherit (lib.asserts) assertMsg;
|
||||
inherit (lib.customisation) makeOverridable;
|
||||
|
||||
testEqualArrayOrMap =
|
||||
@@ -15,6 +16,9 @@ let
|
||||
expectedMap ? null,
|
||||
script,
|
||||
}:
|
||||
assert assertMsg (
|
||||
expectedArray != null || expectedMap != null
|
||||
) "testEqualArrayOrMap: at least one of 'expectedArray' or 'expectedMap' must be provided";
|
||||
stdenvNoCC.mkDerivation {
|
||||
__structuredAttrs = true;
|
||||
strictDeps = true;
|
||||
|
||||
Reference in New Issue
Block a user