Skip to content

Commit ad97d81

Browse files
committed
Should be final writing_tests commit
1 parent 32dc7c5 commit ad97d81

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

book/src/development/writing_tests.md

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,13 @@ As we gradually implement our lint logic, we will keep running this UI test comm
8888
Clippy will begin outputting information that allows us to check if the output is
8989
turning into what we want it to be.
9090

91+
blyxyas marked this conversation as resolved.
9192
### Example output
9293

9394
As our `foo_functions` lint is tested, the output would look something like this:
9495

9596
```
9697
failures:
97-
9898
---- compile_test stdout ----
9999
normalized stderr:
100100
error: function called "foo"
@@ -104,19 +104,16 @@ LL | pub fn foo(&self) {}
104104
| ^^^
105105
|
106106
= note: `-D clippy::foo-functions` implied by `-D warnings`
107-
108107
error: function called "foo"
109108
--> $DIR/foo_functions.rs:13:8
110109
|
111110
LL | fn foo(&self) {}
112111
| ^^^
113-
114112
error: function called "foo"
115113
--> $DIR/foo_functions.rs:19:4
116114
|
117115
LL | fn foo() {}
118116
| ^^^
119-
120117
error: aborting due to 3 previous errors
121118
```
122119

@@ -191,23 +188,23 @@ and prepending the `TESTNAME` variable to `cargo uitest` works for Cargo lints t
191188

192189
## Rustfix Tests
193190

194-
If the lint you are working on is making use of structured suggestions, the test
195-
file should include a `// run-rustfix` comment at the top.
191+
If the lint you are working on is making use of structured suggestions,
192+
`rustfix` will apply the suggestions from the lint to the test file code and
193+
compare that to the contents of a `.fixed` file.
196194

197195
Structured suggestions tell a user how to fix or re-write certain code that has
198196
been linted with [`span_lint_and_sugg`].
199197

200-
The `// run-rustfix` comment will additionally run [rustfix] for our test.
201-
Rustfix will apply the suggestions from the lint to the test file code and
202-
compare that to the contents of a `.fixed` file.
198+
Should `span_lint_and_sugg` be used to generate a suggestion, but not all
199+
suggestions lead to valid code, you can use the `//@no-rustfix` comment on top
200+
of the test file, to not run `rustfix` on that file.
203201

204202
We'll talk about suggestions more in depth in a later chapter.
205203
<!-- FIXME: (blyxyas) Link to "Emitting lints" when that gets merged -->
206204

207205
Use `cargo bless` to automatically generate the `.fixed` file after running
208206
the tests.
209207

210-
[rustfix]: https://github.com/rust-lang/rustfix
211208
[`span_lint_and_sugg`]: https://doc.rust-lang.org/beta/nightly-rustc/clippy_utils/diagnostics/fn.span_lint_and_sugg.html
212209

213210
## Testing Manually

0 commit comments

Comments
 (0)