From 3499e57cfa37e3936d7307b8d941c64f1aec8d4d Mon Sep 17 00:00:00 2001 From: Dandaedre Date: Thu, 17 Sep 2026 02:04:33 +0200 Subject: [PATCH] Add repeatable Python and Rust fixture parity smoke check --- AGENT_TASKS.md | 12 ++++---- tests/parity_smoke.py | 70 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+), 5 deletions(-) create mode 100644 tests/parity_smoke.py diff --git a/AGENT_TASKS.md b/AGENT_TASKS.md index ae38adf..077a0df 100644 --- a/AGENT_TASKS.md +++ b/AGENT_TASKS.md @@ -20,6 +20,8 @@ Progress tracking: check a task only when the Rust behavior is implemented and l Parity note: Python and Rust `target_test_project --dry-run --stop-after verify` both report the missing local release tag and exit nonzero. The Rust dry run now reports this as a prerequisite without creating a tag. Python and Rust metadata-stage runs both succeed on the fixture. Output formatting differs; full fixture parity remains open. +Run the repeatable local smoke comparison with `.venv/bin/python tests/parity_smoke.py`. It builds the Rust binary and compares inspect/metadata fields on the tiny fixture; when the fixture tag is absent, it also checks that both dry runs reject it. The full fixture matrix is still pending. + Work in small, testable phases. Commit migration work in coherent increments. --- @@ -629,12 +631,12 @@ Create a migration-only harness/script or test utility. For each non-mutating fixture: -- [ ] run Python implementation; -- [ ] run Rust implementation; +- [x] run Python implementation; +- [x] run Rust implementation; - [ ] normalize nondeterministic temp paths; -- [ ] compare success/failure; -- [ ] compare selected package; -- [ ] compare version/tag; +- [x] compare success/failure; +- [x] compare selected package; +- [x] compare version/tag; - [ ] compare metadata findings; - [ ] compare planned targets; - [ ] compare artifact names; diff --git a/tests/parity_smoke.py b/tests/parity_smoke.py new file mode 100644 index 0000000..b7be6b6 --- /dev/null +++ b/tests/parity_smoke.py @@ -0,0 +1,70 @@ +"""Opt-in Python/Rust smoke parity check for the tiny local fixture. + +Run with the Python environment used by the old worker: + .venv/bin/python tests/parity_smoke.py +""" + +import os +import re +import subprocess +import sys +from pathlib import Path + + +ROOT = Path(__file__).resolve().parents[1] +FIXTURE = ROOT / "target_test_project" +RUST = ROOT / "target" / "debug" / "rust_realease" + + +def invoke(command): + env = os.environ.copy() + env["PYTHONPATH"] = str(ROOT) + env["NO_COLOR"] = "1" + return subprocess.run(command, cwd=ROOT, env=env, text=True, capture_output=True) + + +def field(output, name): + match = re.search(rf"(?m)^{re.escape(name)}: ([^\n]+)", output) + if match is None: + raise AssertionError(f"missing {name} field:\n{output}") + return match.group(1).strip() + + +def main(): + if not FIXTURE.is_dir(): + raise SystemExit("Initialize target_test_project submodule first.") + subprocess.run(["cargo", "build", "--locked", "--quiet"], cwd=ROOT, check=True) + commands = { + "Python": [sys.executable, "-P", "-m", "worker"], + "Rust": [str(RUST)], + } + for stage in ("inspect", "metadata"): + results = { + name: invoke(base + [str(FIXTURE), "--dry-run", "--stop-after", stage]) + for name, base in commands.items() + } + for name, result in results.items(): + if result.returncode != 0: + raise AssertionError(f"{name} {stage} failed:\n{result.stdout}\n{result.stderr}") + for key in ("Package", "Version", "Binary", "Tag"): + values = {name: field(result.stdout, key) for name, result in results.items()} + if len(set(values.values())) != 1: + raise AssertionError(f"{stage} {key} differs: {values}") + if stage == "metadata": + for name, result in results.items(): + if field(result.stdout, "Binstall metadata") != "valid": + raise AssertionError(f"{name} binstall metadata differs") + tag = field(results["Rust"].stdout, "Tag") + present = subprocess.run( + ["git", "tag", "--list", tag], cwd=FIXTURE, text=True, capture_output=True, check=True + ).stdout.strip() + if not present: + for name, base in commands.items(): + result = invoke(base + [str(FIXTURE), "--dry-run", "--stop-after", "verify"]) + if result.returncode == 0 or "tag" not in result.stdout.lower(): + raise AssertionError(f"{name} dry run missed the local tag:\n{result.stdout}") + print("Python/Rust fixture inspect and metadata smoke parity passed.") + + +if __name__ == "__main__": + main()