From e1c799c5ec4274a19b4ab26bd7a0ddab8f080574 Mon Sep 17 00:00:00 2001 From: Jonathan Watson Date: Wed, 26 Feb 2025 09:46:15 +0000 Subject: [PATCH] test(emacs): add version and emacs test --- e2e/binary/emacs/BUILD.bazel | 31 +++++++++++++++++++++++++------ e2e/binary/emacs/emacs.py | 14 ++++++++++++++ 2 files changed, 39 insertions(+), 6 deletions(-) create mode 100644 e2e/binary/emacs/emacs.py diff --git a/e2e/binary/emacs/BUILD.bazel b/e2e/binary/emacs/BUILD.bazel index 81af26c7..c4582ce7 100644 --- a/e2e/binary/emacs/BUILD.bazel +++ b/e2e/binary/emacs/BUILD.bazel @@ -1,11 +1,30 @@ -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 `emacs` +py_pytest_test( + name = "pytest", + size = "small", + srcs = ["emacs.py"], + data = [ + "@ape//ape:emacs", + ], + deps = [ + "//binary:pytest", + ], +) -build_test( - name = "emacs", +native_test( + name = "version", size = "small", - tags = ["stub"], - targets = ["@ape//ape:emacs"], + src = "@ape//ape:emacs", + args = ["--version"], +) + +test_suite( + name = "emacs", + tests = [ + "pytest", + "version", + ], visibility = ["//:__subpackages__"], ) diff --git a/e2e/binary/emacs/emacs.py b/e2e/binary/emacs/emacs.py new file mode 100644 index 00000000..1877efb8 --- /dev/null +++ b/e2e/binary/emacs/emacs.py @@ -0,0 +1,14 @@ +from __future__ import annotations + +from pathlib import Path +from subprocess import run, PIPE + +from binary import Diff, Relative, Tool + + +def test_emacs(tool: Tool, relative: Relative, tmp_path: Path) -> None: + binary = tool("emacs") + + cmd = (binary, "--batch", "--eval=(prin1 \"Hello, world!\")") + result = run(cmd, check=True, timeout=30, capture_output=True, text=True) + assert "\"Hello, world!\"" == result.stdout -- GitLab