diff --git a/e2e/binary/tree/BUILD.bazel b/e2e/binary/tree/BUILD.bazel index a8b99296430318e13bfc22384bb4e59b66487f53..093f88b05126ec24d3146cf48cc217d53a48b21f 100644 --- a/e2e/binary/tree/BUILD.bazel +++ b/e2e/binary/tree/BUILD.bazel @@ -1,11 +1,33 @@ -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 `tree` +py_pytest_test( + name = "pytest", + size = "small", + srcs = ["tree.py"], + data = [ + "expected.txt", + "fixture/nested/two.txt", + "fixture/one.txt", + "@ape//ape:tree", + ], + deps = [ + "//binary:pytest", + ], +) -build_test( - name = "tree", +native_test( + name = "version", size = "small", - tags = ["stub"], - targets = ["@ape//ape:tree"], + src = "@ape//ape:tree", + args = ["--version"], +) + +test_suite( + name = "tree", + tests = [ + "pytest", + "version", + ], visibility = ["//:__subpackages__"], ) diff --git a/e2e/binary/tree/expected.txt b/e2e/binary/tree/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..773fefebb179a38629c53721d7d7353931b0a02f --- /dev/null +++ b/e2e/binary/tree/expected.txt @@ -0,0 +1,4 @@ +fixture +└── nested + +2 directories diff --git a/e2e/binary/tree/fixture/nested/two.txt b/e2e/binary/tree/fixture/nested/two.txt new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/e2e/binary/tree/fixture/one.txt b/e2e/binary/tree/fixture/one.txt new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/e2e/binary/tree/tree.py b/e2e/binary/tree/tree.py new file mode 100644 index 0000000000000000000000000000000000000000..3fee4d4c72d2ef60c854dc6988c68654621a096a --- /dev/null +++ b/e2e/binary/tree/tree.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_copy(tool: Tool, relative: Relative, tmp_path: Path) -> None: + binary = tool("tree") + fixture = relative("fixture") + expected = relative("expected.txt") + output = tmp_path / "output" + + cmd = (binary, "-d", fixture.name) + with output.open("w") as stream: + run(cmd, check=True, timeout=30, stdout=stream, cwd=fixture.parent) + + assert Diff(expected) == Diff(output)