From e94a06fa28361e268516652e42daac8da891beec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=97=B2=E7=82=8E?= Date: Tue, 20 Oct 2026 10:32:34 +0800 Subject: [PATCH 1/3] feat: prepare req 0.2.0 package and expanded consumer tests --- recipes/req/recipe.yaml | 18 +++++++++----- recipes/req/test.mojo | 25 ------------------- recipes/req/test.py | 53 ++++++++++++----------------------------- 3 files changed, 27 insertions(+), 69 deletions(-) delete mode 100644 recipes/req/test.mojo diff --git a/recipes/req/recipe.yaml b/recipes/req/recipe.yaml index 44a44a3b..6808667a 100644 --- a/recipes/req/recipe.yaml +++ b/recipes/req/recipe.yaml @@ -1,5 +1,5 @@ context: - version: "0.1.0" + version: "0.2.0" mojo_version: "==1.1.0" package: @@ -8,7 +8,7 @@ package: source: - git: https://github.com/mojoto/req.mojo.git - rev: c46152a5d77adf17b85ebb40fe90106a0522e0ee # v0.1.0 + rev: 7f8b006c7b39e77584cf57a24579e32cbadd6435 # 0.2.0 preparation source; no release tag - git: https://github.com/ehsanmok/json.git rev: 0bae1f3815d249efa6cb0a3483eb6658700635e5 # v0.4.1 target_directory: vendor/json @@ -56,15 +56,20 @@ tests: interpreter: bash content: | set -euo pipefail - mojo build --Werror test.mojo -o test-req + mojo build --Werror tests/package.mojo -o test-req python test.py files: recipe: - - test.mojo - test.py + source: + - tests/package.mojo + - tests/conftest.py + - tests/transports/http2_server.py requirements: run: - python >=3.12 + - h2 >=4.3,<5 + - openssl about: homepage: https://github.com/mojoto/req.mojo @@ -77,8 +82,9 @@ about: - vendor/json/NOTICE summary: A synchronous HTTP client for Mojo. description: | - Send HTTP/1.1 requests with JSON, forms, authentication, cookies, - connection reuse, streaming, timeouts, and TLS verification. + Send HTTP/1.1 and opt-in HTTP/2 requests with JSON, multipart and file + uploads, HTTP/HTTPS proxies, connection pool limits, hooks, injectable + transports, response iterators, and verified TLS. Includes the native shared library and the CPU source modules from ehsanmok/json 0.4.1. The native transport loads automatically from the active environment; consumers need no extra linker flags. diff --git a/recipes/req/test.mojo b/recipes/req/test.mojo deleted file mode 100644 index adca1414..00000000 --- a/recipes/req/test.mojo +++ /dev/null @@ -1,25 +0,0 @@ -import req -from std.os import getenv -from std.testing import assert_equal, assert_true - - -def main() raises: - var url = getenv("REQ_PACKAGE_TEST_URL") - var response = req.get(url) - response.raise_for_status() - assert_equal(response.status_code, 200) - assert_equal(response.json()["value"].int_value(), 42) - assert_true(response.text().byte_length() > 0) - - var client = req.Client(base_url=url + "/", timeout=req.Timeout(5.0)) - var first = client.get("first") - first.raise_for_status() - assert_equal(first.json()["value"].int_value(), 42) - var payload = req.JSONValue.object() - payload.set("name", req.JSONValue("Mojo")) - var posted = client.post("post", json=payload) - posted.raise_for_status() - assert_equal(posted.json()["name"].string_value(), "Mojo") - client.close() - - print("Req installed-package HTTP and JSON tests passed") diff --git a/recipes/req/test.py b/recipes/req/test.py index ce9238cc..92974897 100644 --- a/recipes/req/test.py +++ b/recipes/req/test.py @@ -1,43 +1,20 @@ +"""Exercise the installed package using the source release smoke test.""" + import os +from pathlib import Path import subprocess -import threading -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer - - -class Handler(BaseHTTPRequestHandler): - protocol_version = "HTTP/1.1" - - def respond(self, body): - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.send_header("Content-Length", str(len(body))) - self.end_headers() - self.wfile.write(body) - - def do_GET(self): - self.respond(b'{"value":42}') - - def do_POST(self): - self.respond(self.rfile.read(int(self.headers["Content-Length"]))) +import sys - def log_message(self, *_): - pass +sys.path.insert(0, str(Path("tests").resolve())) +from conftest import Fixtures # noqa: E402 -with ThreadingHTTPServer(("127.0.0.1", 0), Handler) as server: - worker = threading.Thread(target=server.serve_forever, daemon=True) - worker.start() - try: - for command in [["mojo", "run", "--Werror", "test.mojo"], ["./test-req"]]: - subprocess.run( - command, - env={ - **os.environ, - "REQ_PACKAGE_TEST_URL": f"http://127.0.0.1:{server.server_port}", - }, - check=True, - timeout=120, - ) - finally: - server.shutdown() - worker.join() +with Fixtures() as fixtures: + env = dict(os.environ, **fixtures.environment) + for name in ("REQ_NATIVE_LIB", "REQ_EXPECT_LOAD_ERROR", "REQ_EXPECT_HTTP2_UNAVAILABLE"): + env.pop(name, None) + for command in [ + ["mojo", "run", "--Werror", "tests/package.mojo"], + ["./test-req"], + ]: + subprocess.run(command, env=env, check=True, timeout=120) From ee3799855d26fcb1501ca539494e7b1d16fadb5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=97=B2=E7=82=8E?= Date: Tue, 20 Oct 2026 10:47:49 +0800 Subject: [PATCH 2/3] test: align source pin and format installed consumer checks --- recipes/req/recipe.yaml | 2 +- recipes/req/test.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/recipes/req/recipe.yaml b/recipes/req/recipe.yaml index 6808667a..47d39ddc 100644 --- a/recipes/req/recipe.yaml +++ b/recipes/req/recipe.yaml @@ -8,7 +8,7 @@ package: source: - git: https://github.com/mojoto/req.mojo.git - rev: 7f8b006c7b39e77584cf57a24579e32cbadd6435 # 0.2.0 preparation source; no release tag + rev: e371e42cbaa3a7b98ea4efe505e79eae0e08f3d9 # 0.2.0 preparation source; no release tag - git: https://github.com/ehsanmok/json.git rev: 0bae1f3815d249efa6cb0a3483eb6658700635e5 # v0.4.1 target_directory: vendor/json diff --git a/recipes/req/test.py b/recipes/req/test.py index 92974897..2bf75aed 100644 --- a/recipes/req/test.py +++ b/recipes/req/test.py @@ -11,7 +11,11 @@ with Fixtures() as fixtures: env = dict(os.environ, **fixtures.environment) - for name in ("REQ_NATIVE_LIB", "REQ_EXPECT_LOAD_ERROR", "REQ_EXPECT_HTTP2_UNAVAILABLE"): + for name in ( + "REQ_NATIVE_LIB", + "REQ_EXPECT_LOAD_ERROR", + "REQ_EXPECT_HTTP2_UNAVAILABLE", + ): env.pop(name, None) for command in [ ["mojo", "run", "--Werror", "tests/package.mojo"], From 673ed4fdff5270f4c487db052269cf725cfad430 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=97=B2=E7=82=8E?= Date: Tue, 20 Oct 2026 10:55:07 +0800 Subject: [PATCH 3/3] chore: pin final req 0.2.0 preparation source --- recipes/req/recipe.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/req/recipe.yaml b/recipes/req/recipe.yaml index 47d39ddc..cbdbda1b 100644 --- a/recipes/req/recipe.yaml +++ b/recipes/req/recipe.yaml @@ -8,7 +8,7 @@ package: source: - git: https://github.com/mojoto/req.mojo.git - rev: e371e42cbaa3a7b98ea4efe505e79eae0e08f3d9 # 0.2.0 preparation source; no release tag + rev: 40d245911d3e681dfb7e837d4a097d0f2ce58af9 # 0.2.0 preparation source; no release tag - git: https://github.com/ehsanmok/json.git rev: 0bae1f3815d249efa6cb0a3483eb6658700635e5 # v0.4.1 target_directory: vendor/json