core/pkgs/build-support/trivial-builders/test/write-shell-script.nix

20 lines
427 B
Nix
Raw Normal View History

2024-06-30 08:16:52 +00:00
{ lib, writeShellScript }:
let
2024-05-02 00:46:19 +00:00
output = "hello";
2024-06-30 08:16:52 +00:00
in
(writeShellScript "test-script" ''
2024-05-02 00:46:19 +00:00
echo ${lib.escapeShellArg output}
2024-06-30 08:16:52 +00:00
'').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
'';
})