Skip to content

Commit 6010ef0

Browse files
cliffhallclaude
andcommitted
fix: cover pytest-retry in the no-retry guard; state the overrides limit
Copilot round 6 on #4920: - verify:no-test-retries matches the pytest-retry plugin, its --retries flag and `retries` ini option, and @pytest.mark.retries. - verify:install-fresh documents that it cannot see an edited `overrides` entry: the lockfile records an override's result, not the override. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Signed-off-by: cliffhall <[email protected]>
1 parent 5db6e0d commit 6010ef0

3 files changed

Lines changed: 30 additions & 7 deletions

File tree

‎scripts/verify-install-fresh.mjs‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,13 @@
3535
// versions on disk can all match the lockfile while that is true, so the first
3636
// comparison alone would pass it.
3737
//
38-
// What it does NOT do is look for packages that are installed but absent from
38+
// It does not check `overrides`. npm writes the result of an override into the
39+
// lockfile (the version each package resolved to) but not the override itself,
40+
// so an `overrides` entry edited without re-running `npm install` cannot be
41+
// seen by comparing files; it would take re-resolving the tree, which is what
42+
// `npm install` is for.
43+
//
44+
// What it also does NOT do is look for packages that are installed but absent from
3945
// the lockfile. That needs a walk of `node_modules`, the Inspector's guard does
4046
// not do it either, and the failure it would catch (source importing a leftover
4147
// package) fails CI's build on a fresh install rather than passing silently.

‎scripts/verify-no-test-retries.mjs‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@
2121
// not semantics, so the patterns below are the ones each runner documents:
2222
//
2323
// Vitest `retry:` in a config or a test's options; `--retry` on the CLI
24-
// pytest the `pytest-rerunfailures` / `flaky` plugins, their `--reruns`
25-
// flag, and the `@pytest.mark.flaky` / `@flaky` decorators
24+
// pytest the `pytest-rerunfailures`, `pytest-retry` and `flaky` plugins,
25+
// their `--reruns` / `--retries` flags and `retries` ini option,
26+
// and the `@pytest.mark.flaky` / `@flaky` / `@pytest.mark.retries`
27+
// decorators
2628
//
2729
// A match inside a comment or an ordinary string is still a match: this guard
2830
// cannot parse two languages, and a false positive costs one reworded comment
@@ -71,25 +73,26 @@ export const RULES = [
7173
// Matched against each command of the workflow's `run:` steps.
7274
commands: true,
7375
files: /(?:^|\/)\.github\/workflows\/[^/]+\.ya?ml$/,
74-
pattern: /\b(?:vitest|pytest)\b.*--(?:retry|reruns|force-flaky)\b/,
76+
pattern: /\b(?:vitest|pytest)\b.*--(?:retry|retries|reruns|force-flaky)\b/,
7577
why: "a test runner's retry flag in a workflow",
7678
},
7779
{
7880
id: "pytest-rerun-plugin",
7981
files: /(?:^|\/)(?:pyproject\.toml|uv\.lock)$/,
80-
pattern: /\b(?:pytest-rerunfailures|flaky)\b/,
82+
pattern: /\b(?:pytest-rerunfailures|pytest-retry|flaky)\b/,
8183
why: "a pytest rerun plugin",
8284
},
8385
{
8486
id: "pytest-reruns-flag",
8587
files: /(?:^|\/)(?:pyproject\.toml|pytest\.ini|setup\.cfg|tox\.ini)$/,
86-
pattern: /--reruns\b|--force-flaky\b/,
88+
// The flags, and pytest-retry's `retries = N` ini option.
89+
pattern: /--reruns\b|--retries\b|--force-flaky\b|^\s*retries\s*=/,
8790
why: "pytest's rerun flag",
8891
},
8992
{
9093
id: "pytest-flaky-marker",
9194
files: /\.py$/,
92-
pattern: /@(?:pytest\.mark\.)?flaky\b/,
95+
pattern: /@(?:pytest\.mark\.)?flaky\b|@pytest\.mark\.retries\b/,
9396
why: "pytest's flaky marker",
9497
},
9598
];

‎scripts/verify-no-test-retries.test.mjs‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,20 @@ const cases = [
9494
["pytest-rerun-plugin"],
9595
],
9696
["src/b/pyproject.toml", 'dev = ["flaky>=3"]', ["pytest-rerun-plugin"]],
97+
[
98+
"src/b/pyproject.toml",
99+
'dev = ["pytest-retry>=1.6"]',
100+
["pytest-rerun-plugin"],
101+
],
102+
["src/b/pyproject.toml", 'addopts = "--retries 2"', ["pytest-reruns-flag"]],
103+
["src/b/pyproject.toml", "retries = 2", ["pytest-reruns-flag"]],
104+
["src/b/pyproject.toml", "max_retries = 2", []],
105+
["src/b/tests/test_x.py", "@pytest.mark.retries(2)", ["pytest-flaky-marker"]],
106+
[
107+
".github/workflows/python.yml",
108+
step(" run: uv run pytest --retries 2"),
109+
["workflow-retry-flag"],
110+
],
97111
["src/b/uv.lock", 'name = "pytest-rerunfailures"', ["pytest-rerun-plugin"]],
98112
["src/b/pyproject.toml", 'addopts = "--reruns 3"', ["pytest-reruns-flag"]],
99113
[

0 commit comments

Comments
 (0)