biome: 1.9.2 -> 1.9.3
[NixPkgs.git] / pkgs / build-support / trivial-builders / test / writeScriptBin.nix
blob1487443130dab9a821caddae806f0f44b9b85e12
1 /*
2   Run with:
4       cd nixpkgs
5       nix-build -A tests.trivial-builders.writeShellScriptBin
6 */
8 { lib, writeScriptBin, runCommand }:
9 let
10   output = "hello";
11   pkg = writeScriptBin "test-script" ''
12     echo ${lib.escapeShellArg output}
13   '';
15   assert pkg.meta.mainProgram == "test-script";
16   runCommand "test-writeScriptBin" { } ''
18     echo Testing with getExe...
20     target=${lib.getExe pkg}
21     expected=${lib.escapeShellArg output}
22     got=$("$target")
23     if [[ "$got" != "$expected" ]]; then
24       echo "wrong output: expected $expected, got $got"
25       exit 1
26     fi
28     echo Testing with makeBinPath...
30     PATH="${lib.makeBinPath [ pkg ]}:$PATH"
31     got=$(test-script)
32     if [[ "$got" != "$expected" ]]; then
33       echo "wrong output: expected $expected, got $got"
34       exit 1
35     fi
37     touch $out
38   ''