bazel.tests: prebuild the bazel self-extraction to speed up test

Factor out the common parts of tests & cache the bazel
self-extraction (ugh) to a common store path.
This commit is contained in:
Profpatsch
2019-06-12 14:09:42 +02:00
parent 44f97b56d9
commit 629c050b5d
3 changed files with 83 additions and 33 deletions
@@ -1,4 +1,4 @@
{ stdenv, lib, writeText, runCommandCC, bazel }:
{ stdenv, lib, writeText, bazel, bazelTest, runLocal }:
let
WORKSPACE = writeText "WORKSPACE" ''
@@ -29,9 +29,7 @@ let
)
'';
runLocal = name: script: runCommandCC name { preferLocalBuild = true; } script;
workspaceDir = runLocal "our_workspace" ''
workspaceDir = runLocal "our_workspace" {} ''
mkdir $out
cp ${WORKSPACE} $out/WORKSPACE
mkdir $out/python
@@ -40,17 +38,15 @@ let
cp ${pythonBUILD} $out/python/BUILD.bazel
'';
testBazel = runLocal "bazel-test-builtin-rules" ''
export HOME=$(mktemp -d)
# Note https://github.com/bazelbuild/bazel/issues/5763#issuecomment-456374609
# about why to create a subdir for the workspace.
cp -r ${workspaceDir} wd && chmod u+w wd && cd wd
${bazel}/bin/bazel \
run \
--host_javabase='@local_jdk//:jdk' \
//python:bin
touch $out
'';
testBazel = bazelTest {
name = "bazel-test-builtin-rules";
inherit workspaceDir;
bazelScript = ''
${bazel}/bin/bazel \
run \
--host_javabase='@local_jdk//:jdk' \
//python:bin
'';
};
in testBazel