diff --git a/e2e/binary/sum/BUILD.bazel b/e2e/binary/sum/BUILD.bazel index 60c1d1fa86b7cc85fa071a2dbf0d9de661e82aaf..cf42fdaed1672303d5f19208b050a63e4c2e0017 100644 --- a/e2e/binary/sum/BUILD.bazel +++ b/e2e/binary/sum/BUILD.bazel @@ -1,11 +1,30 @@ -load("@bazel_skylib//rules:build_test.bzl", "build_test") +load("@rules_python_pytest//python_pytest:defs.bzl", "py_pytest_test") +load("@bazel_skylib//rules:native_binary.bzl", "native_test") -# TODO: write an _actual_ test for `sum` +py_pytest_test( + name = "pytest", + size = "small", + srcs = ["sum.py"], + data = [ + "@ape//ape:sum", + ], + deps = [ + "//binary:pytest", + ], +) -build_test( - name = "sum", +native_test( + name = "version", size = "small", - tags = ["stub"], - targets = ["@ape//ape:sum"], + src = "@ape//ape:sum", + args = ["--version"], +) + +test_suite( + name = "sum", + tests = [ + "pytest", + "version", + ], visibility = ["//:__subpackages__"], ) diff --git a/e2e/binary/sum/sum.py b/e2e/binary/sum/sum.py new file mode 100644 index 0000000000000000000000000000000000000000..9264550b6282460a00028a868124ba47c7acb8b3 --- /dev/null +++ b/e2e/binary/sum/sum.py @@ -0,0 +1,21 @@ +from __future__ import annotations + +from subprocess import run +from pathlib import Path + +from binary.tool import Tool + + +def test_sum(tool: Tool, tmp_path: Path) -> None: + binary = tool("sum") + input_path = tmp_path / "input_file" + + with open(input_path, "w") as file: + file.write("hello") + cmd = (binary, input_path) + result = run(cmd, check=True, timeout=30, capture_output=True, text=True) + + # Remove path from output + actual = result.stdout.rsplit(" ", 1)[0] + expected = "08403 1" + assert actual == expected