diff options
| author | bors <bors@rust-lang.org> | 2021-04-29 12:03:43 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-04-29 12:03:43 +0000 |
| commit | 10a51c0ac07ee5c5388d075c8209c8bef51069cf (patch) | |
| tree | 82074dd3ca0a399c03148857ee44cac6891961fa /src/bootstrap | |
| parent | 78c963945aa35a76703bf62e024af2d85b2796e2 (diff) | |
| parent | 8c25e27f1676ac40918731975cbcd47c6acff0a7 (diff) | |
| download | rust-10a51c0ac07ee5c5388d075c8209c8bef51069cf.tar.gz rust-10a51c0ac07ee5c5388d075c8209c8bef51069cf.zip | |
Auto merge of #84189 - jyn514:clippy-dev, r=Mark-Simulacrum
Implement `x.py test src/tools/clippy --bless` - Add clippy_dev to the rust workspace Before, it would give an error that it wasn't either included or excluded from the workspace: ``` error: current package believes it's in a workspace when it's not: current: /home/joshua/rustc/src/tools/clippy/clippy_dev/Cargo.toml workspace: /home/joshua/rustc/Cargo.toml this may be fixable by adding `src/tools/clippy/clippy_dev` to the `workspace.members` array of the manifest located at: /home/joshua/rustc/Cargo.toml Alternatively, to keep it out of the workspace, add the package to the `workspace.exclude` array, or add an empty `[workspace]` table to the package's manifest. ``` - Change clippy's copy of compiletest not to special-case rust-lang/rust. Using OUT_DIR confused `clippy_dev` and it couldn't find the test outputs. This is one of the reasons why `cargo dev bless` used to silently do nothing (the others were that `CARGO_TARGET_DIR` and `PROFILE` weren't set appropriately). - Run clippy_dev on test failure I tested this by removing a couple lines from a stderr file, and they were correctly replaced. - Fix clippy_dev warnings
Diffstat (limited to 'src/bootstrap')
| -rw-r--r-- | src/bootstrap/builder.rs | 5 | ||||
| -rw-r--r-- | src/bootstrap/test.rs | 20 |
2 files changed, 25 insertions, 0 deletions
diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 38901a35296..62a3a87eeb8 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -1627,6 +1627,11 @@ impl Cargo { pub fn add_rustc_lib_path(&mut self, builder: &Builder<'_>, compiler: Compiler) { builder.add_rustc_lib_path(compiler, &mut self.command); } + + pub fn current_dir(&mut self, dir: &Path) -> &mut Cargo { + self.command.current_dir(dir); + self + } } impl From<Cargo> for Command { diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index b9d7ecf8c0e..965d1162145 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -632,6 +632,26 @@ impl Step for Clippy { cargo.add_rustc_lib_path(builder, compiler); + if builder.try_run(&mut cargo.into()) { + // The tests succeeded; nothing to do. + return; + } + + if !builder.config.cmd.bless() { + std::process::exit(1); + } + + let mut cargo = builder.cargo(compiler, Mode::ToolRustc, SourceType::InTree, host, "run"); + cargo.arg("-p").arg("clippy_dev"); + // clippy_dev gets confused if it can't find `clippy/Cargo.toml` + cargo.current_dir(&builder.src.join("src").join("tools").join("clippy")); + if builder.config.rust_optimize { + cargo.env("PROFILE", "release"); + } else { + cargo.env("PROFILE", "debug"); + } + cargo.arg("--"); + cargo.arg("bless"); builder.run(&mut cargo.into()); } } |
