tests.replaceVars.replaceVarsWith: fix (#375620)

This commit is contained in:
Philip Taron
2025-01-21 15:20:23 -08:00
committed by GitHub
+34 -22
View File
@@ -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" ''
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.
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
'';
-- 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" ''
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@.
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
'';
-- eroosevelt@humanrights.un.org
''
);
};
fails-in-check-phase-with-exemption =
@@ -120,13 +124,21 @@ let
};
in
{
replaceVars = mkTests replaceVars;
replaceVarsWith = mkTests (
src: replacements:
replaceVarsWith {
inherit src replacements;
dir = "bin";
isExecutable = true;
}
);
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")"
''
);
}