lol
1/*
2 Run with:
3
4 cd nixpkgs
5 nix-build -A tests.trivial-builders.writeShellScriptBin
6*/
7
8{
9 lib,
10 writeShellScriptBin,
11 runCommand,
12}:
13let
14 output = "hello";
15 pkg = writeShellScriptBin "test-script" ''
16 echo ${lib.escapeShellArg output}
17 '';
18in
19assert pkg.meta.mainProgram == "test-script";
20runCommand "test-writeShellScriptBin" { } ''
21
22 echo Testing with getExe...
23
24 target=${lib.getExe pkg}
25 expected=${lib.escapeShellArg output}
26 got=$("$target")
27 if [[ "$got" != "$expected" ]]; then
28 echo "wrong output: expected $expected, got $got"
29 exit 1
30 fi
31
32 echo Testing with makeBinPath...
33
34 PATH="${lib.makeBinPath [ pkg ]}:$PATH"
35 got=$(test-script)
36 if [[ "$got" != "$expected" ]]; then
37 echo "wrong output: expected $expected, got $got"
38 exit 1
39 fi
40
41 touch $out
42''