diff options
author | Naïm Favier <n@monade.li> | 2023-03-29 14:06:45 +0200 |
---|---|---|
committer | Naïm Favier <n@monade.li> | 2023-03-29 14:06:45 +0200 |
commit | e6f19ea4295df7d4a05c1c122962309f5e6fca70 (patch) | |
tree | fc2c43cbb6c34116c7789725acd03958424c336d /pkgs/build-support/trivial-builders | |
parent | 9973b3ec30e07dade936b1f0bfd084c5ec0596be (diff) |
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.
Diffstat (limited to 'pkgs/build-support/trivial-builders')
-rw-r--r-- | pkgs/build-support/trivial-builders/test/write-shell-script.nix | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/pkgs/build-support/trivial-builders/test/write-shell-script.nix b/pkgs/build-support/trivial-builders/test/write-shell-script.nix new file mode 100644 index 0000000000000..a5c9f1fae42f6 --- /dev/null +++ b/pkgs/build-support/trivial-builders/test/write-shell-script.nix @@ -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 + ''; +}) |