nixpkgs/pkgs/development/tools/build-managers/bazel/bash-tools-test.nix
Guillaume Bouchard 67904dccbb bazel: 0.28.1 -> 0.29.0
- Upgraded dependencies
  - dependencies script upgraded to take into account new WORKSPACE
    rules
- Tests now depends on the `distdir`

Runtime bazel now also depends on the `distdir` setting which appears
in the global configuration file. This increases the bazel closure
size by 85 MO for stuffs which can normally be downloaded at runtime
by bazel. However, any invocation of `buildBazelPackage` (such as in
`bazel-watcher`) may fail in nix sandbox if theses files are not
available at runtime.

If this overhead is too important, we may later evolve to a finer
grained solution, where buildBazelPackage declares the list of
necessary dependencies.
2019-09-03 13:12:53 +02:00

45 lines
1021 B
Nix

{ writeText, bazel, runLocal, bazelTest, distDir }:
# Tests that certain executables are available in bazel-executed bash shells.
let
WORKSPACE = writeText "WORKSPACE" ''
workspace(name = "our_workspace")
'';
fileIn = writeText "input.txt" ''
one
two
three
'';
fileBUILD = writeText "BUILD" ''
genrule(
name = "tool_usage",
srcs = [ ":input.txt" ],
outs = [ "output.txt" ],
cmd = "cat $(location :input.txt) | gzip - | gunzip - | awk '/t/' > $@",
)
'';
workspaceDir = runLocal "our_workspace" {} ''
mkdir $out
cp ${WORKSPACE} $out/WORKSPACE
cp ${fileIn} $out/input.txt
cp ${fileBUILD} $out/BUILD
'';
testBazel = bazelTest {
name = "bazel-test-bash-tools";
bazelPkg = bazel;
inherit workspaceDir;
bazelScript = ''
${bazel}/bin/bazel build :tool_usage --distdir=${distDir}
cp bazel-genfiles/output.txt $out
echo "Testing content" && [ "$(cat $out | wc -l)" == "2" ] && echo "OK"
'';
};
in testBazel