Unverified Commit d07168dc authored by Wolfgang Walther's avatar Wolfgang Walther
Browse files

tests.replaceVars.replaceVarsWith: fix

This never worked properly, but it does now.
parent 08a4c76a
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")"
        ''
      );
}