nixpkgs/pkgs/development/tools/build-managers/bazel/bash-tools-test.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

45 lines
1.0 KiB
Nix
Raw Normal View History

{ writeText, bazel, runLocal, bazelTest, distDir, extraBazelArgs ? ""}:
2019-01-22 12:27:19 +00:00
# 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" {} ''
2019-01-22 12:27:19 +00:00
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 = ''
2023-10-19 21:43:36 +00:00
${bazel}/bin/bazel build :tool_usage --distdir=${distDir} ${extraBazelArgs}
2019-09-22 14:32:03 +00:00
cp bazel-bin/output.txt $out
echo "Testing content" && [ "$(cat $out | wc -l)" == "2" ] && echo "OK"
'';
};
2019-01-22 12:27:19 +00:00
in testBazel