From b52c84c2fd1f198229d4b810f0ea456884fbdd15 Mon Sep 17 00:00:00 2001 From: Luke Hackwell Date: Tue, 4 Mar 2025 10:56:36 +0000 Subject: [PATCH] test(unbourne): add pytest test --- e2e/binary/unbourne/BUILD.bazel | 23 +++++++++++++++++------ e2e/binary/unbourne/expected.txt | 1 + e2e/binary/unbourne/redirect.py | 18 ++++++++++++++++++ 3 files changed, 36 insertions(+), 6 deletions(-) create mode 100644 e2e/binary/unbourne/expected.txt create mode 100644 e2e/binary/unbourne/redirect.py diff --git a/e2e/binary/unbourne/BUILD.bazel b/e2e/binary/unbourne/BUILD.bazel index 6f9d958d..ae3b2ef5 100644 --- a/e2e/binary/unbourne/BUILD.bazel +++ b/e2e/binary/unbourne/BUILD.bazel @@ -1,11 +1,22 @@ -load("@bazel_skylib//rules:build_test.bzl", "build_test") +load("@rules_python_pytest//python_pytest:defs.bzl", "py_pytest_test") -# TODO: write an _actual_ test for `unbourne` +py_pytest_test( + name = "pytest", + size = "small", + srcs = ["redirect.py"], + data = [ + "expected.txt", + "@ape//ape:unbourne", + ], + deps = [ + "//binary:pytest", + ], +) -build_test( +test_suite( name = "unbourne", - size = "small", - tags = ["stub"], - targets = ["@ape//ape:unbourne"], + tests = [ + "pytest", + ], visibility = ["//:__subpackages__"], ) diff --git a/e2e/binary/unbourne/expected.txt b/e2e/binary/unbourne/expected.txt new file mode 100644 index 00000000..ce013625 --- /dev/null +++ b/e2e/binary/unbourne/expected.txt @@ -0,0 +1 @@ +hello diff --git a/e2e/binary/unbourne/redirect.py b/e2e/binary/unbourne/redirect.py new file mode 100644 index 00000000..8b873fc5 --- /dev/null +++ b/e2e/binary/unbourne/redirect.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_redirect(tool: Tool, relative: Relative, tmp_path: Path) -> None: + binary = tool("unbourne") + expected = relative("expected.txt") + output = tmp_path / "output.txt" + + stdin = f"echo hello > {str(output)}".encode() + cmd = (binary,) + res = run(cmd, check=True, timeout=30, input=stdin,) + + assert Diff(expected) == Diff(output) -- GitLab