Skip to content
Closed
Show file tree
Hide file tree
Changes from 5 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/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ pub fn cli() -> App {
"Check all targets",
)
.arg_release("Check artifacts in release mode, with optimizations")
.arg_force_rebuild("Force rebuild of this crate")
.arg(opt("profile", "Profile to build the selected target for").value_name("PROFILE"))
.arg_features()
.arg_target_triple("Check for the target triple")
Expand Down
5 changes: 5 additions & 0 deletions src/cargo/util/command_prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@ pub trait AppExt: Sized {
fn arg_dry_run(self, dry_run: &'static str) -> Self {
self._arg(opt("dry-run", dry_run))
}

fn arg_force_rebuild(self, force_rebuild: &'static str) -> Self {
self._arg(opt("force-rebuild", force_rebuild))
}
}

impl AppExt for App {
Expand Down Expand Up @@ -315,6 +319,7 @@ pub trait ArgMatchesExt {
build_config.message_format = message_format;
build_config.release = self._is_present("release");
build_config.build_plan = self._is_present("build-plan");
build_config.force_rebuild = self._is_present("force-rebuild");
if build_config.build_plan && !config.cli_unstable().unstable_options {
Err(failure::format_err!(
"`--build-plan` flag is unstable, pass `-Z unstable-options` to enable it"
Expand Down
20 changes: 20 additions & 0 deletions tests/testsuite/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,26 @@ fn build_check() {
foo.cargo("check").run();
}

// Checks that --force-rebuild displays warnings even if the project has not changed
// since the last check/build
#[test]
fn force_rebuild_displays_error() {
let foo = project()
.file(
"src/main.rs",
"use std::default::Default; fn main() {}",
)
.build();

foo.cargo("check")
.with_stderr_contains("[..]warning: unused import[..]")
.run();

foo.cargo("check --force-rebuild")
.with_stderr_contains("[..]warning: unused import[..]")
.run();
}

// Checks that where a project has both a lib and a bin, the lib is only checked
// not built.
#[test]
Expand Down
16 changes: 0 additions & 16 deletions tests/testsuite/profile_targets.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use crate::support::is_nightly;
use crate::support::{basic_manifest, project, Project};

// These tests try to exercise exactly which profiles are selected for every
Expand Down Expand Up @@ -454,11 +453,6 @@ fn profile_selection_bench() {

#[test]
fn profile_selection_check_all_targets() {
if !is_nightly() {
// This can be removed once 1.27 is stable, see below.
return;
}

let p = all_target_project();
// check
// NOTES:
Expand Down Expand Up @@ -525,11 +519,6 @@ fn profile_selection_check_all_targets() {

#[test]
fn profile_selection_check_all_targets_release() {
if !is_nightly() {
// See note in profile_selection_check_all_targets.
return;
}

let p = all_target_project();
// check --release
// https://github.com/rust-lang/cargo/issues/5218
Expand Down Expand Up @@ -572,11 +561,6 @@ fn profile_selection_check_all_targets_release() {

#[test]
fn profile_selection_check_all_targets_test() {
if !is_nightly() {
// See note in profile_selection_check_all_targets.
return;
}

let p = all_target_project();
// check --profile=test
// NOTES:
Expand Down