Skip to content

Commit

Permalink
Force clippy to run.
Browse files Browse the repository at this point in the history
  • Loading branch information
ehuss committed Jul 20, 2019
1 parent 9f7bd62 commit 1c6d8bb
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
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

0 comments on commit 1c6d8bb

Please sign in to comment.