From e109eb80ae7e6fd8f885f356e54b5f4381dcc8cf Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Tue, 28 Apr 2026 18:47:27 +0000 Subject: [PATCH] compat-matrix: add PYTEST_K env var to scope pytest from the publisher MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Operator escape hatch for first-time validation after a Claude Code CLI upgrade or a proxy-config change. Setting `PYTEST_K=anthropic and basic_messaging_non_streaming` (for example) narrows the matrix run to one cell, which is enough to confirm the worktree+uv+proxy+pytest plumbing without burning a full $2 in provider tokens. Cells the narrowed run doesn't touch are filled with `not_tested` by the matrix builder, so a PYTEST_K-narrowed run is structurally safe to publish — though in practice operators pair it with `--skip-publish` during validation. --- tests/claude_code/publisher.py | 35 +++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/tests/claude_code/publisher.py b/tests/claude_code/publisher.py index 4c3c40bc43b..492d91c6965 100644 --- a/tests/claude_code/publisher.py +++ b/tests/claude_code/publisher.py @@ -642,24 +642,29 @@ def main(argv: Optional[Sequence[str]] = None) -> int: "ANTHROPIC_AUTH_TOKEN": DEFAULT_PROXY_API_KEY, "COMPAT_RESULTS_PATH": str(args.results), } + pytest_cmd = [ + "uv", + "run", + "pytest", + "tests/claude_code/", + "--ignore=tests/claude_code/_driver_unit_tests", + "--ignore=tests/claude_code/_builder_unit_tests", + "--ignore=tests/claude_code/_publisher_unit_tests", + "--ignore=tests/claude_code/_pr_gate_unit_tests", + ] + # Operator escape hatch: PYTEST_K narrows the run to a single + # cell or feature for first-time validation after a CLI/proxy + # upgrade. The matrix builder fills cells we didn't touch with + # `not_tested`, so a PYTEST_K-narrowed run is safe to publish — + # though in practice it's used with --skip-publish. + pytest_k = os.environ.get("PYTEST_K", "").strip() + if pytest_k: + pytest_cmd.extend(["-k", pytest_k]) + print(f"PYTEST_K set; narrowing pytest to: {pytest_k}", flush=True) # Run pytest from inside the worktree so it picks up the # checked-out tag's test code (and its conftest hook), not the # current process's working directory. - subprocess.run( - [ - "uv", - "run", - "pytest", - "tests/claude_code/", - "--ignore=tests/claude_code/_driver_unit_tests", - "--ignore=tests/claude_code/_builder_unit_tests", - "--ignore=tests/claude_code/_publisher_unit_tests", - "--ignore=tests/claude_code/_pr_gate_unit_tests", - ], - env=env, - cwd=args.worktree, - check=False, - ) + subprocess.run(pytest_cmd, env=env, cwd=args.worktree, check=False) if args.skip_publish: print("skip-publish: not opening a PR", flush=True)