From e2de4bac4b749e53aad45c92f41c9ba19a46e6c3 Mon Sep 17 00:00:00 2001 From: Luke Hackwell Date: Thu, 27 Feb 2025 15:06:10 +0000 Subject: [PATCH] test(test): add native and pytest test tests --- e2e/binary/test/BUILD.bazel | 32 ++++++++++++++++++++++++++------ e2e/binary/test/test.py | 21 +++++++++++++++++++++ 2 files changed, 47 insertions(+), 6 deletions(-) create mode 100644 e2e/binary/test/test.py diff --git a/e2e/binary/test/BUILD.bazel b/e2e/binary/test/BUILD.bazel index 0dcf8ba0..940112b1 100644 --- a/e2e/binary/test/BUILD.bazel +++ b/e2e/binary/test/BUILD.bazel @@ -1,11 +1,31 @@ -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 `test` -build_test( - name = "test", +py_pytest_test( + name = "pytest", + size = "small", + srcs = ["test.py"], + data = [ + "@ape//ape:test" + ], + deps = [ + "//binary:pytest", + ], +) + +native_test( + name = "native", size = "small", - tags = ["stub"], - targets = ["@ape//ape:test"], + src = "@ape//ape:test", + args = ["hello"], +) + +test_suite( + name = "test", + tests = [ + "native", + "pytest", + ], visibility = ["//:__subpackages__"], ) diff --git a/e2e/binary/test/test.py b/e2e/binary/test/test.py new file mode 100644 index 00000000..6ffabf06 --- /dev/null +++ b/e2e/binary/test/test.py @@ -0,0 +1,21 @@ +from __future__ import annotations + +from subprocess import run, CalledProcessError +import pytest + +from binary.tool import Tool + + +def test_strings_equal(tool: Tool) -> None: + binary = tool("test") + + cmd = (binary, 'hello', '=', 'hello') + run(cmd, check=True, timeout=30) + + +def test_strings_unequal(tool: Tool) -> None: + binary = tool("test") + + cmd = (binary, 'hello', '=', 'bye') + with pytest.raises(CalledProcessError): + run(cmd, check=True, timeout=30) -- GitLab