Commit abf9e606 authored by Connor Baker's avatar Connor Baker
Browse files

testers.testEqualArrayOrMap: move argument check from bash to Nix

parent c80dc381
Loading
Loading
Loading
Loading
+3 −6
Original line number Diff line number Diff line
@@ -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 −0
Original line number Diff line number Diff line
@@ -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;