lock: 1.3.0 -> 1.3.4 (#364295)
[NixPkgs.git] / pkgs / build-support / trivial-builders / test / writeShellScriptBin.nix
blob94d09473ee9f80e46b52b344a77ed7330b24436e
1 /*
2   Run with:
4       cd nixpkgs
5       nix-build -A tests.trivial-builders.writeShellScriptBin
6 */
9   lib,
10   writeShellScriptBin,
11   runCommand,
13 let
14   output = "hello";
15   pkg = writeShellScriptBin "test-script" ''
16     echo ${lib.escapeShellArg output}
17   '';
19 assert pkg.meta.mainProgram == "test-script";
20 runCommand "test-writeShellScriptBin" { } ''
22   echo Testing with getExe...
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
32   echo Testing with makeBinPath...
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
41   touch $out