Skip to content

Fix vacuous CI matrix meta-test and add missing entries#3129

Closed
adamtheturtle wants to merge 4 commits intomainfrom
adamtheturtle/verify-issue-3128
Closed

Fix vacuous CI matrix meta-test and add missing entries#3129
adamtheturtle wants to merge 4 commits intomainfrom
adamtheturtle/verify-issue-3128

Conversation

@adamtheturtle
Copy link
Copy Markdown
Member

@adamtheturtle adamtheturtle commented Apr 25, 2026

Summary

  • Fixes ci/test_custom_linters.py meta-tests pass vacuously: capsys does not capture in-process pytest.main() output #3128. ci/test_custom_linters.py::test_tests_collected_once was passing vacuously because the in-process pytest.main() installed its own capture, so capsys returned an empty string and every pattern collected 0 tests.
  • Replaces the stdout-parsing approach with a small pytest plugin that hooks pytest_collection_modifyitems and reads node IDs directly — still in-process (no subprocess overhead), and the meta-test now does real work (~89s vs 1.6s).
  • Adds the matrix entries the now-working meta-test surfaces: tests/mock_vws/test_respx_mock_usage.py, tests/mock_vws/test_target_validators.py, docs/source/httpx-example.rst, and ci/ (so the meta-tests themselves run in CI).

Test plan

  • uv run --extra=dev python -m pytest -v ci/test_custom_linters.py — both tests pass and runtime reflects real collection work.

Note

Medium Risk
Touches CI workflow matrix and the meta-test that validates it; risk is mainly false positives/negatives or increased CI runtime due to real collection across patterns.

Overview
Fixes the ci/test_custom_linters.py meta-tests so they no longer pass vacuously: replaces stdout parsing/capsys with an in-process pytest collection plugin (pytest_collection_modifyitems) that records collected node IDs and asserts collection succeeds.

Updates the GitHub Actions ci_pattern matrix in .github/workflows/test.yml to include previously unlisted test/doc/ci/ paths that the now-working meta-test detects (so all patterns are validated and the meta-tests themselves run in CI).

Reviewed by Cursor Bugbot for commit d907796. Bugbot is set up for automated code reviews on this repo. Configure here.

The in-process pytest.main() in ci/test_custom_linters.py installs its
own capture, so capsys saw an empty string and tests passed vacuously.
Switch to a collection-hook plugin that reads node IDs directly. This
surfaces three test files missing from the ci-tests matrix
(test_respx_mock_usage.py, test_target_validators.py,
docs/source/httpx-example.rst) plus the meta-tests themselves; add
them. Closes #3128.
Comment thread ci/test_custom_linters.py
Previously ran pytest.main() per pattern (~120 invocations, 89s). Now
do a single in-process collection and check each pattern against the
cached node IDs in pure Python via a small boundary-aware prefix
matcher. Runtime drops from 89s to under 1s.
Previously the return code of pytest.main() was discarded, so a
collection error (import failure, syntax error) would silently leave
the fixture with whatever items were captured before the crash. Assert
the exit code is OK so collection errors fail the meta-tests loudly.
The prefix-matching shortcut was a hand-rolled approximation of
pytest's selector. Go back to invoking pytest.main() per pattern so
selection matches CI exactly, even though it's slower (~89s). Keep the
exit-code assertion so collection errors fail loudly.
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit d907796. Configure here.

Comment thread ci/test_custom_linters.py
tests = _tests_from_pattern(ci_pattern=ci_pattern)
message = f'"{ci_pattern}" does not match any tests.'
assert collect_only_result == 0, message
assert tests, message
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Custom error message in test_ci_patterns_valid is unreachable

Low Severity

When a CI pattern matches no tests, pytest.main(--collect-only) returns ExitCode.NO_TESTS_COLLECTED (5), not ExitCode.OK. The hard assert exit_code == pytest.ExitCode.OK inside _tests_from_pattern fires first, so the function can never return an empty set. This makes the assert tests, message check in test_ci_patterns_valid dead code — the helpful "…does not match any tests" message is unreachable, replaced by a less informative "Collection…failed with exit code" error.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit d907796. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ci/test_custom_linters.py meta-tests pass vacuously: capsys does not capture in-process pytest.main() output

1 participant