core/pkgs/build-support/trivial-builders/test/write-shell-script.nix
2024-06-30 09:12:46 +01:00

20 lines
427 B
Nix

{ 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
'';
})