diff --git a/e2e/binary/bc/BUILD.bazel b/e2e/binary/bc/BUILD.bazel index a8f7850e4bd126466d089f4e5160b5646ba8b93b..6d937132b7f53c8b0606494dba2deb56c835c15a 100644 --- a/e2e/binary/bc/BUILD.bazel +++ b/e2e/binary/bc/BUILD.bazel @@ -1,11 +1,32 @@ -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 `bc` +py_pytest_test( + name = "pytest", + size = "small", + srcs = ["calculate.py"], + data = [ + "@ape//ape:bc", + "fixture.txt", + "expected.txt", + ], + deps = [ + "//binary:pytest" + ], +) -build_test( - name = "bc", +native_test( + name = "version", size = "small", - tags = ["stub"], - targets = ["@ape//ape:bc"], + src = "@ape//ape:bc", + visibility = ["//:__subpackages__"], +) + +test_suite( + name = "bc", + tests = [ + "pytest", + "version", + ], visibility = ["//:__subpackages__"], ) diff --git a/e2e/binary/bc/calculate.py b/e2e/binary/bc/calculate.py new file mode 100644 index 0000000000000000000000000000000000000000..a08c23c574a7679e15545fd435043780416642e3 --- /dev/null +++ b/e2e/binary/bc/calculate.py @@ -0,0 +1,19 @@ +from __future__ import annotations + +from pathlib import Path +from subprocess import run + +from binary import Tool, Relative, Diff + + +def test_copy(tool: Tool, relative: Relative, tmp_path: Path) -> None: + binary = tool("bc") + fixture = relative("fixture.txt") + expected = relative("expected.txt") + output = tmp_path / "output.txt" + + cmd = (binary, fixture) + with open(output, "w") as stream: + run(cmd, check=True, timeout=30, stdout=stream) + + assert Diff(expected) == Diff(output) diff --git a/e2e/binary/bc/expected.txt b/e2e/binary/bc/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..60d3b2f4a4cd5f1637eba020358bfe5ecb5edcf2 --- /dev/null +++ b/e2e/binary/bc/expected.txt @@ -0,0 +1 @@ +15 diff --git a/e2e/binary/bc/fixture.txt b/e2e/binary/bc/fixture.txt new file mode 100644 index 0000000000000000000000000000000000000000..701bda205741402d53ad9c96a1d45a544d049025 --- /dev/null +++ b/e2e/binary/bc/fixture.txt @@ -0,0 +1 @@ +5 + 10