diff --git a/e2e/binary/wc/BUILD.bazel b/e2e/binary/wc/BUILD.bazel index 2c6e95816356387ba13bfab25ef78ddc036ff59e..0d3a5cd0636b2832f083992d33b2b13811f85011 100644 --- a/e2e/binary/wc/BUILD.bazel +++ b/e2e/binary/wc/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 `wc` +py_pytest_test( + name = "pytest", + size = "small", + srcs = ["wc.py"], + data = [ + "fixture.txt", + "expected.txt", + "@ape//ape:wc", + ], + deps = [ + "//binary:pytest", + ], +) -build_test( - name = "wc", +native_test( + name = "version", size = "small", - tags = ["stub"], - targets = ["@ape//ape:wc"], + src = "@ape//ape:wc", + args = ["--version"], +) + +test_suite( + name = "wc", + tests = [ + "pytest", + "version", + ], visibility = ["//:__subpackages__"], ) diff --git a/e2e/binary/wc/expected.txt b/e2e/binary/wc/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c5fd483394fa6d5b158b25910923908109489248 --- /dev/null +++ b/e2e/binary/wc/expected.txt @@ -0,0 +1 @@ + 4 4 23 diff --git a/e2e/binary/wc/fixture.txt b/e2e/binary/wc/fixture.txt new file mode 100644 index 0000000000000000000000000000000000000000..ee2ddfb138033b9bc14e8a25feec6c49baa3d6f8 --- /dev/null +++ b/e2e/binary/wc/fixture.txt @@ -0,0 +1,4 @@ +Pongo +Gorilla +Pan +Homo diff --git a/e2e/binary/wc/wc.py b/e2e/binary/wc/wc.py new file mode 100644 index 0000000000000000000000000000000000000000..527584a03e5e5e396eade12ebde390894c610fb5 --- /dev/null +++ b/e2e/binary/wc/wc.py @@ -0,0 +1,19 @@ +from __future__ import annotations + +from pathlib import Path +from subprocess import run + +from binary import Diff, Relative, Tool + + +def test_wc(tool: Tool, relative: Relative, tmp_path: Path) -> None: + binary = tool("wc") + fixture = relative("fixture.txt") + expected = relative("expected.txt") + output = tmp_path / "output.txt" + + cmd = (binary, "-lcw",) + with open(output, "w") as stream, open(fixture, "rb") as stdin: + run(cmd, check=True, timeout=30, stdout=stream, stdin=stdin) + + assert Diff(expected) == Diff(output)