mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-11-13 09:17:07 +03:00
writeTextFile: chmod before checkPhase
Set the executable bit before running the check phase, so that the check phase can run the script to test its behaviour. This aligns with what `concatTextFile` is doing. Also use explicit `if` statements so that we don't silently ignore `chmod` failures.
This commit is contained in:
parent
9973b3ec30
commit
e6f19ea429
@ -150,9 +150,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"
|
||||
'';
|
||||
|
||||
/*
|
||||
@ -411,7 +413,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"
|
||||
'';
|
||||
|
||||
|
@ -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
|
||||
'';
|
||||
})
|
@ -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 {};
|
||||
|
Loading…
Reference in New Issue
Block a user