2019-06-16 20:59:06 +01:00
|
|
|
{ writeText, bazel, bazelTest, runLocal }:
|
2019-01-15 14:14:33 +00:00
|
|
|
|
|
|
|
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" ],
|
|
|
|
)
|
|
|
|
|
2019-06-11 19:10:03 +01:00
|
|
|
py_binary(
|
2019-01-15 14:14:33 +00:00
|
|
|
name = "bin",
|
|
|
|
srcs = [ "bin.py" ],
|
|
|
|
deps = [ ":lib" ],
|
|
|
|
)
|
|
|
|
'';
|
|
|
|
|
2019-06-11 20:43:53 +01:00
|
|
|
workspaceDir = runLocal "our_workspace" {} ''
|
2019-01-15 14:14:33 +00:00
|
|
|
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
|
|
|
|
'';
|
|
|
|
|
2019-06-11 20:43:53 +01:00
|
|
|
testBazel = bazelTest {
|
|
|
|
name = "bazel-test-builtin-rules";
|
|
|
|
inherit workspaceDir;
|
2019-06-13 15:12:38 +01:00
|
|
|
bazelPkg = bazel;
|
2019-06-11 20:43:53 +01:00
|
|
|
bazelScript = ''
|
|
|
|
${bazel}/bin/bazel \
|
|
|
|
run \
|
|
|
|
//python:bin
|
|
|
|
'';
|
|
|
|
};
|
2019-01-15 14:14:33 +00:00
|
|
|
|
|
|
|
in testBazel
|