diff --git a/e2e/binary/uniq/BUILD.bazel b/e2e/binary/uniq/BUILD.bazel index ea2512a8824d4eee70c993acca96975bdd3a9ad2..307d2b5a32ffe483b4a9a0fbd5cb8d4128cbcb91 100644 --- a/e2e/binary/uniq/BUILD.bazel +++ b/e2e/binary/uniq/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 `uniq` +py_pytest_test( + name = "pytest", + size = "small", + srcs = ["unique.py"], + data = [ + "fixture.txt", + "expected.txt", + "@ape//ape:uniq", + ], + deps = [ + "//binary:pytest", + ], +) -build_test( - name = "uniq", +native_test( + name = "version", size = "small", - tags = ["stub"], - targets = ["@ape//ape:uniq"], + src = "@ape//ape:uniq", + args = ["--version"], +) + +test_suite( + name = "uniq", + tests = [ + "pytest", + "version", + ], visibility = ["//:__subpackages__"], ) diff --git a/e2e/binary/uniq/expected.txt b/e2e/binary/uniq/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ead505f9b673e589044fd0b6b5c677fc3b6bb0a --- /dev/null +++ b/e2e/binary/uniq/expected.txt @@ -0,0 +1 @@ +I am unique diff --git a/e2e/binary/uniq/fixture.txt b/e2e/binary/uniq/fixture.txt new file mode 100644 index 0000000000000000000000000000000000000000..95fd729d0e3463705902cbb39775147466a292b4 --- /dev/null +++ b/e2e/binary/uniq/fixture.txt @@ -0,0 +1,6 @@ +Remove me twice +Remove me twice +I am unique +Remove me thrice +Remove me thrice +Remove me thrice \ No newline at end of file diff --git a/e2e/binary/uniq/unique.py b/e2e/binary/uniq/unique.py new file mode 100644 index 0000000000000000000000000000000000000000..6c6acea6ae8fe6cea925f000570fe855c9f245a4 --- /dev/null +++ b/e2e/binary/uniq/unique.py @@ -0,0 +1,18 @@ +from __future__ import annotations + +from pathlib import Path +from subprocess import run + +from binary import Diff, Relative, Tool + + +def test_concatenate(tool: Tool, relative: Relative, tmp_path: Path) -> None: + binary = tool("uniq") + expected = relative("expected.txt") + fixture = relative("fixture.txt") + output = tmp_path / "output.txt" + + cmd = (binary, fixture, "-u") + with open(output, "w") as stream: + run(cmd, check=True, timeout=30, stdout=stream) + assert Diff(expected) == Diff(output)