Skip to content

Commit 1989fcc

Browse files
authored
Merge pull request #202 from euxaristia/fix/pr-triage-async-test-detection
fix(ci): recognize namespaced test attributes in pr-triage's needs-tests check
2 parents 5981257 + 13f6948 commit 1989fcc

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

‎.github/workflows/pr-triage.yml‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,15 @@ jobs:
7070
const changedRust = names.some(n => n.startsWith("crates/") && n.endsWith(".rs"));
7171
// A test can live in a tests/ dir, a *_test.rs file, or (the common Rust
7272
// pattern) an inline #[test] / #[cfg(test)] block added inside the source file.
73+
// Async tests use a namespaced attribute (#[tokio::test], #[async_std::test],
74+
// possibly with args like #[tokio::test(flavor = ...)]) rather than the bare
75+
// #[test]. Match only on added lines, with the attribute at the start of the
76+
// line after horizontal whitespace, covering bare, cfg(test), namespaced,
77+
// optional leading ::, and raw-identifier (r#test) forms. No head-file fetch
78+
// or lexer: needs-tests is advisory, not a merge gate.
7379
const addsInlineTest = files.some(f =>
7480
f.filename.endsWith(".rs") && f.patch &&
75-
/^\+.*#\[(test\]|cfg\(test\))/m.test(f.patch));
81+
/^\+[ \t]*#\[[ \t]*(?:cfg[ \t]*\([ \t]*test[ \t]*\)|(?:::[ \t]*)?(?:[\w-]+[ \t]*::[ \t]*)*(?:r#)?test\b)/m.test(f.patch));
7682
const touchedTests =
7783
names.some(n => n.includes("/tests/") || n.endsWith("_test.rs")) || addsInlineTest;
7884
if (changedRust && !touchedTests) want.add("needs-tests");

0 commit comments

Comments
 (0)