diff --git a/e2e/binary/kill/grim.py b/e2e/binary/kill/grim.py index 684c3aa3c6583728adb99c38fb376af82b319679..a9abe5f5eade00adfadb31a18b2494a19e8c45e4 100644 --- a/e2e/binary/kill/grim.py +++ b/e2e/binary/kill/grim.py @@ -7,11 +7,11 @@ from binary import Tool def test_kill(tool: Tool) -> None: - tool = tool("kill") + binary = tool("kill") process = Popen((executable, "-c", "from time import sleep; sleep(5)")) - run((tool, f"{process.pid}"), check=True) + run((binary, f"{process.pid}"), check=True) try: process.wait(timeout=1) diff --git a/e2e/binary/lua/lua.py b/e2e/binary/lua/lua.py index 567fc24b5b8e3b764cc685d84a01bcecba794672..66a4569466949eb8aeb89b1627a3f39f8f957887 100644 --- a/e2e/binary/lua/lua.py +++ b/e2e/binary/lua/lua.py @@ -7,12 +7,12 @@ from binary import Diff, Relative, Tool def test_roundtrip(tool: Tool, relative: Relative, tmp_path: Path) -> None: - tool = tool("lua") + binary = tool("lua") fixture = relative("fixture.lua") expected = relative("expected.txt") output = tmp_path / "output.txt" - cmd = (tool, fixture) + cmd = (binary, fixture) with open(output, "w") as stream: run(cmd, check=True, stdout=stream) diff --git a/e2e/binary/numfmt/format.py b/e2e/binary/numfmt/format.py index 2402011025d3bdbead5b609845f1b2be04a5eaec..05925116cf49ea1ad901f772b6a289697104d879 100644 --- a/e2e/binary/numfmt/format.py +++ b/e2e/binary/numfmt/format.py @@ -6,8 +6,8 @@ from binary import Tool def test_format(tool: Tool) -> None: - tool = tool("numfmt") - cmd = (tool, "--to=si", "1000") + binary = tool("numfmt") + cmd = (binary, "--to=si", "1000") r = run(cmd, stdout=PIPE, encoding="utf8") assert r.returncode == 0, r.stdout assert r.stdout.rstrip() == "1.0K" diff --git a/e2e/binary/od/convert.py b/e2e/binary/od/convert.py index 8192ab38c875b15825003aa2310385a38dd7687a..338c08f1448aaf22e347d0fff22aa827f1c0d18c 100644 --- a/e2e/binary/od/convert.py +++ b/e2e/binary/od/convert.py @@ -7,12 +7,12 @@ from binary import Diff, Relative, Tool def test_convert(tool: Tool, relative: Relative, tmp_path: Path) -> None: - tool = tool("od") + binary = tool("od") fixture = relative("fixture.txt") expected = relative("expected.txt") output = tmp_path / "output.txt" - cmd = (tool, f"{fixture}") + cmd = (binary, f"{fixture}") with output.open("w") as stream: run(cmd, check=True, stdout=stream) diff --git a/e2e/binary/printenv/BUILD.bazel b/e2e/binary/printenv/BUILD.bazel index c4c3e7e325cd0727cb00c104caab9d761d258efd..0110dc896701bd83db39a47f01f8c2a597545ccf 100644 --- a/e2e/binary/printenv/BUILD.bazel +++ b/e2e/binary/printenv/BUILD.bazel @@ -1,11 +1,30 @@ -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 `printenv` +py_pytest_test( + name = "pytest", + size = "small", + srcs = ["print.py"], + data = [ + "@ape//ape:printenv", + ], + deps = [ + "//binary:pytest", + ], +) -build_test( - name = "printenv", +native_test( + name = "version", size = "small", - tags = ["stub"], - targets = ["@ape//ape:printenv"], + src = "@ape//ape:printenv", + args = ["--version"], +) + +test_suite( + name = "printenv", + tests = [ + "pytest", + "version", + ], visibility = ["//:__subpackages__"], ) diff --git a/e2e/binary/printenv/print.py b/e2e/binary/printenv/print.py new file mode 100644 index 0000000000000000000000000000000000000000..87a9569de0aeef961ce080b1d80353531dc00f67 --- /dev/null +++ b/e2e/binary/printenv/print.py @@ -0,0 +1,15 @@ +from __future__ import annotations + +from subprocess import run + +from binary import Tool + + +def test_copy(tool: Tool) -> None: + binary = tool("printenv") + + cmd = (binary,) + env = {"TEST": "1"} + r = run(cmd, timeout=30, capture_output=True, text=True, env=env) + assert r.returncode == 0 + assert r.stdout.rstrip() == "TEST=1"