diff --git a/e2e/binary/split/BUILD.bazel b/e2e/binary/split/BUILD.bazel index d8e53274a54b86f385999c527a3039b29541cb6c..17642eabe10acb58e91d478cb9b2936a1b5015cc 100644 --- a/e2e/binary/split/BUILD.bazel +++ b/e2e/binary/split/BUILD.bazel @@ -1,11 +1,33 @@ -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 `split` +py_pytest_test( + name = "pytest", + size = "small", + srcs = ["split.py"], + data = [ + "xaa.expected.txt", + "xab.expected.txt", + "fixture.txt", + "@ape//ape:split", + ], + deps = [ + "//binary:pytest", + ], +) -build_test( - name = "split", +native_test( + name = "version", size = "small", - tags = ["stub"], - targets = ["@ape//ape:split"], + src = "@ape//ape:split", + args = ["--version"], +) + +test_suite( + name = "split", + tests = [ + "pytest", + "version", + ], visibility = ["//:__subpackages__"], ) diff --git a/e2e/binary/split/fixture.txt b/e2e/binary/split/fixture.txt new file mode 100644 index 0000000000000000000000000000000000000000..ee2ddfb138033b9bc14e8a25feec6c49baa3d6f8 --- /dev/null +++ b/e2e/binary/split/fixture.txt @@ -0,0 +1,4 @@ +Pongo +Gorilla +Pan +Homo diff --git a/e2e/binary/split/split.py b/e2e/binary/split/split.py new file mode 100644 index 0000000000000000000000000000000000000000..bec4086ba537b13fdbaa337810554499f8307a15 --- /dev/null +++ b/e2e/binary/split/split.py @@ -0,0 +1,21 @@ +from __future__ import annotations + +from subprocess import run +from pathlib import Path + +from binary import Diff, Relative, Tool + + +def test_split(tool: Tool, relative: Relative, tmp_path: Path) -> None: + binary = tool("split") + fixture = Path.cwd() / relative("fixture.txt") + output_map = { + tmp_path / "xaa": relative("xaa.expected.txt"), + tmp_path / "xab": relative("xab.expected.txt"), + } + + cmd = (binary, '-l', '2', fixture,) + run(cmd, check=True, timeout=30, cwd=tmp_path,) + + for output, expected in output_map.items(): + assert Diff(expected) == Diff(output) diff --git a/e2e/binary/split/xaa.expected.txt b/e2e/binary/split/xaa.expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..13bbd603cb29acd3161c976cdc9137619c2c2c3f --- /dev/null +++ b/e2e/binary/split/xaa.expected.txt @@ -0,0 +1,2 @@ +Pongo +Gorilla diff --git a/e2e/binary/split/xab.expected.txt b/e2e/binary/split/xab.expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..eb489a27ad4c6100a063bb7ded57bcdc187506fa --- /dev/null +++ b/e2e/binary/split/xab.expected.txt @@ -0,0 +1,2 @@ +Pan +Homo