From 4dac202abca809d9d3df792c273b425b3e9584d2 Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Thu, 5 Jun 2025 14:41:32 +0100 Subject: [PATCH] test(nice): add native and pytest cases --- e2e/binary/nice/BUILD.bazel | 31 +++++++++++++++++++++++++------ e2e/binary/nice/scheduling.py | 13 +++++++++++++ 2 files changed, 38 insertions(+), 6 deletions(-) create mode 100644 e2e/binary/nice/scheduling.py diff --git a/e2e/binary/nice/BUILD.bazel b/e2e/binary/nice/BUILD.bazel index 2431017f..f4f9aace 100644 --- a/e2e/binary/nice/BUILD.bazel +++ b/e2e/binary/nice/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 `nice` +py_pytest_test( + name = "pytest", + size = "small", + srcs = ["scheduling.py"], + data = [ + "@ape//ape:nice", + ], + deps = [ + "//binary:pytest", + ], +) -build_test( - name = "nice", +native_test( + name = "version", size = "small", - tags = ["stub"], - targets = ["@ape//ape:nice"], + src = "@ape//ape:nice", + args = ["--version"], +) + +test_suite( + name = "nice", + tests = [ + "pytest", + "version", + ], visibility = ["//:__subpackages__"], ) diff --git a/e2e/binary/nice/scheduling.py b/e2e/binary/nice/scheduling.py new file mode 100644 index 00000000..5f0ca9d0 --- /dev/null +++ b/e2e/binary/nice/scheduling.py @@ -0,0 +1,13 @@ +from __future__ import annotations + +from subprocess import run +from sys import executable + +from binary import Tool + + +def test_kill(tool: Tool) -> None: + binary = tool("nice") + cmd = (binary, executable, "-c", "print('Hello, world!')") + r = run(cmd, check=True, capture_output=True, text=True) + assert r.stdout.rstrip() == "Hello, world!" -- GitLab