diff --git a/e2e/binary/yes/BUILD.bazel b/e2e/binary/yes/BUILD.bazel index e9605cc491c74b1d4be91d6bf0d4edd0ed14d3e8..2f2534dee3c15fd67e28c34a14c738659ce8b2c8 100644 --- a/e2e/binary/yes/BUILD.bazel +++ b/e2e/binary/yes/BUILD.bazel @@ -1,11 +1,31 @@ -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 `yes` +py_pytest_test( + name = "pytest", + size = "small", + srcs = ["yes.py"], + data = [ + "@ape//ape:yes", + "expected.txt", + ], + deps = [ + "//binary:pytest", + ], +) -build_test( - name = "yes", +native_test( + name = "version", size = "small", - tags = ["stub"], - targets = ["@ape//ape:yes"], + src = "@ape//ape:yes", + args = ["--version"], +) + +test_suite( + name = "yes", + tests = [ + "pytest", + "version", + ], visibility = ["//:__subpackages__"], ) diff --git a/e2e/binary/yes/expected.txt b/e2e/binary/yes/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..57dc54cc8a5e9327c7467d103b8d3b909896a98f --- /dev/null +++ b/e2e/binary/yes/expected.txt @@ -0,0 +1,5 @@ +y +y +y +y +y diff --git a/e2e/binary/yes/yes.py b/e2e/binary/yes/yes.py new file mode 100644 index 0000000000000000000000000000000000000000..d34a3c17983de27dc56a159c552f53dda24005a0 --- /dev/null +++ b/e2e/binary/yes/yes.py @@ -0,0 +1,22 @@ +from __future__ import annotations + +from subprocess import Popen, PIPE +from pathlib import Path + +from binary import Tool, Relative, Diff + + +def test_yes(tool: Tool, relative: Relative, tmp_path: Path) -> None: + binary = tool("yes") + expected = relative("expected.txt") + output = tmp_path / "output.txt" + + process = Popen(binary, stdout=PIPE, text=True) + + with open(output, "w") as stream: + for i in range(5): + stream.write(process.stdout.readline()) + + process.terminate() + + assert Diff(expected) == Diff(output)