bitwarden-desktop: 2024.12.0 -> 2024.12.1 (#373177)
[NixPkgs.git] / pkgs / build-support / trivial-builders / test / writeCBin.nix
blob9d6dc3433f198fb8d0de18c6c480c8e89df61beb
1 /*
2   Run with:
4       cd nixpkgs
5       nix-build -A tests.trivial-builders.writeCBin
6 */
9   lib,
10   writeCBin,
11   runCommand,
13 let
14   output = "hello";
15   pkg = writeCBin "test-script" ''
16     #include <stdio.h>
17     int main () {
18       printf("hello\n");
19       return 0;
20     }
21   '';
23 assert pkg.meta.mainProgram == "test-script";
24 runCommand "test-writeCBin" { } ''
26   echo Testing with getExe...
28   target=${lib.getExe pkg}
29   expected=${lib.escapeShellArg output}
30   got=$("$target")
31   if [[ "$got" != "$expected" ]]; then
32     echo "wrong output: expected $expected, got $got"
33     exit 1
34   fi
36   echo Testing with makeBinPath...
38   PATH="${lib.makeBinPath [ pkg ]}:$PATH"
39   got=$(test-script)
40   if [[ "$got" != "$expected" ]]; then
41     echo "wrong output: expected $expected, got $got"
42     exit 1
43   fi
45   touch $out