From a04ee8f16e1221b3b06662ee4d08c5881ded1890 Mon Sep 17 00:00:00 2001 From: Anjali Kumar Date: Wed, 19 Mar 2025 09:56:07 +0000 Subject: [PATCH] test(echo): add native and pytest tests --- e2e/binary/echo/BUILD.bazel | 31 +++++++++++++++++++++++++------ e2e/binary/echo/echo.py | 12 ++++++++++++ 2 files changed, 37 insertions(+), 6 deletions(-) create mode 100644 e2e/binary/echo/echo.py diff --git a/e2e/binary/echo/BUILD.bazel b/e2e/binary/echo/BUILD.bazel index ff802ed9..80f8100c 100644 --- a/e2e/binary/echo/BUILD.bazel +++ b/e2e/binary/echo/BUILD.bazel @@ -1,11 +1,30 @@ -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 `echo` +py_pytest_test( + name = "pytest", + size = "small", + srcs = ["echo.py"], + data = [ + "@ape//ape:echo", + ], + deps = [ + "//binary:pytest", + ], +) -build_test( - name = "echo", +native_test( + name = "version", size = "small", - tags = ["stub"], - targets = ["@ape//ape:echo"], + src = "@ape//ape:echo", + args = ["--version"], +) + +test_suite( + name = "echo", + tests = [ + "pytest", + "version", + ], visibility = ["//:__subpackages__"], ) diff --git a/e2e/binary/echo/echo.py b/e2e/binary/echo/echo.py new file mode 100644 index 00000000..b2f32619 --- /dev/null +++ b/e2e/binary/echo/echo.py @@ -0,0 +1,12 @@ +from __future__ import annotations + +from subprocess import run +from binary import Tool + + +def test_echo(tool: Tool) -> None: + binary = tool("echo") + + cmd = (binary, "Hello, world!") + result = run(cmd, check=True, timeout=30, capture_output=True, text=True) + assert result.stdout.rstrip() == "Hello, world!" -- GitLab