Skip to content

Commit 34cd948

Browse files
authored
Fix diagnostic paths printed by dogfood test (#14746)
Where you would previously see ``` error: some lint --> src/lib.rs:1:2 ``` it will now print ``` error: some lint --> clippy_lints/src/lib.rs:1:2 ``` Ensuring you can click the link in the terminal A workaround for us not being in a workspace changelog: none
2 parents ca62816 + 772ea35 commit 34cd948

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

tests/dogfood.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ fn dogfood() {
4444
"rustc_tools_util",
4545
] {
4646
println!("linting {package}");
47-
if !run_clippy_for_package(package, &["-D", "clippy::all", "-D", "clippy::pedantic"]) {
48-
failed_packages.push(if package.is_empty() { "root" } else { package });
47+
if !run_clippy_for_package(package) {
48+
failed_packages.push(package);
4949
}
5050
}
5151

@@ -57,7 +57,7 @@ fn dogfood() {
5757
}
5858

5959
#[must_use]
60-
fn run_clippy_for_package(project: &str, args: &[&str]) -> bool {
60+
fn run_clippy_for_package(project: &str) -> bool {
6161
let root_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
6262

6363
let mut command = Command::new(&*test_utils::CARGO_CLIPPY_PATH);
@@ -79,15 +79,17 @@ fn run_clippy_for_package(project: &str, args: &[&str]) -> bool {
7979
}
8080
}
8181

82-
command.arg("--").args(args);
82+
command.arg("--");
8383
command.arg("-Cdebuginfo=0"); // disable debuginfo to generate less data in the target dir
84-
command.args(["-D", "clippy::dbg_macro"]);
85-
84+
command.args(["-D", "clippy::all", "-D", "clippy::pedantic", "-D", "clippy::dbg_macro"]);
8685
if !cfg!(feature = "internal") {
8786
// running a clippy built without internal lints on the clippy source
88-
// that contains e.g. `allow(clippy::invalid_paths)`
87+
// that contains e.g. `allow(clippy::symbol_as_str)`
8988
command.args(["-A", "unknown_lints"]);
9089
}
9190

91+
// Workaround for not being a workspace, add the crate's directory back to the path
92+
command.args(["--remap-path-prefix", &format!("={project}")]);
93+
9294
command.status().unwrap().success()
9395
}

0 commit comments

Comments
 (0)