Relax fs layout so that multiple pass/fail manifests are possible
This commit is contained in:
parent
1a04686fc0
commit
f9013ff197
@ -43,7 +43,7 @@ case), and we don't need type information so it will have an early pass type
|
||||
(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. For cargo lints,
|
||||
two project hierarchies (fail/pass) will be created under `tests/ui-cargo`.
|
||||
two project hierarchies (fail/pass) will be created by default under `tests/ui-cargo`.
|
||||
|
||||
Next, we'll open up these files and add our lint!
|
||||
|
||||
@ -110,12 +110,17 @@ 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:
|
||||
the `Cargo.toml` manifest file. We also need a minimal crate associated
|
||||
with that manifest.
|
||||
|
||||
If our new lint is named e.g. `foo_categories`, after running `cargo dev new_lint`
|
||||
we will find by default two new crates, each with its manifest file:
|
||||
|
||||
* `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.
|
||||
|
||||
If you need more cases, you can copy one of those crates (under `foo_categories`) and rename it.
|
||||
|
||||
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`.
|
||||
|
@ -174,9 +174,13 @@ fn run_ui_cargo(config: &mut compiletest::Config) {
|
||||
_ => {},
|
||||
}
|
||||
|
||||
for case in &["pass", "fail"] {
|
||||
let tail: PathBuf = [case, "src"].iter().collect();
|
||||
let src_path = dir_path.join(tail);
|
||||
for case in fs::read_dir(&dir_path)? {
|
||||
let case = case?;
|
||||
if !case.file_type()?.is_dir() {
|
||||
continue;
|
||||
}
|
||||
|
||||
let src_path = case.path().join("src");
|
||||
env::set_current_dir(&src_path)?;
|
||||
|
||||
for file in fs::read_dir(&src_path)? {
|
||||
|
Loading…
Reference in New Issue
Block a user