nixpkgs/pkgs/development/tools/build-managers/bazel/python-bin-path-test.nix
Profpatsch 629c050b5d 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.
2019-06-12 14:09:42 +02:00

53 lines
1018 B
Nix

{ stdenv, lib, writeText, bazel, bazelTest, runLocal }:
let
WORKSPACE = writeText "WORKSPACE" ''
workspace(name = "our_workspace")
'';
pythonLib = writeText "lib.py" ''
def foo():
return 43
'';
pythonBin = writeText "bin.py" ''
from lib import foo
assert foo() == 43
'';
pythonBUILD = writeText "BUILD" ''
py_library(
name = "lib",
srcs = [ "lib.py" ],
)
py_binary(
name = "bin",
srcs = [ "bin.py" ],
deps = [ ":lib" ],
)
'';
workspaceDir = runLocal "our_workspace" {} ''
mkdir $out
cp ${WORKSPACE} $out/WORKSPACE
mkdir $out/python
cp ${pythonLib} $out/python/lib.py
cp ${pythonBin} $out/python/bin.py
cp ${pythonBUILD} $out/python/BUILD.bazel
'';
testBazel = bazelTest {
name = "bazel-test-builtin-rules";
inherit workspaceDir;
bazelScript = ''
${bazel}/bin/bazel \
run \
--host_javabase='@local_jdk//:jdk' \
//python:bin
'';
};
in testBazel