Skip to content

Commit

Permalink
switch from unused_imports to deprecated to test unfixable warnings
Browse files Browse the repository at this point in the history
The unused_imports warning is going to emit fixable suggestions in the
near future, but that means parts of the cargo's test suite will break.
This commit switches the tests to use the deprecated warning, which
*shouldn't* be fixable at all.
  • Loading branch information
pietroalbini committed Feb 10, 2019
1 parent 9b5d4b7 commit ea9cd6e
Showing 1 changed file with 38 additions and 25 deletions.
63 changes: 38 additions & 25 deletions tests/testsuite/fix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -702,11 +702,11 @@ fn fix_features() {
#[test]
fn shows_warnings() {
let p = project()
.file("src/lib.rs", "use std::default::Default; pub fn foo() {}")
.file("src/lib.rs", "#[deprecated] fn bar() {} pub fn foo() { let _ = bar(); }")
.build();

p.cargo("fix --allow-no-vcs")
.with_stderr_contains("[..]warning: unused import[..]")
.with_stderr_contains("[..]warning: use of deprecated item[..]")
.run();
}

Expand Down Expand Up @@ -984,20 +984,22 @@ fn shows_warnings_on_second_run_without_changes() {
.file(
"src/lib.rs",
r#"
use std::default::Default;
#[deprecated]
fn bar() {}
pub fn foo() {
let _ = bar();
}
"#,
)
.build();

p.cargo("fix --allow-no-vcs")
.with_stderr_contains("[..]warning: unused import[..]")
.with_stderr_contains("[..]warning: use of deprecated item[..]")
.run();

p.cargo("fix --allow-no-vcs")
.with_stderr_contains("[..]warning: unused import[..]")
.with_stderr_contains("[..]warning: use of deprecated item[..]")
.run();
}

Expand All @@ -1007,65 +1009,76 @@ fn shows_warnings_on_second_run_without_changes_on_multiple_targets() {
.file(
"src/lib.rs",
r#"
use std::default::Default;
#[deprecated]
fn bar() {}
pub fn a() -> u32 { 3 }
pub fn foo() {
let _ = bar();
}
"#,
)
.file(
"src/main.rs",
r#"
use std::default::Default;
fn main() { println!("3"); }
#[deprecated]
fn bar() {}
fn main() {
let _ = bar();
}
"#,
)
.file(
"tests/foo.rs",
r#"
use std::default::Default;
#[deprecated]
fn bar() {}
#[test]
fn foo_test() {
println!("3");
let _ = bar();
}
"#,
)
.file(
"tests/bar.rs",
r#"
use std::default::Default;
#[deprecated]
fn bar() {}
#[test]
fn foo_test() {
println!("3");
let _ = bar();
}
"#,
)
.file(
"examples/fooxample.rs",
r#"
use std::default::Default;
#[deprecated]
fn bar() {}
fn main() {
println!("3");
let _ = bar();
}
"#,
)
.build();

p.cargo("fix --allow-no-vcs --all-targets")
.with_stderr_contains(" --> examples/fooxample.rs:2:21")
.with_stderr_contains(" --> src/lib.rs:2:21")
.with_stderr_contains(" --> src/main.rs:2:21")
.with_stderr_contains(" --> tests/bar.rs:2:21")
.with_stderr_contains(" --> tests/foo.rs:2:21")
.with_stderr_contains(" --> examples/fooxample.rs:6:29")
.with_stderr_contains(" --> src/lib.rs:6:29")
.with_stderr_contains(" --> src/main.rs:6:29")
.with_stderr_contains(" --> tests/bar.rs:7:29")
.with_stderr_contains(" --> tests/foo.rs:7:29")
.run();

p.cargo("fix --allow-no-vcs --all-targets")
.with_stderr_contains(" --> examples/fooxample.rs:2:21")
.with_stderr_contains(" --> src/lib.rs:2:21")
.with_stderr_contains(" --> src/main.rs:2:21")
.with_stderr_contains(" --> tests/bar.rs:2:21")
.with_stderr_contains(" --> tests/foo.rs:2:21")
.with_stderr_contains(" --> examples/fooxample.rs:6:29")
.with_stderr_contains(" --> src/lib.rs:6:29")
.with_stderr_contains(" --> src/main.rs:6:29")
.with_stderr_contains(" --> tests/bar.rs:7:29")
.with_stderr_contains(" --> tests/foo.rs:7:29")
.run();
}

Expand Down

0 comments on commit ea9cd6e

Please sign in to comment.