about summary refs log tree commit diff
path: root/doc
diff options
context:
space:
mode:
authorEduardo Broto <ebroto@tutanota.com>2020-05-18 21:39:56 +0200
committerEduardo Broto <ebroto@tutanota.com>2020-05-21 14:11:11 +0200
commit5d0135e222448e637ec1d66b3dd5c0805884dedd (patch)
tree8de4aee122a73a75f3b483121f642c932b193957 /doc
parent1eb6adf47579e3c56b38ba6cce7676e8d2d5beb0 (diff)
Add documentation for testing cargo lints
Diffstat (limited to 'doc')
-rw-r--r--doc/adding_lints.md19
1 files changed, 17 insertions, 2 deletions
diff --git a/doc/adding_lints.md b/doc/adding_lints.md
index 9ad1315c175..75768681db9 100644
--- a/doc/adding_lints.md
+++ b/doc/adding_lints.md
@@ -42,8 +42,10 @@ case), and we don't need type information so it will have an early pass type
 `cargo dev new_lint --name=foo_functions --pass=early --category=pedantic`
 (category will default to nursery if not provided). This command will create
 two files: `tests/ui/foo_functions.rs` and `clippy_lints/src/foo_functions.rs`,
-as well as run `cargo dev update_lints` to register the new lint. Next, we'll
-open up these files and add our lint!
+as well as run `cargo dev update_lints` to register the new lint. For cargo lints,
+two project hierarchies (fail/pass) will be created under `tests/ui-cargo`.
+
+Next, we'll open up these files and add our lint!
 
 ## Testing
 
@@ -105,6 +107,19 @@ our lint, we need to commit the generated `.stderr` files, too. In general, you
 should only commit files changed by `tests/ui/update-all-references.sh` for the
 specific lint you are creating/editing.
 
+### Cargo lints
+
+For cargo lints, the process of testing differs in that we are interested in
+the contents of the `Cargo.toml` files. If our new lint is named e.g. `foo_categories`,
+after running `cargo dev new_lint` we will find two new manifest files:
+
+* `tests/ui-cargo/foo_categories/fail/Cargo.toml`: this file should cause the new lint to raise an error.
+* `tests/ui-cargo/foo_categories/pass/Cargo.toml`: this file should not trigger the lint.
+
+The process of generating the `.stderr` file is the same, and prepending the `TESTNAME`
+variable to `cargo uitest` works too, but the script to update the references
+is in another path: `tests/ui-cargo/update-all-references.sh`.
+
 ## Rustfix tests
 
 If the lint you are working on is making use of structured suggestions, the