Skip to content

Commit 96a3dec

Browse files
committed
sembr src/tests/best-practices.md
1 parent 2a581c4 commit 96a3dec

1 file changed

Lines changed: 25 additions & 25 deletions

File tree

src/tests/best-practices.md

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ a bunch of git archeology.
77

88
It's good practice to review the test that you authored by pretending that you
99
are a different contributor who is looking at the test that failed several years
10-
later without much context (this also helps yourself even a few days or months
11-
later!). Then ask yourself: how can I make my life and their lives easier?
10+
later without much context (this also helps yourself even a few days or months later!).
11+
Then ask yourself: how can I make my life and their lives easier?
1212

1313
To help put this into perspective, let's start with an aside on how to write a
1414
test that makes the life of another contributor as hard as possible.
@@ -35,15 +35,14 @@ test that makes the life of another contributor as hard as possible.
3535

3636
Make it easy for the reader to immediately understand what the test is
3737
exercising, instead of having to type in the issue number and dig through github
38-
search for what the test is trying to exercise. This has an additional benefit
39-
of making the test possible to be filtered via `--test-args` as a collection of
40-
related tests.
38+
search for what the test is trying to exercise.
39+
This has an additional benefit
40+
of making the test possible to be filtered via `--test-args` as a collection of related tests.
4141

4242
- Name the test after what it's trying to exercise or prevent regressions of.
4343
- Keep it concise.
4444
- Avoid using issue numbers alone as test names.
45-
- Avoid starting the test name with `issue-xxxxx` prefix as it degrades
46-
auto-completion.
45+
- Avoid starting the test name with `issue-xxxxx` prefix as it degrades auto-completion.
4746

4847
> **Avoid using only issue numbers as test names**
4948
>
@@ -78,21 +77,22 @@ related tests.
7877
7978
## Test organization
8079
81-
- For most test suites, try to find a semantically meaningful subdirectory to
82-
home the test.
80+
- For most test suites, try to find a semantically meaningful subdirectory to home the test.
8381
- E.g. for an implementation of RFC 2093 specifically, we can group a
84-
collection of tests under `tests/ui/rfc-2093-infer-outlives/`. For the
85-
directory name, include what the RFC is about.
82+
collection of tests under `tests/ui/rfc-2093-infer-outlives/`.
83+
For the directory name, include what the RFC is about.
8684
- For the [`run-make`]/`run-make-support` test suites, each `rmake.rs` must
8785
be contained within an immediate subdirectory under `tests/run-make/` or
88-
`tests/run-make-cargo/` respectively. Further nesting is not presently
89-
supported. Avoid using _only_ an issue number for the test name as well.
86+
`tests/run-make-cargo/` respectively.
87+
Further nesting is not presently supported.
88+
Avoid using _only_ an issue number for the test name as well.
9089
9190
## Test descriptions
9291
9392
To help other contributors understand what the test is about if their changes
9493
lead to the test failing, we should make sure a test has sufficient docs about
95-
its intent/purpose, links to relevant context (incl. issue numbers or other
94+
its intent/purpose, links to relevant context (incl.
95+
issue numbers or other
9696
discussions) and possibly relevant resources (e.g. can be helpful to link to
9797
Win32 APIs for specific behavior).
9898
@@ -136,8 +136,8 @@ fn main() {
136136
}
137137
```
138138
139-
For how much context/explanation is needed, it is up to the author and
140-
reviewer's discretion. A good rule of thumb is non-trivial things exercised in
139+
For how much context/explanation is needed, it is up to the author and reviewer's discretion.
140+
A good rule of thumb is non-trivial things exercised in
141141
the test deserves some explanation to help other contributors to understand.
142142
This may include remarks on:
143143

@@ -159,17 +159,17 @@ This may include remarks on:
159159

160160
## Flaky tests
161161

162-
All tests need to strive to be reproducible and reliable. Flaky tests are the
163-
worst kind of tests, arguably even worse than not having the test in the first
162+
All tests need to strive to be reproducible and reliable.
163+
Flaky tests are the worst kind of tests, arguably even worse than not having the test in the first
164164
place.
165165

166166
- Flaky tests can fail in completely unrelated PRs which can confuse other
167-
contributors and waste their time trying to figure out if test failure is
168-
related.
167+
contributors and waste their time trying to figure out if test failure is related.
169168
- Flaky tests provide no useful information from its test results other than
170-
it's flaky and not reliable: if a test passed but it's flakey, did I just get
171-
lucky? if a test is flakey but it failed, was it just spurious?
172-
- Flaky tests degrade confidence in the whole test suite. If a test suite can
169+
it's flaky and not reliable: if a test passed but it's flakey, did I just get lucky?
170+
if a test is flakey but it failed, was it just spurious?
171+
- Flaky tests degrade confidence in the whole test suite.
172+
If a test suite can
173173
randomly spuriously fail due to flaky tests, did the whole test suite pass or
174174
did I just get lucky/unlucky?
175175
- Flaky tests can randomly fail in full CI, wasting previous full CI resources.
@@ -189,8 +189,8 @@ See [compiletest directives] for a listing of directives.
189189
See [LLVM FileCheck guide][FileCheck] for details.
190190

191191
- Avoid matching on specific register numbers or basic block numbers unless
192-
they're special or critical for the test. Consider using patterns to match
193-
them where suitable.
192+
they're special or critical for the test.
193+
Consider using patterns to match them where suitable.
194194

195195
> **TODO**
196196
>

0 commit comments

Comments
 (0)