Skip to content

Commit bbdfd18

Browse files
jieyouxuUrgau
authored andcommitted
Revise test naming advice to discourage using issue numbers alone
But accept test names that include non-prefix issue number.
1 parent 0cd0a74 commit bbdfd18

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

src/tests/best-practices.md

+14-8
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ test that makes the life of another contributor as hard as possible.
1717
>
1818
> To make the life of another contributor as hard as possible, one might:
1919
>
20-
> - Only name the test after an issue, e.g. `issue-123456.rs`.
20+
> - Name the test after an issue number alone without any other context, e.g.
21+
> `issue-123456.rs`.
2122
> - Have no comments at all on what the test is trying to exercise, no links to
2223
> relevant context.
2324
> - Include a test that is massive (that can otherwise be minimized) and
@@ -40,23 +41,28 @@ related tests.
4041

4142
- Name the test after what it's trying to exercise or prevent regressions of.
4243
- Keep it concise.
43-
- Avoid including issue numbers in test names.
44+
- Avoid using issue numbers alone as test names.
45+
- Avoid starting the test name with `issue-xxxxx` prefix as it degrades
46+
auto-completion.
4447

45-
> **Avoid issue numbers in test names**
48+
> **Avoid using only issue numbers as test names**
4649
>
47-
> Prefer including them as links or `#123456` in test comments instead.
50+
> Prefer including them as links or `#123456` in test comments instead. Or if it
51+
> makes sense to include the issue number, also include brief keywords like
52+
> `macro-external-span-ice-123956.rs`.
4853
>
4954
> ```text
5055
> tests/ui/typeck/issue-123456.rs // bad
51-
> tests/ui/typeck/issue-123456-asm-macro-external-span-ice.rs // bad
56+
> tests/ui/typeck/issue-123456-asm-macro-external-span-ice.rs // bad (for tab completion)
57+
> tests/ui/typeck/asm-macro-external-span-ice-123456.rs // good
5258
> tests/ui/typeck/asm-macro-external-span-ice.rs // good
5359
> ```
5460
>
5561
> `issue-123456.rs` does not tell you immediately anything about what the test
5662
> is actually exercising meaning you need to do additional searching. Including
57-
> the issue number in the test name is really noisy for finding relevant tests
58-
> by what they're exercising (if you `ls` a test directory and get a bunch of
59-
> `issue-xxxxx` prefixes). We can link to the issue in a test comment.
63+
> the issue number in the test name as a prefix makes tab completion less useful
64+
> (if you `ls` a test directory and get a bunch of `issue-xxxxx` prefixes). We
65+
> can link to the issue in a test comment.
6066
>
6167
> ```rs
6268
> //! Check that `asm!` macro including nested macros that come from external

0 commit comments

Comments
 (0)