Merge #223741: writeTextFile: chmod before checkPhase

...into staging
This commit is contained in:
Vladimír Čunát 2023-04-04 08:57:05 +02:00
commit 87a8a597e6
No known key found for this signature in database
GPG Key ID: E747DF1F9575A3AA
3 changed files with 23 additions and 3 deletions

View File

@ -149,9 +149,11 @@ rec {
echo -n "$text" > "$target"
fi
eval "$checkPhase"
if [ -n "$executable" ]; then
chmod +x "$target"
fi
(test -n "$executable" && chmod +x "$target") || true
eval "$checkPhase"
'';
/*
@ -412,7 +414,10 @@ rec {
mkdir -p "$(dirname "$file")"
cat $files > "$file"
(test -n "$executable" && chmod +x "$file") || true
if [ -n "$executable" ]; then
chmod +x "$file"
fi
eval "$checkPhase"
'';

View File

@ -0,0 +1,14 @@
{ lib, writeShellScript }: let
output = "hello";
in (writeShellScript "test-script" ''
echo ${lib.escapeShellArg output}
'').overrideAttrs (old: {
checkPhase = old.checkPhase or "" + ''
expected=${lib.escapeShellArg output}
got=$("$target")
if [[ "$got" != "$expected" ]]; then
echo "wrong output: expected $expected, got $got"
exit 1
fi
'';
})

View File

@ -70,6 +70,7 @@ with pkgs;
trivial-builders = recurseIntoAttrs {
writeStringReferencesToFile = callPackage ../build-support/trivial-builders/test/writeStringReferencesToFile.nix {};
writeTextFile = callPackage ../build-support/trivial-builders/test/write-text-file.nix {};
writeShellScript = callPackage ../build-support/trivial-builders/test/write-shell-script.nix {};
references = callPackage ../build-support/trivial-builders/test/references.nix {};
overriding = callPackage ../build-support/trivial-builders/test-overriding.nix {};
concat = callPackage ../build-support/trivial-builders/test/concat-test.nix {};