Unverified Commit 5225b00f authored by Philip Taron's avatar Philip Taron Committed by GitHub
Browse files

tests.replaceVars.replaceVarsWith: fix (#375620)

parents 002e317b d07168dc
Loading
Loading
Loading
Loading
+34 −22
Original line number Diff line number Diff line
@@ -11,7 +11,7 @@ let
  inherit (testers) testEqualContents testBuildFailure;

  mkTests =
    callReplaceVars:
    callReplaceVars: mkExpectation:
    lib.recurseIntoAttrs {
      succeeds = testEqualContents {
        assertion = "replaceVars-succeeds";
@@ -21,13 +21,15 @@ let
          brotherhood = "shared humanity";
        };

        expected = builtins.toFile "expected" ''
        expected = mkExpectation (
          builtins.toFile "source.txt" ''
            All human beings are born free and are the same in dignity and rights.
            They are endowed with reason and conscience and should act towards
            one another in a spirit of shared humanity.

              -- eroosevelt@humanrights.un.org
        '';
          ''
        );
      };

      # There might eventually be a usecase for this, but it's not supported at the moment.
@@ -83,13 +85,15 @@ let
          brotherhood = null;
        };

        expected = builtins.toFile "expected" ''
        expected = mkExpectation (
          builtins.toFile "source.txt" ''
            All human beings are born free and are the same in dignity and rights.
            They are endowed with reason and conscience and should act towards
            one another in a spirit of @brotherhood@.

              -- eroosevelt@humanrights.un.org
        '';
          ''
        );
      };

      fails-in-check-phase-with-exemption =
@@ -120,13 +124,21 @@ let
    };
in
{
  replaceVars = mkTests replaceVars;
  replaceVarsWith = mkTests (
  replaceVars = mkTests replaceVars lib.id;
  replaceVarsWith =
    mkTests
      (
        src: replacements:
        replaceVarsWith {
          inherit src replacements;
          dir = "bin";
          isExecutable = true;
        }
      )
      (
        file:
        runCommand "expected" { inherit file; } ''
          install -Dm755 "$file" "$out/bin/$(stripHash "$file")"
        ''
      );
}