2024-05-02 00:46:19 +00:00
|
|
|
/*
|
|
|
|
Run with:
|
|
|
|
|
|
|
|
cd nixpkgs
|
|
|
|
nix-build -A tests.trivial-builders.writeShellScriptBin
|
|
|
|
*/
|
|
|
|
|
|
|
|
{
|
|
|
|
lib,
|
|
|
|
writeShellScriptBin,
|
|
|
|
runCommand,
|
|
|
|
}:
|
|
|
|
let
|
|
|
|
output = "hello";
|
|
|
|
pkg = writeShellScriptBin "test-script" ''
|
|
|
|
echo ${lib.escapeShellArg output}
|
|
|
|
'';
|
|
|
|
in
|
|
|
|
assert pkg.meta.mainProgram == "test-script";
|
|
|
|
runCommand "test-writeShellScriptBin" { } ''
|
2024-06-30 08:12:46 +00:00
|
|
|
|
2024-05-02 00:46:19 +00:00
|
|
|
echo Testing with getExe...
|
2024-06-30 08:12:46 +00:00
|
|
|
|
2024-05-02 00:46:19 +00:00
|
|
|
target=${lib.getExe pkg}
|
|
|
|
expected=${lib.escapeShellArg output}
|
|
|
|
got=$("$target")
|
|
|
|
if [[ "$got" != "$expected" ]]; then
|
|
|
|
echo "wrong output: expected $expected, got $got"
|
|
|
|
exit 1
|
|
|
|
fi
|
2024-06-30 08:12:46 +00:00
|
|
|
|
2024-05-02 00:46:19 +00:00
|
|
|
echo Testing with makeBinPath...
|
2024-06-30 08:12:46 +00:00
|
|
|
|
2024-05-02 00:46:19 +00:00
|
|
|
PATH="${lib.makeBinPath [ pkg ]}:$PATH"
|
|
|
|
got=$(test-script)
|
|
|
|
if [[ "$got" != "$expected" ]]; then
|
|
|
|
echo "wrong output: expected $expected, got $got"
|
|
|
|
exit 1
|
|
|
|
fi
|
2024-06-30 08:12:46 +00:00
|
|
|
|
2024-05-02 00:46:19 +00:00
|
|
|
touch $out
|
|
|
|
''
|