Skip to content

test(verify): pin marker+forceselect pairing invariant (#1632) - #1648

Merged
Sinity merged 1 commit into
masterfrom
feature/test/testmon-marker-guard
May 26, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/test/testmon-marker-guard

Conversation

@Sinity

@Sinity Sinity commented May 26, 2026 •

Copy link
Copy Markdown
Owner

Summary

PR #1550 silently ran ~9,500 tests instead of the affected subset for a full week before being caught — a marker filter (`-m not scale_*`) deactivated pytest-testmon affected selection, with no failing test to surface the regression. This adds two unit tests pinning the marker+`--testmon-forceselect` pairing invariant so the footgun cannot re-land silently. Closes #1632.

Problem

Per pytest-testmon docs, any non-trivial `-m` marker selection deactivates testmon's affected-test selection unless `--testmon-forceselect` is also passed. PR #1550 added the flag; this PR makes sure it stays there.

The existing tests assert specific marker tokens are present (`not scale_medium`, `not scale_large`), so a future change that swaps the marker vocabulary could pass those tests while still removing `--testmon-forceselect`. The new tests assert the conditional invariant directly: IF `-m` is in the command THEN `--testmon-forceselect` is also in the command — independent of the marker tokens themselves.

Solution

Two focused unit tests under `tests/unit/devtools/test_verify.py`:

  • `test_default_testmon_step_pairs_marker_filter_with_forceselect` — the default lane (no flags).
  • `test_skip_slow_testmon_step_keeps_forceselect_with_compound_marker` — `--skip-slow` composes the marker; the pairing must hold.

The assertion message in both tests names #1550 and #1632 so any future failure trace points directly at the regression history.

This matches the recommended Option 3 from #1632:

A meta-test under `tests/unit/devtools/` that constructs the same pytest argv `devtools verify` uses and asserts `--testmon-forceselect` is present whenever `-m` markers are present.

Verification

```
$ pytest tests/unit/devtools/test_verify.py
36 passed (2 new)

$ devtools verify --quick
"exit_code": 0
```

Both new tests pass against current code. To verify they actually catch the regression, I locally deleted the `pytest_cmd.append("--testmon-forceselect")` line in `devtools/verify.py:384` — both new tests fail with the named assertion message, the existing tests fail too.

Summary by CodeRabbit

  • Tests
    • Added regression tests to enforce consistent test execution behavior with marker filtering options.

Review Change Stack

PR #1550 fixed a silent regression where the default ``devtools verify``
pytest step combined ``-m`` marker filters with testmon affected
selection — per pytest-testmon docs, any non-trivial marker selector
deactivates testmon's affected selection unless ``--testmon-forceselect``
is also passed. The bug ran for a full week, every default verify
expanding to ~9,500 tests instead of the affected subset (200-427 s
instead of <10 s), with no failing test surfacing the regression.

This adds two regression tests pinning the invariant:

- ``test_default_testmon_step_pairs_marker_filter_with_forceselect``:
  when the default lane includes ``-m`` markers, ``--testmon-forceselect``
  must also be in the command. The assertion message names #1550 and
  #1632 so any future regression points directly at this guard.
- ``test_skip_slow_testmon_step_keeps_forceselect_with_compound_marker``:
  ``--skip-slow`` composes ``and not slow`` into the marker expression;
  the pairing invariant still holds.

These complement the existing
``test_marker_filters_keep_testmon_selection_forced`` and
``test_skip_slow_composes_with_forced_testmon_selection``. The
existing tests assert specific marker tokens are present; the new
tests assert the conditional invariant directly (IF -m present THEN
--testmon-forceselect present), so a future change that swaps the
marker tokens still trips the guard.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented May 26, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 32f6edfe-d40c-44b9-80ca-5a66a8de5cce

📥 Commits

Reviewing files that changed from the base of the PR and between 70f5f16 and b296b1c.

📒 Files selected for processing (1)
  • tests/unit/devtools/test_verify.py

📝 Walkthrough

Walkthrough

Two unit tests enforce a regression guard that ensures any -m marker filter in the default pytest testmon lane is paired with --testmon-forceselect. One test covers the baseline case; the second verifies the same invariant holds when --skip-slow is enabled, preventing marker filter composition from silencing testmon selection.

Changes

Testmon Marker Filter Regression Guard

Layer / File(s) Summary
Regression guard tests for marker filter pairing
tests/unit/devtools/test_verify.py
test_default_testmon_step_pairs_marker_filter_with_forceselect asserts --testmon-forceselect is present whenever -m is in the pytest testmon step. test_skip_slow_testmon_step_keeps_forceselect_with_compound_marker verifies the same invariant holds when skip_slow=True, ensuring marker filter composition does not drop the forceselect flag.

🎯 2 (Simple) | ⏱️ ~8 minutes

🐰 Two tests hop into the testmon field,
To guard against selection that's concealed,
When markers dance with -m in the command line,
--testmon-forceselect must align!
A regression ward, tested twice, so fine! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically identifies the main change: adding tests to enforce a marker+forceselect pairing invariant, directly addressing issue #1632.
Description check ✅ Passed The description covers Summary, Problem, Solution, and Verification sections. The Changelog and Risks sections are appropriately omitted as this is a test-only PR per template guidelines.
Linked Issues check ✅ Passed The PR implements Option 3 (recommended) from #1632: meta-tests asserting --testmon-forceselect is present whenever -m markers are used, meeting the stated acceptance criteria.
Out of Scope Changes check ✅ Passed All changes are focused test additions to enforce a specific regression guard; no unrelated code modifications or scope creep detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/test/testmon-marker-guard

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Sinity
Sinity merged commit 055b4a1 into master May 26, 2026
4 checks passed
@Sinity
Sinity deleted the feature/test/testmon-marker-guard branch May 26, 2026 19:38
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.

verify: guard against silent testmon selection deactivation

1 participant