nixpkgs/pkgs/development/tools/build-managers/bazel/python-bin-path-test.nix
Guillaume Bouchard 67904dccbb bazel: 0.28.1 -> 0.29.0
- Upgraded dependencies
  - dependencies script upgraded to take into account new WORKSPACE
    rules
- Tests now depends on the `distdir`

Runtime bazel now also depends on the `distdir` setting which appears
in the global configuration file. This increases the bazel closure
size by 85 MO for stuffs which can normally be downloaded at runtime
by bazel. However, any invocation of `buildBazelPackage` (such as in
`bazel-watcher`) may fail in nix sandbox if theses files are not
available at runtime.

If this overhead is too important, we may later evolve to a finer
grained solution, where buildBazelPackage declares the list of
necessary dependencies.
2019-09-03 13:12:53 +02:00

54 lines
1,018 B
Nix

{ writeText, bazel, bazelTest, runLocal, distDir }:
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;
bazelPkg = bazel;
bazelScript = ''
${bazel}/bin/bazel \
run \
--distdir=${distDir} \
//python:bin
'';
};
in testBazel