diff --git a/e2e/binary/od/BUILD.bazel b/e2e/binary/od/BUILD.bazel index 09a1c195d7645e3c281ec1d90f3730d9b63003f3..0803db0574095f1733f6761cd36199a824b74f6d 100644 --- a/e2e/binary/od/BUILD.bazel +++ b/e2e/binary/od/BUILD.bazel @@ -1,11 +1,32 @@ -load("@bazel_skylib//rules:build_test.bzl", "build_test") +load("@bazel_skylib//rules:native_binary.bzl", "native_test") +load("@rules_python_pytest//python_pytest:defs.bzl", "py_pytest_test") -# TODO: write an _actual_ test for `od` +py_pytest_test( + name = "pytest", + size = "small", + srcs = ["convert.py"], + data = [ + "expected.txt", + "fixture.txt", + "@ape//ape:od", + ], + deps = [ + "//binary:pytest", + ], +) -build_test( - name = "od", +native_test( + name = "version", size = "small", - tags = ["stub"], - targets = ["@ape//ape:od"], + src = "@ape//ape:od", + args = ["--version"], +) + +test_suite( + name = "od", + tests = [ + "pytest", + "version", + ], visibility = ["//:__subpackages__"], ) diff --git a/e2e/binary/od/convert.py b/e2e/binary/od/convert.py new file mode 100644 index 0000000000000000000000000000000000000000..8192ab38c875b15825003aa2310385a38dd7687a --- /dev/null +++ b/e2e/binary/od/convert.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_convert(tool: Tool, relative: Relative, tmp_path: Path) -> None: + tool = tool("od") + fixture = relative("fixture.txt") + expected = relative("expected.txt") + output = tmp_path / "output.txt" + + cmd = (tool, f"{fixture}") + with output.open("w") as stream: + run(cmd, check=True, stdout=stream) + + assert Diff(expected) == Diff(output) diff --git a/e2e/binary/od/expected.txt b/e2e/binary/od/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..99419798af7e5331777e1e23c66149205687a850 --- /dev/null +++ b/e2e/binary/od/expected.txt @@ -0,0 +1,2 @@ +0000000 062510 066154 026157 073440 071157 062154 005041 +0000016 diff --git a/e2e/binary/od/fixture.txt b/e2e/binary/od/fixture.txt new file mode 100644 index 0000000000000000000000000000000000000000..af5626b4a114abcb82d63db7c8082c3c4756e51b --- /dev/null +++ b/e2e/binary/od/fixture.txt @@ -0,0 +1 @@ +Hello, world!