2019-08-30 17:05:26 +02:00
|
|
|
{ writeText, bazel, runLocal, bazelTest, distDir }:
|
2019-01-22 13:27:19 +01: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/' > $@",
|
|
|
|
)
|
|
|
|
'';
|
|
|
|
|
2019-06-11 21:43:53 +02:00
|
|
|
workspaceDir = runLocal "our_workspace" {} ''
|
2019-01-22 13:27:19 +01:00
|
|
|
mkdir $out
|
|
|
|
cp ${WORKSPACE} $out/WORKSPACE
|
|
|
|
cp ${fileIn} $out/input.txt
|
|
|
|
cp ${fileBUILD} $out/BUILD
|
|
|
|
'';
|
|
|
|
|
2019-06-11 21:43:53 +02:00
|
|
|
testBazel = bazelTest {
|
|
|
|
name = "bazel-test-bash-tools";
|
2019-06-13 16:12:38 +02:00
|
|
|
bazelPkg = bazel;
|
2019-06-11 21:43:53 +02:00
|
|
|
inherit workspaceDir;
|
|
|
|
|
|
|
|
bazelScript = ''
|
2019-08-30 17:05:26 +02:00
|
|
|
${bazel}/bin/bazel build :tool_usage --distdir=${distDir}
|
2019-09-22 16:32:03 +02:00
|
|
|
cp bazel-bin/output.txt $out
|
2019-06-11 21:43:53 +02:00
|
|
|
echo "Testing content" && [ "$(cat $out | wc -l)" == "2" ] && echo "OK"
|
|
|
|
'';
|
|
|
|
};
|
2019-01-22 13:27:19 +01:00
|
|
|
|
|
|
|
in testBazel
|