Repository navigation
Commit dd6cff5
committed
ci(triage): detect harness test attributes, not just #[test]
The needs-tests detector matched an added `#[test]` or `#[cfg(test)]` line
and nothing else, so it missed every test written with a harness attribute.
That is most of this repo: 345 `#[tokio::test]` and 189 `#[sqlx::test]`
against 540 bare `#[test]`. Any PR whose tests are all DB or async tests got
labeled needs-tests, which is what happened on #275 (three added
`#[sqlx::test]` functions) and #262 (eight).
Match an added attribute whose last path component contains `test`, followed
by `]` or `(`. That covers the four forms in the tree today and the harnesses
a contributor might reach for later (`#[rstest]`, `#[test_case]`,
`#[wasm_bindgen_test]`) without enumerating them.
Deliberately not keying on an added `assert!`: a production assertion is
ordinary Rust, so that signal would let a testless PR clear the label
silently. The label is a nudge, so it should fail loud. Labeling a PR that
did add tests gets corrected by the author; clearing one that did not is
invisible.
Anchoring to the start of the added line also drops three false positives the
old `.*` prefix accepted: a comment, a string literal, and a doc example that
merely mention `#[test]`.
Verified against the real patches of 14 open PRs: #275 and #262 stop being
labeled, both of which do add tests, and no other verdict changes.1 parent c926e1e commit dd6cff5
1 file changed
Lines changed: 15 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
73 | 87 | | |
74 | 88 | | |
75 | | - | |
| 89 | + | |
76 | 90 | | |
77 | 91 | | |
78 | 92 | | |
| |||
0 commit comments