Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{
2 writeText,
3 bazel,
4 runLocal,
5 bazelTest,
6 distDir,
7 extraBazelArgs ? "",
8}:
9
10# Tests that certain executables are available in bazel-executed bash shells.
11
12let
13 WORKSPACE = writeText "WORKSPACE" ''
14 workspace(name = "our_workspace")
15 '';
16
17 fileIn = writeText "input.txt" ''
18 one
19 two
20 three
21 '';
22
23 fileBUILD = writeText "BUILD" ''
24 genrule(
25 name = "tool_usage",
26 srcs = [ ":input.txt" ],
27 outs = [ "output.txt" ],
28 cmd = "cat $(location :input.txt) | gzip - | gunzip - | awk '/t/' > $@",
29 )
30 '';
31
32 workspaceDir = runLocal "our_workspace" { } ''
33 mkdir $out
34 cp ${WORKSPACE} $out/WORKSPACE
35 cp ${fileIn} $out/input.txt
36 cp ${fileBUILD} $out/BUILD
37 '';
38
39 testBazel = bazelTest {
40 name = "bazel-test-bash-tools";
41 bazelPkg = bazel;
42 inherit workspaceDir;
43
44 bazelScript = ''
45 ${bazel}/bin/bazel build :tool_usage --distdir=${distDir} ${extraBazelArgs}
46 cp bazel-bin/output.txt $out
47 echo "Testing content" && [ "$(cat $out | wc -l)" == "2" ] && echo "OK"
48 '';
49 };
50
51in
52testBazel