diff --git a/e2e/binary/unzip/BUILD.bazel b/e2e/binary/unzip/BUILD.bazel index d88b69fc8f27a18143a972dbc4ea8b3a1fb56085..09df8a35b62560fc69f754f9967516bceac8953f 100644 --- a/e2e/binary/unzip/BUILD.bazel +++ b/e2e/binary/unzip/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 `unzip` +py_pytest_test( + name = "pytest", + size = "small", + srcs = ["unzip.py"], + data = [ + "fixture.txt", + "@ape//ape:unzip", + ], + deps = [ + "//binary:pytest", + ], +) -build_test( - name = "unzip", +native_test( + name = "version", size = "small", - tags = ["stub"], - targets = ["@ape//ape:unzip"], + src = "@ape//ape:unzip", + args = ["-v"], +) + +test_suite( + name = "unzip", + tests = [ + "pytest", + "version", + ], visibility = ["//:__subpackages__"], ) diff --git a/e2e/binary/unzip/fixture.txt b/e2e/binary/unzip/fixture.txt new file mode 100644 index 0000000000000000000000000000000000000000..ce013625030ba8dba906f756967f9e9ca394464a --- /dev/null +++ b/e2e/binary/unzip/fixture.txt @@ -0,0 +1 @@ +hello diff --git a/e2e/binary/unzip/unzip.py b/e2e/binary/unzip/unzip.py new file mode 100644 index 0000000000000000000000000000000000000000..83e4f4ccc917822b02bf38403d6069b32a1a1cbd --- /dev/null +++ b/e2e/binary/unzip/unzip.py @@ -0,0 +1,22 @@ +from __future__ import annotations + +from pathlib import Path +from subprocess import run +import zipfile + +from binary import Diff, Relative, Tool + + +def test_unzip(tool: Tool, relative: Relative, tmp_path: Path) -> None: + binary = tool("unzip") + fixture = relative("fixture.txt") + zipped = tmp_path / "output.zip" + unzipped = tmp_path / "fixture.txt" + + with zipfile.ZipFile(zipped, "w") as zip: + zip.write(fixture, arcname=fixture.name) + + cmd = (binary, zipped, "-d", tmp_path) + run(cmd, check=True, timeout=30,) + + assert Diff(fixture) == Diff(unzipped)