Skip to content

Commit

Permalink
Add test for py_pex_binary
Browse files Browse the repository at this point in the history
  • Loading branch information
ekfeet committed Sep 17, 2024
1 parent 69dd957 commit e1c3618
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
33 changes: 33 additions & 0 deletions py/tests/py-pex-binary/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
load("@aspect_bazel_lib//lib:testing.bzl", "assert_contains")
load("//py:defs.bzl", "py_binary", "py_pex_binary")

# Test that both single-file modules (six) and multi-file modules (cowsay) work with py_pex_binary.
py_binary(
name = "print_modules_bin",
srcs = ["print_modules.py"],
data = ["data.txt"],
deps = [
"@bazel_tools//tools/python/runfiles",
"@pypi_cowsay//:pkg",
"@pypi_six//:pkg",
],
)

py_pex_binary(
name = "print_modules_pex",
binary = ":print_modules_bin",
)

# PEX_ROOT is set to avoid warning on default user PEX_ROOT not being writable
genrule(
name = "run_print_modules_pex",
outs = ["print_modules_pex.out"],
cmd = "PEX_ROOT=.pex $(execpath print_modules_pex) >$@",
tools = ["print_modules_pex"],
)

assert_contains(
name = "test__print_modules_pex",
actual = "print_modules_pex.out",
expected = "Mooo!,cowsay-6.1/cowsay/__init__.py,six-1.16.0/six.py",
)
1 change: 1 addition & 0 deletions py/tests/py-pex-binary/data.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Mooo!
1 change: 1 addition & 0 deletions requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ pytest
cowsay
ftfy==6.2.0
neptune==1.10.2
six
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,7 @@ six==1.16.0 \
--hash=sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926 \
--hash=sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254
# via
# -r requirements.in
# bravado
# bravado-core
# neptune
Expand Down

0 comments on commit e1c3618

Please sign in to comment.