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