Add repeatable Python and Rust fixture parity smoke check
This commit is contained in:
parent
9416fd2f48
commit
3499e57cfa
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
Loading…
Reference in New Issue