1{ writeText, bazel, bazelTest, runLocal, distDir }:
2
3let
4 WORKSPACE = writeText "WORKSPACE" ''
5 workspace(name = "our_workspace")
6 '';
7
8 pythonLib = writeText "lib.py" ''
9 def foo():
10 return 43
11 '';
12
13 pythonBin = writeText "bin.py" ''
14 from lib import foo
15
16 assert foo() == 43
17 '';
18
19 pythonBUILD = writeText "BUILD" ''
20 py_library(
21 name = "lib",
22 srcs = [ "lib.py" ],
23 )
24
25 py_binary(
26 name = "bin",
27 srcs = [ "bin.py" ],
28 deps = [ ":lib" ],
29 )
30 '';
31
32 workspaceDir = runLocal "our_workspace" {} ''
33 mkdir $out
34 cp ${WORKSPACE} $out/WORKSPACE
35 mkdir $out/python
36 cp ${pythonLib} $out/python/lib.py
37 cp ${pythonBin} $out/python/bin.py
38 cp ${pythonBUILD} $out/python/BUILD.bazel
39 '';
40
41 testBazel = bazelTest {
42 name = "bazel-test-builtin-rules";
43 inherit workspaceDir;
44 bazelPkg = bazel;
45 bazelScript = ''
46 ${bazel}/bin/bazel \
47 run \
48 --distdir=${distDir} \
49 //python:bin
50 '';
51 };
52
53in testBazel