diff --git a/e2e/binary/awk/BUILD.bazel b/e2e/binary/awk/BUILD.bazel index 148c38e1057a690908b0c7aac3a9def8b918c8cd..862629a7e294de2ba111db750e4302b1259c8201 100644 --- a/e2e/binary/awk/BUILD.bazel +++ b/e2e/binary/awk/BUILD.bazel @@ -2,7 +2,7 @@ load("@rules_python_pytest//python_pytest:defs.bzl", "py_pytest_test") load("@bazel_skylib//rules:native_binary.bzl", "native_test") py_pytest_test( - name = "print", + name = "pytest", size = "small", srcs = ["print.py"], data = [ @@ -23,8 +23,8 @@ native_test( test_suite( name = "awk", tests = [ - ":print", - ":version", + "pytest", + "version", ], visibility = ["//:__subpackages__"], ) diff --git a/e2e/binary/b2sum/BUILD.bazel b/e2e/binary/b2sum/BUILD.bazel index cdec46e7de509d0568f11251b7dc9646fa5be4d5..74a3e1bc65256e6941804836a1d352a8e223514b 100644 --- a/e2e/binary/b2sum/BUILD.bazel +++ b/e2e/binary/b2sum/BUILD.bazel @@ -2,7 +2,7 @@ load("@rules_python_pytest//python_pytest:defs.bzl", "py_pytest_test") load("@bazel_skylib//rules:native_binary.bzl", "native_test") py_pytest_test( - name = "digest", + name = "pytest", size = "small", srcs = ["digest.py"], data = [ @@ -25,8 +25,8 @@ native_test( test_suite( name = "b2sum", tests = [ - ":digest", - ":version", + "pytest", + "version", ], visibility = ["//:__subpackages__"], ) diff --git a/e2e/binary/brotli/BUILD.bazel b/e2e/binary/brotli/BUILD.bazel index ed227b4ecfdf150c28ce1d0a72e1a018da10d86e..9003a0e7e8e893ec8507a7fc5c014a23c5965c6f 100644 --- a/e2e/binary/brotli/BUILD.bazel +++ b/e2e/binary/brotli/BUILD.bazel @@ -2,7 +2,7 @@ load("@rules_python_pytest//python_pytest:defs.bzl", "py_pytest_test") load("@bazel_skylib//rules:native_binary.bzl", "native_test") py_pytest_test( - name = "roundtrip", + name = "pytest", size = "small", srcs = ["roundtrip.py"], data = [ @@ -24,8 +24,8 @@ native_test( test_suite( name = "brotli", tests = [ - ":roundtrip", - ":version", + "pytest", + "version", ], visibility = ["//:__subpackages__"], ) diff --git a/e2e/binary/bzip2/BUILD.bazel b/e2e/binary/bzip2/BUILD.bazel index ebcb3e851a01161339210212c88879873d6d66f1..17550228f2fdbf99493ecb09561cff4f42820212 100644 --- a/e2e/binary/bzip2/BUILD.bazel +++ b/e2e/binary/bzip2/BUILD.bazel @@ -2,7 +2,7 @@ load("@rules_python_pytest//python_pytest:defs.bzl", "py_pytest_test") load("@bazel_skylib//rules:native_binary.bzl", "native_test") py_pytest_test( - name = "roundtrip", + name = "pytest", size = "small", srcs = ["roundtrip.py"], data = [ @@ -24,8 +24,8 @@ native_test( test_suite( name = "bzip2", tests = [ - ":roundtrip", - ":version", + "pytest", + "version", ], visibility = ["//:__subpackages__"], ) diff --git a/e2e/binary/cmp/BUILD.bazel b/e2e/binary/cmp/BUILD.bazel index 5e657eae152c7c7663598831b73f3400dc5cce2d..57c91e2cc73bdb751f43d5293b04cb9e9f3ba17e 100644 --- a/e2e/binary/cmp/BUILD.bazel +++ b/e2e/binary/cmp/BUILD.bazel @@ -2,7 +2,7 @@ load("@rules_python_pytest//python_pytest:defs.bzl", "py_pytest_test") load("@bazel_skylib//rules:native_binary.bzl", "native_test") py_pytest_test( - name = "text", + name = "pytest", size = "small", srcs = ["text.py"], data = [ @@ -26,8 +26,8 @@ native_test( test_suite( name = "cmp", tests = [ - ":text", - ":version", + "pytest", + "version", ], visibility = ["//:__subpackages__"], ) diff --git a/e2e/binary/curl/BUILD.bazel b/e2e/binary/curl/BUILD.bazel index 5bc08c78e581d654f59c06fa25d1a5dc85e8aa75..790098e748f78592d17a56875dbe51db413f5677 100644 --- a/e2e/binary/curl/BUILD.bazel +++ b/e2e/binary/curl/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 `curl` +py_pytest_test( + name = "pytest", + size = "small", + srcs = ["head.py"], + data = [ + "@ape//ape:curl", + ], + tags = ["requires-network"], + deps = [ + "//binary:pytest", + ], +) -build_test( - name = "curl", +native_test( + name = "version", size = "small", - tags = ["stub"], - targets = ["@ape//ape:curl"], + src = "@ape//ape:curl", + args = ["--version"], +) + +test_suite( + name = "curl", + tests = [ + "pytest", + "version", + ], visibility = ["//:__subpackages__"], ) diff --git a/e2e/binary/curl/head.py b/e2e/binary/curl/head.py new file mode 100644 index 0000000000000000000000000000000000000000..6407c5c12d27d302c8e3a750ddc4256cddb87071 --- /dev/null +++ b/e2e/binary/curl/head.py @@ -0,0 +1,38 @@ +from __future__ import annotations + +from pathlib import Path +from subprocess import run +from typing import Final +from urllib.error import HTTPError +from urllib.request import Request, urlopen + +from binary import Tool +from pytest import mark + +URL: Final = "https://gitlab.arm.com/api/v4/projects" + + +def ping(url: str) -> bool: + request = Request(url, method="HEAD") + + # FIXME: remove this when the CI image works with Python SSL verification + import ssl + context = ssl._create_unverified_context() + + try: + with urlopen(request, context=context) as stream: + if "Content-Length" not in stream.headers: + return False + return 200 <= stream.status < 300 + except HTTPError as e: + return False + + +@mark.skipif(not ping(URL), reason="No network availability") +def test_curl(tool: Tool, tmp_path: Path) -> None: + binary = tool("curl") + + cmd = (binary, "-sfSLX", "HEAD", URL) + result = run(cmd, timeout=30, capture_output=True, text=True) + + assert 0 == result.returncode, result.stderr diff --git a/e2e/binary/diff/BUILD.bazel b/e2e/binary/diff/BUILD.bazel index 45fa9b5cd435f2cffe483b2c9d49902eaca4830c..cb5c70f2ec558b5c0925fc3d16a21f8ec16dc09e 100644 --- a/e2e/binary/diff/BUILD.bazel +++ b/e2e/binary/diff/BUILD.bazel @@ -2,7 +2,7 @@ load("@rules_python_pytest//python_pytest:defs.bzl", "py_pytest_test") load("@bazel_skylib//rules:native_binary.bzl", "native_test") py_pytest_test( - name = "normal", + name = "pytest", size = "small", srcs = ["normal.py"], data = [ @@ -26,8 +26,8 @@ native_test( test_suite( name = "diff", tests = [ - ":normal", - ":version", + "pytest", + "version", ], visibility = ["//:__subpackages__"], ) diff --git a/e2e/binary/diff3/BUILD.bazel b/e2e/binary/diff3/BUILD.bazel index 26e6bf0241232fbab6ebff9d153096e55dadfb1b..69c138962545a0957c5a3ac75bf9fa1e29dbe97d 100644 --- a/e2e/binary/diff3/BUILD.bazel +++ b/e2e/binary/diff3/BUILD.bazel @@ -2,7 +2,7 @@ load("@rules_python_pytest//python_pytest:defs.bzl", "py_pytest_test") load("@bazel_skylib//rules:native_binary.bzl", "native_test") py_pytest_test( - name = "threeway", + name = "pytest", size = "small", srcs = ["threeway.py"], data = [ @@ -28,8 +28,8 @@ native_test( test_suite( name = "diff3", tests = [ - ":threeway", - ":version", + "pytest", + "version", ], visibility = ["//:__subpackages__"], ) diff --git a/e2e/binary/gzip/BUILD.bazel b/e2e/binary/gzip/BUILD.bazel index f5b8e5283ccbd18836205dccef5f06a5303976c4..34fdfc67ee5e93be9c4ea2419c1f87d171c0f58d 100644 --- a/e2e/binary/gzip/BUILD.bazel +++ b/e2e/binary/gzip/BUILD.bazel @@ -2,7 +2,7 @@ load("@rules_python_pytest//python_pytest:defs.bzl", "py_pytest_test") load("@bazel_skylib//rules:native_binary.bzl", "native_test") py_pytest_test( - name = "roundtrip", + name = "pytest", size = "small", srcs = ["roundtrip.py"], data = [ @@ -24,8 +24,8 @@ native_test( test_suite( name = "gzip", tests = [ - ":roundtrip", - ":version", + "pytest", + "version", ], visibility = ["//:__subpackages__"], ) diff --git a/e2e/binary/pigz/BUILD.bazel b/e2e/binary/pigz/BUILD.bazel index f446f6f05f94f5058e3cf684792842b78b892992..c9764e2fb9c8c873702a69e59fa32ce77a8250e3 100644 --- a/e2e/binary/pigz/BUILD.bazel +++ b/e2e/binary/pigz/BUILD.bazel @@ -2,7 +2,7 @@ load("@rules_python_pytest//python_pytest:defs.bzl", "py_pytest_test") load("@bazel_skylib//rules:native_binary.bzl", "native_test") py_pytest_test( - name = "roundtrip", + name = "pytest", size = "small", srcs = ["roundtrip.py"], data = [ @@ -24,8 +24,8 @@ native_test( test_suite( name = "pigz", tests = [ - ":roundtrip", - ":version", + "pytest", + "version", ], visibility = ["//:__subpackages__"], ) diff --git a/e2e/binary/sdiff/BUILD.bazel b/e2e/binary/sdiff/BUILD.bazel index db219d129b94873b3d2fac0efee2f9d37fc4f45e..f8773dd9450ad3f18c4cd1f0a2c9599b9f75aa79 100644 --- a/e2e/binary/sdiff/BUILD.bazel +++ b/e2e/binary/sdiff/BUILD.bazel @@ -2,7 +2,7 @@ load("@rules_python_pytest//python_pytest:defs.bzl", "py_pytest_test") load("@bazel_skylib//rules:native_binary.bzl", "native_test") py_pytest_test( - name = "diff", + name = "pytest", size = "small", srcs = ["diff.py"], data = [ @@ -27,8 +27,8 @@ native_test( test_suite( name = "sdiff", tests = [ - ":diff", - ":version", + "pytest", + "version", ], visibility = ["//:__subpackages__"], ) diff --git a/e2e/binary/sha1sum/BUILD.bazel b/e2e/binary/sha1sum/BUILD.bazel index 9dd80c3ef80b4e9e724d341d02af6d36776f6873..c1aeab72909d3a577ff50c4975381843f7f14620 100644 --- a/e2e/binary/sha1sum/BUILD.bazel +++ b/e2e/binary/sha1sum/BUILD.bazel @@ -2,7 +2,7 @@ load("@rules_python_pytest//python_pytest:defs.bzl", "py_pytest_test") load("@bazel_skylib//rules:native_binary.bzl", "native_test") py_pytest_test( - name = "digest", + name = "pytest", size = "small", srcs = ["digest.py"], data = [ @@ -25,8 +25,8 @@ native_test( test_suite( name = "sha1sum", tests = [ - ":digest", - ":version", + "pytest", + "version", ], visibility = ["//:__subpackages__"], ) diff --git a/e2e/binary/sha224sum/BUILD.bazel b/e2e/binary/sha224sum/BUILD.bazel index ca7557b8e535775c3cdf6574c5b388fe7407e6b1..e88446324843332c2930ba2f109e65eec143869e 100644 --- a/e2e/binary/sha224sum/BUILD.bazel +++ b/e2e/binary/sha224sum/BUILD.bazel @@ -2,7 +2,7 @@ load("@rules_python_pytest//python_pytest:defs.bzl", "py_pytest_test") load("@bazel_skylib//rules:native_binary.bzl", "native_test") py_pytest_test( - name = "digest", + name = "pytest", size = "small", srcs = ["digest.py"], data = [ @@ -25,8 +25,8 @@ native_test( test_suite( name = "sha224sum", tests = [ - ":digest", - ":version", + "pytest", + "version", ], visibility = ["//:__subpackages__"], ) diff --git a/e2e/binary/sha256sum/BUILD.bazel b/e2e/binary/sha256sum/BUILD.bazel index abeff9e667da980acf60f21fc1abfb056bd812d4..b3d856e3b7b51d51de22f9479fc9ea6ebe87aeaa 100644 --- a/e2e/binary/sha256sum/BUILD.bazel +++ b/e2e/binary/sha256sum/BUILD.bazel @@ -2,7 +2,7 @@ load("@rules_python_pytest//python_pytest:defs.bzl", "py_pytest_test") load("@bazel_skylib//rules:native_binary.bzl", "native_test") py_pytest_test( - name = "digest", + name = "pytest", size = "small", srcs = ["digest.py"], data = [ @@ -25,8 +25,8 @@ native_test( test_suite( name = "sha256sum", tests = [ - ":digest", - ":version", + "pytest", + "version", ], visibility = ["//:__subpackages__"], ) diff --git a/e2e/binary/sha384sum/BUILD.bazel b/e2e/binary/sha384sum/BUILD.bazel index c1112fb483dbf1afed1318b8c91ccfaf630ad6b5..43808b92291716d275851fa97c6378f59556c6d6 100644 --- a/e2e/binary/sha384sum/BUILD.bazel +++ b/e2e/binary/sha384sum/BUILD.bazel @@ -2,7 +2,7 @@ load("@rules_python_pytest//python_pytest:defs.bzl", "py_pytest_test") load("@bazel_skylib//rules:native_binary.bzl", "native_test") py_pytest_test( - name = "digest", + name = "pytest", size = "small", srcs = ["digest.py"], data = [ @@ -25,8 +25,8 @@ native_test( test_suite( name = "sha384sum", tests = [ - ":digest", - ":version", + "pytest", + "version", ], visibility = ["//:__subpackages__"], ) diff --git a/e2e/binary/sha512sum/BUILD.bazel b/e2e/binary/sha512sum/BUILD.bazel index 526f7a463571f50bb3beab73342057c06f0bc609..8e740db0e7f3adb59e57cc10ae6e2f8eaadfcbbb 100644 --- a/e2e/binary/sha512sum/BUILD.bazel +++ b/e2e/binary/sha512sum/BUILD.bazel @@ -2,7 +2,7 @@ load("@rules_python_pytest//python_pytest:defs.bzl", "py_pytest_test") load("@bazel_skylib//rules:native_binary.bzl", "native_test") py_pytest_test( - name = "digest", + name = "pytest", size = "small", srcs = ["digest.py"], data = [ @@ -25,8 +25,8 @@ native_test( test_suite( name = "sha512sum", tests = [ - ":digest", - ":version", + "pytest", + "version", ], visibility = ["//:__subpackages__"], ) diff --git a/e2e/binary/xz/BUILD.bazel b/e2e/binary/xz/BUILD.bazel index ef98636ca9f4675cb474ecfd46302e5a1edb9c0e..76065cee38c516a3661fb96094c5ac80a3ed74d0 100644 --- a/e2e/binary/xz/BUILD.bazel +++ b/e2e/binary/xz/BUILD.bazel @@ -2,7 +2,7 @@ load("@rules_python_pytest//python_pytest:defs.bzl", "py_pytest_test") load("@bazel_skylib//rules:native_binary.bzl", "native_test") py_pytest_test( - name = "roundtrip", + name = "pytest", size = "small", srcs = ["roundtrip.py"], data = [ @@ -24,8 +24,8 @@ native_test( test_suite( name = "xz", tests = [ - ":roundtrip", - ":version", + "pytest", + "version", ], visibility = ["//:__subpackages__"], ) diff --git a/e2e/binary/zstd/BUILD.bazel b/e2e/binary/zstd/BUILD.bazel index 43a70f523da6d9efae6280f6384311efc3207c41..89842034accf53893932e7a67ede9ade6e35f6ff 100644 --- a/e2e/binary/zstd/BUILD.bazel +++ b/e2e/binary/zstd/BUILD.bazel @@ -2,7 +2,7 @@ load("@rules_python_pytest//python_pytest:defs.bzl", "py_pytest_test") load("@bazel_skylib//rules:native_binary.bzl", "native_test") py_pytest_test( - name = "roundtrip", + name = "pytest", size = "small", srcs = ["roundtrip.py"], data = [ @@ -24,8 +24,8 @@ native_test( test_suite( name = "zstd", tests = [ - ":roundtrip", - ":version", + "pytest", + "version", ], visibility = ["//:__subpackages__"], )