Skip to content

Commit 5225b00

Browse files
authored
tests.replaceVars.replaceVarsWith: fix (NixOS#375620)
2 parents 002e317 + d07168d commit 5225b00

File tree

1 file changed

+34
-22
lines changed

1 file changed

+34
-22
lines changed

pkgs/test/replace-vars/default.nix

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ let
1111
inherit (testers) testEqualContents testBuildFailure;
1212

1313
mkTests =
14-
callReplaceVars:
14+
callReplaceVars: mkExpectation:
1515
lib.recurseIntoAttrs {
1616
succeeds = testEqualContents {
1717
assertion = "replaceVars-succeeds";
@@ -21,13 +21,15 @@ let
2121
brotherhood = "shared humanity";
2222
};
2323

24-
expected = builtins.toFile "expected" ''
25-
All human beings are born free and are the same in dignity and rights.
26-
They are endowed with reason and conscience and should act towards
27-
one another in a spirit of shared humanity.
24+
expected = mkExpectation (
25+
builtins.toFile "source.txt" ''
26+
All human beings are born free and are the same in dignity and rights.
27+
They are endowed with reason and conscience and should act towards
28+
one another in a spirit of shared humanity.
2829
29-
30-
'';
30+
31+
''
32+
);
3133
};
3234

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

86-
expected = builtins.toFile "expected" ''
87-
All human beings are born free and are the same in dignity and rights.
88-
They are endowed with reason and conscience and should act towards
89-
one another in a spirit of @brotherhood@.
88+
expected = mkExpectation (
89+
builtins.toFile "source.txt" ''
90+
All human beings are born free and are the same in dignity and rights.
91+
They are endowed with reason and conscience and should act towards
92+
one another in a spirit of @brotherhood@.
9093
91-
92-
'';
94+
95+
''
96+
);
9397
};
9498

9599
fails-in-check-phase-with-exemption =
@@ -120,13 +124,21 @@ let
120124
};
121125
in
122126
{
123-
replaceVars = mkTests replaceVars;
124-
replaceVarsWith = mkTests (
125-
src: replacements:
126-
replaceVarsWith {
127-
inherit src replacements;
128-
dir = "bin";
129-
isExecutable = true;
130-
}
131-
);
127+
replaceVars = mkTests replaceVars lib.id;
128+
replaceVarsWith =
129+
mkTests
130+
(
131+
src: replacements:
132+
replaceVarsWith {
133+
inherit src replacements;
134+
dir = "bin";
135+
isExecutable = true;
136+
}
137+
)
138+
(
139+
file:
140+
runCommand "expected" { inherit file; } ''
141+
install -Dm755 "$file" "$out/bin/$(stripHash "$file")"
142+
''
143+
);
132144
}

0 commit comments

Comments
 (0)