diff --git a/e2e/binary/jq/BUILD.bazel b/e2e/binary/jq/BUILD.bazel index ba9714d33ec7f1937c510e5f2e84a803f09ab8fa..01a4b72dd55d8abda3778f057220dd0232a41c3e 100644 --- a/e2e/binary/jq/BUILD.bazel +++ b/e2e/binary/jq/BUILD.bazel @@ -1,11 +1,31 @@ -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 `jq` +py_pytest_test( + name = "pytest", + size = "small", + srcs = ["jq.py"], + data = [ + ":fixture.json", + "@ape//ape:jq", + ], + deps = [ + "//binary:pytest", + ], +) -build_test( - name = "jq", +native_test( + name = "version", size = "small", - tags = ["stub"], - targets = ["@ape//ape:jq"], + src = "@ape//ape:jq", + args = ["--version"], +) + +test_suite( + name = "jq", + tests = [ + "pytest", + "version", + ], visibility = ["//:__subpackages__"], ) diff --git a/e2e/binary/jq/fixture.json b/e2e/binary/jq/fixture.json new file mode 100644 index 0000000000000000000000000000000000000000..0458103a0e2326eb12fb2d18e66d339639ab211e --- /dev/null +++ b/e2e/binary/jq/fixture.json @@ -0,0 +1,4 @@ +{ + "one": 1, + "two": 2 +} diff --git a/e2e/binary/jq/jq.py b/e2e/binary/jq/jq.py new file mode 100644 index 0000000000000000000000000000000000000000..04488a4581190f640a67b859ab8a74050e921cc4 --- /dev/null +++ b/e2e/binary/jq/jq.py @@ -0,0 +1,15 @@ +from __future__ import annotations + +from subprocess import run + +from binary.tool import Tool +from binary import Relative + + +def test_jq(tool: Tool, relative: Relative) -> None: + binary = tool("jq") + fixture = relative("fixture.json") + + cmd = (binary, ".one", fixture) + result = run(cmd, check=True, timeout=30, capture_output=True, text=True) + assert "1\n" == result.stdout