Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force clippy to run. #7157

Merged
merged 1 commit into from
Jul 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/bin/cargo/commands/clippy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {

let wrapper = util::process(util::config::clippy_driver());
compile_opts.build_config.primary_unit_rustc = Some(wrapper);
compile_opts.build_config.force_rebuild = true;

ops::compile(&ws, &compile_opts)?;
Ok(())
Expand Down
40 changes: 40 additions & 0 deletions tests/testsuite/clippy.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
use crate::support::{clippy_is_available, project, registry::Package};

#[cargo_test]
// Clippy should never be considered fresh.
fn clippy_force_rebuild() {
if !clippy_is_available() {
return;
}

Package::new("dep1", "0.1.0").publish();

// This is just a random clippy lint (assertions_on_constants) that
// hopefully won't change much in the future.
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.1.0"
[dependencies]
dep1 = "0.1"
"#,
)
.file("src/lib.rs", "pub fn f() { assert!(true); }")
.build();

p.cargo("clippy-preview -Zunstable-options -v")
.masquerade_as_nightly_cargo()
.with_stderr_contains("[..]assert!(true)[..]")
.run();

// Make sure it runs again.
p.cargo("clippy-preview -Zunstable-options -v")
.masquerade_as_nightly_cargo()
.with_stderr_contains("[FRESH] dep1 v0.1.0")
.with_stderr_contains("[..]assert!(true)[..]")
.run();
}
1 change: 1 addition & 0 deletions tests/testsuite/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ mod cargo_features;
mod cfg;
mod check;
mod clean;
mod clippy;
mod collisions;
mod concurrent;
mod config;
Expand Down