diff --git a/e2e/binary/datasette/BUILD.bazel b/e2e/binary/datasette/BUILD.bazel index 9cf32e2b51d82964a651e4015edb7fe38950542d..b4c6b1c082d1e604215d548def16feabf0d104f8 100644 --- a/e2e/binary/datasette/BUILD.bazel +++ b/e2e/binary/datasette/BUILD.bazel @@ -1,11 +1,32 @@ -load("@bazel_skylib//rules:build_test.bzl", "build_test") +load("@bazel_skylib//rules:native_binary.bzl", "native_test") +load("@rules_python_pytest//python_pytest:defs.bzl", "py_pytest_test") -# TODO: write an _actual_ test for `datasette` +py_pytest_test( + name = "pytest", + size = "small", + srcs = ["python.py"], + data = [ + "hello.py", + "@ape//ape:datasette", + ], + deps = [ + "//binary:pytest", + ], +) -build_test( - name = "datasette", +native_test( + name = "version", size = "small", - tags = ["stub"], - targets = ["@ape//ape:datasette"], + src = "@ape//ape:datasette", + args = ["--version"], + visibility = ["//:__subpackages__"], +) + +test_suite( + name = "datasette", + tests = [ + "pytest", + "version", + ], visibility = ["//:__subpackages__"], ) diff --git a/e2e/binary/datasette/hello.py b/e2e/binary/datasette/hello.py new file mode 100644 index 0000000000000000000000000000000000000000..1d1fe875174881dba2ea9adcf37c5e373cb1c939 --- /dev/null +++ b/e2e/binary/datasette/hello.py @@ -0,0 +1,11 @@ +import sys + + +def main() -> int: + print("Hello!", end="") + + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/e2e/binary/datasette/python.py b/e2e/binary/datasette/python.py new file mode 100644 index 0000000000000000000000000000000000000000..21f063b0dd04e6dfb59df12a9532243086479539 --- /dev/null +++ b/e2e/binary/datasette/python.py @@ -0,0 +1,30 @@ +from __future__ import annotations + +from subprocess import PIPE, run + +from binary import Relative, Tool + + +def test_script(tool: Tool, relative: Relative) -> None: + binary = tool("datasette") + hello = relative("hello.py") + + cmd = (binary, hello) + r = run(cmd, check=True, timeout=30, stdout=PIPE, text=True) + + assert 0 == r.returncode + assert "Hello!" == r.stdout + + +def test_command(tool: Tool) -> None: + binary = tool("datasette") + + cmd = ( + binary, + "-c", + "print('Hello!', end='')", + ) + r = run(cmd, check=True, timeout=30, stdout=PIPE, text=True) + + assert 0 == r.returncode + assert "Hello!" == r.stdout diff --git a/e2e/binary/pypack1/BUILD.bazel b/e2e/binary/pypack1/BUILD.bazel index ec004a69adc043558bb837c0df9c5fef3adb2ba9..462efb247e74433c34285bab559a7c9075e2b0d6 100644 --- a/e2e/binary/pypack1/BUILD.bazel +++ b/e2e/binary/pypack1/BUILD.bazel @@ -1,11 +1,32 @@ -load("@bazel_skylib//rules:build_test.bzl", "build_test") +load("@bazel_skylib//rules:native_binary.bzl", "native_test") +load("@rules_python_pytest//python_pytest:defs.bzl", "py_pytest_test") -# TODO: write an _actual_ test for `pypack1` +py_pytest_test( + name = "pytest", + size = "small", + srcs = ["python.py"], + data = [ + "hello.py", + "@ape//ape:pypack1", + ], + deps = [ + "//binary:pytest", + ], +) -build_test( - name = "pypack1", +native_test( + name = "version", size = "small", - tags = ["stub"], - targets = ["@ape//ape:pypack1"], + src = "@ape//ape:pypack1", + args = ["--version"], + visibility = ["//:__subpackages__"], +) + +test_suite( + name = "pypack1", + tests = [ + "pytest", + "version", + ], visibility = ["//:__subpackages__"], ) diff --git a/e2e/binary/pypack1/hello.py b/e2e/binary/pypack1/hello.py new file mode 100644 index 0000000000000000000000000000000000000000..1d1fe875174881dba2ea9adcf37c5e373cb1c939 --- /dev/null +++ b/e2e/binary/pypack1/hello.py @@ -0,0 +1,11 @@ +import sys + + +def main() -> int: + print("Hello!", end="") + + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/e2e/binary/pypack1/python.py b/e2e/binary/pypack1/python.py new file mode 100644 index 0000000000000000000000000000000000000000..87b0d30657b52bea285b13d995ba63741badca31 --- /dev/null +++ b/e2e/binary/pypack1/python.py @@ -0,0 +1,30 @@ +from __future__ import annotations + +from subprocess import PIPE, run + +from binary import Relative, Tool + + +def test_script(tool: Tool, relative: Relative) -> None: + binary = tool("pypack1") + hello = relative("hello.py") + + cmd = (binary, hello) + r = run(cmd, check=True, timeout=30, stdout=PIPE, text=True) + + assert 0 == r.returncode + assert "Hello!" == r.stdout + + +def test_command(tool: Tool) -> None: + binary = tool("pypack1") + + cmd = ( + binary, + "-c", + "print('Hello!', end='')", + ) + r = run(cmd, check=True, timeout=30, stdout=PIPE, text=True) + + assert 0 == r.returncode + assert "Hello!" == r.stdout diff --git a/e2e/binary/pypack2/BUILD.bazel b/e2e/binary/pypack2/BUILD.bazel index e88a983707172712dcd5184fc029a311f6bc6f5a..325bca7e3657981d053dea4184fd43ffdd4a80a5 100644 --- a/e2e/binary/pypack2/BUILD.bazel +++ b/e2e/binary/pypack2/BUILD.bazel @@ -1,11 +1,32 @@ -load("@bazel_skylib//rules:build_test.bzl", "build_test") +load("@bazel_skylib//rules:native_binary.bzl", "native_test") +load("@rules_python_pytest//python_pytest:defs.bzl", "py_pytest_test") -# TODO: write an _actual_ test for `pypack2` +py_pytest_test( + name = "pytest", + size = "small", + srcs = ["python.py"], + data = [ + "hello.py", + "@ape//ape:pypack2", + ], + deps = [ + "//binary:pytest", + ], +) -build_test( - name = "pypack2", +native_test( + name = "version", size = "small", - tags = ["stub"], - targets = ["@ape//ape:pypack2"], + src = "@ape//ape:pypack2", + args = ["--version"], + visibility = ["//:__subpackages__"], +) + +test_suite( + name = "pypack2", + tests = [ + "pytest", + "version", + ], visibility = ["//:__subpackages__"], ) diff --git a/e2e/binary/pypack2/hello.py b/e2e/binary/pypack2/hello.py new file mode 100644 index 0000000000000000000000000000000000000000..1d1fe875174881dba2ea9adcf37c5e373cb1c939 --- /dev/null +++ b/e2e/binary/pypack2/hello.py @@ -0,0 +1,11 @@ +import sys + + +def main() -> int: + print("Hello!", end="") + + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/e2e/binary/pypack2/python.py b/e2e/binary/pypack2/python.py new file mode 100644 index 0000000000000000000000000000000000000000..0e1cb389871d314a6ac3fb2155a3ab457979f1f4 --- /dev/null +++ b/e2e/binary/pypack2/python.py @@ -0,0 +1,30 @@ +from __future__ import annotations + +from subprocess import PIPE, run + +from binary import Relative, Tool + + +def test_script(tool: Tool, relative: Relative) -> None: + binary = tool("pypack2") + hello = relative("hello.py") + + cmd = (binary, hello) + r = run(cmd, check=True, timeout=30, stdout=PIPE, text=True) + + assert 0 == r.returncode + assert "Hello!" == r.stdout + + +def test_command(tool: Tool) -> None: + binary = tool("pypack2") + + cmd = ( + binary, + "-c", + "print('Hello!', end='')", + ) + r = run(cmd, check=True, timeout=30, stdout=PIPE, text=True) + + assert 0 == r.returncode + assert "Hello!" == r.stdout