From 7c6b060f669e8f0931e8ed2a0f9e64c243e22a08 Mon Sep 17 00:00:00 2001 From: Anjali Kumar Date: Mon, 28 Apr 2025 11:15:28 +0100 Subject: [PATCH 1/2] test(false): add native and pytest tests for false --- e2e/binary/false/BUILD.bazel | 56 +++++++++++++++++++++++++++++++---- e2e/binary/false/expected.txt | 1 + e2e/binary/false/false.py | 14 +++++++++ 3 files changed, 66 insertions(+), 5 deletions(-) create mode 100644 e2e/binary/false/expected.txt create mode 100644 e2e/binary/false/false.py diff --git a/e2e/binary/false/BUILD.bazel b/e2e/binary/false/BUILD.bazel index 8301ea9d..a7f872ed 100644 --- a/e2e/binary/false/BUILD.bazel +++ b/e2e/binary/false/BUILD.bazel @@ -1,11 +1,57 @@ -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 `false` +py_pytest_test( + name = "pytest", + size = "small", + srcs = ["false.py"], + data = [ +<<<<<<< HEAD +<<<<<<< HEAD + "expected.txt", +======= +>>>>>>> 6c0bc741e94c6b196a1439d34948f499148a1ccb +======= +>>>>>>> 6c0bc741e94c6b196a1439d34948f499148a1ccb + "@ape//ape:false", + ], + deps = [ + "//binary:pytest", + ], +) -build_test( +native_test( +<<<<<<< HEAD +<<<<<<< HEAD + name = "version", + size = "small", + src = "@ape//ape:false", + args = ["--version"], +) + +test_suite( name = "false", + tests = [ + "pytest", + "version", +======= +======= +>>>>>>> 6c0bc741e94c6b196a1439d34948f499148a1ccb + name = "native", size = "small", - tags = ["stub"], - targets = ["@ape//ape:false"], + src = "@ape//ape:false", + args = ["hello"], +) + +test_suite( + name = "false" + tests = [ + "native", + "pytest", +<<<<<<< HEAD +>>>>>>> 6c0bc741e94c6b196a1439d34948f499148a1ccb +======= +>>>>>>> 6c0bc741e94c6b196a1439d34948f499148a1ccb + ], visibility = ["//:__subpackages__"], ) diff --git a/e2e/binary/false/expected.txt b/e2e/binary/false/expected.txt new file mode 100644 index 00000000..9f2560bd --- /dev/null +++ b/e2e/binary/false/expected.txt @@ -0,0 +1 @@ +Cat Gorilla Platypus \ No newline at end of file diff --git a/e2e/binary/false/false.py b/e2e/binary/false/false.py new file mode 100644 index 00000000..c31e2f0a --- /dev/null +++ b/e2e/binary/false/false.py @@ -0,0 +1,14 @@ +from __future__ import annotations + +from pathlib import Path +from subprocess import run, CalledProcessError +import pytest + +from binary import Diff, Relative, Tool + +def test_false(tool:Tool, relative: Relative, tmp_path: Path) -> None: + binary = tool("false") + + cmd = (binary, "Hello, world!", '=', "Goodbye!") + result = run(cmd, check=True, timeout=30, capture_output=True) + assert result.stdout.rstrip() == False -- GitLab From 56647527d72f0de6e9425c303f110c54f84b0d08 Mon Sep 17 00:00:00 2001 From: Anjali Kumar Date: Wed, 4 Jun 2025 10:54:20 +0100 Subject: [PATCH 2/2] test(rm): add native and pytest tests --- e2e/binary/rm/BUILD.bazel | 31 +++++++++++++++++++++++++------ e2e/binary/rm/rm.py | 17 +++++++++++++++++ 2 files changed, 42 insertions(+), 6 deletions(-) create mode 100644 e2e/binary/rm/rm.py diff --git a/e2e/binary/rm/BUILD.bazel b/e2e/binary/rm/BUILD.bazel index f76722ff..c4487d7d 100644 --- a/e2e/binary/rm/BUILD.bazel +++ b/e2e/binary/rm/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 `rm` +py_pytest_test( + name = "pytest", + size = "small", + srcs = ["rm.py"], + data = [ + "@ape//ape:rm", + ], + deps = [ + "//binary:pytest", + ], +) -build_test( - name = "rm", +native_test( + name = "version", size = "small", - tags = ["stub"], - targets = ["@ape//ape:rm"], + src = "@ape//ape:rm", + args = ["--version"], +) + +test_suite( + name = "rm", + tests = [ + "pytest", + "version", + ], visibility = ["//:__subpackages__"], ) diff --git a/e2e/binary/rm/rm.py b/e2e/binary/rm/rm.py new file mode 100644 index 00000000..0ef370ef --- /dev/null +++ b/e2e/binary/rm/rm.py @@ -0,0 +1,17 @@ +from __future__ import annotations + +from pathlib import Path +from subprocess import run + +from binary import Tool, Relative + + +def test_rm(tool: Tool, relative: Relative, tmp_path: Path) -> None: + binary = tool("rm") + fixture = tmp_path / "fixture.txt" + fixture.touch() + + cmd = (binary, f"{fixture}") + run(cmd, check=True, timeout=30, capture_output=True, text=True) + + assert not fixture.exists() -- GitLab