diff --git a/e2e/binary/zip/BUILD.bazel b/e2e/binary/zip/BUILD.bazel index ce603aa76bdc66001b0351c2efaf8f85811ecfcd..11b8352f5a1c0f12677a7d449f5fc7213dffc218 100644 --- a/e2e/binary/zip/BUILD.bazel +++ b/e2e/binary/zip/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 `zip` +py_pytest_test( + name = "pytest", + size = "small", + srcs = ["zip.py"], + data = [ + "fixture.txt", + "@ape//ape:zip", + ], + deps = [ + "//binary:pytest", + ], +) -build_test( - name = "zip", +native_test( + name = "version", size = "small", - tags = ["stub"], - targets = ["@ape//ape:zip"], + src = "@ape//ape:zip", + args = ["--version"], +) + +test_suite( + name = "zip", + tests = [ + "pytest", + "version", + ], visibility = ["//:__subpackages__"], ) diff --git a/e2e/binary/zip/fixture.txt b/e2e/binary/zip/fixture.txt new file mode 100644 index 0000000000000000000000000000000000000000..ce013625030ba8dba906f756967f9e9ca394464a --- /dev/null +++ b/e2e/binary/zip/fixture.txt @@ -0,0 +1 @@ +hello diff --git a/e2e/binary/zip/zip.py b/e2e/binary/zip/zip.py new file mode 100644 index 0000000000000000000000000000000000000000..963e19438fa6397bc8e5dd2f6e77ab7077879284 --- /dev/null +++ b/e2e/binary/zip/zip.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_zip(tool: Tool, relative: Relative, tmp_path: Path) -> None: + binary = tool("zip") + fixture = relative("fixture.txt") + zipped = tmp_path / "output.zip" + unzipped = tmp_path / "fixture.txt" + + cmd = (binary, "-j", zipped, fixture) + run(cmd, check=True, timeout=30,) + + with zipfile.ZipFile(zipped, "r") as zip: + zip.extractall(tmp_path) + + assert Diff(fixture) == Diff(unzipped)