flag_tests: bool,
flag_bench: Vec<String>,
flag_benches: bool,
+ flag_all_targets: bool,
flag_no_fail_fast: bool,
flag_frozen: bool,
flag_locked: bool,
--tests Benchmark all tests
--bench NAME Benchmark only the specified bench target
--benches Benchmark all benches
+ --all-targets Benchmark all targets (default)
--no-run Compile, but don't run benchmarks
-p SPEC, --package SPEC ... Package to run benchmarks for
--all Benchmark all packages in the workspace
&options.flag_bin, options.flag_bins,
&options.flag_test, options.flag_tests,
&options.flag_example, options.flag_examples,
- &options.flag_bench, options.flag_benches,),
+ &options.flag_bench, options.flag_benches,
+ options.flag_all_targets),
message_format: options.flag_message_format,
target_rustdoc_args: None,
target_rustc_args: None,
flag_tests: bool,
flag_bench: Vec<String>,
flag_benches: bool,
+ flag_all_targets: bool,
flag_locked: bool,
flag_frozen: bool,
flag_all: bool,
--tests Build all tests
--bench NAME Build only the specified bench target
--benches Build all benches
+ --all-targets Build all targets (lib and bin targets by default)
--release Build artifacts in release mode, with optimizations
--features FEATURES Space-separated list of features to also build
--all-features Build all available features
&options.flag_bin, options.flag_bins,
&options.flag_test, options.flag_tests,
&options.flag_example, options.flag_examples,
- &options.flag_bench, options.flag_benches,),
+ &options.flag_bench, options.flag_benches,
+ options.flag_all_targets),
message_format: options.flag_message_format,
target_rustdoc_args: None,
target_rustc_args: None,
--tests Check all tests
--bench NAME Check only the specified bench target
--benches Check all benches
+ --all-targets Check all targets (lib and bin targets by default)
--release Check artifacts in release mode, with optimizations
--features FEATURES Space-separated list of features to also check
--all-features Check all available features
flag_tests: bool,
flag_bench: Vec<String>,
flag_benches: bool,
+ flag_all_targets: bool,
flag_locked: bool,
flag_frozen: bool,
flag_all: bool,
&options.flag_bin, options.flag_bins,
&options.flag_test, options.flag_tests,
&options.flag_example, options.flag_examples,
- &options.flag_bench, options.flag_benches,),
+ &options.flag_bench, options.flag_benches,
+ options.flag_all_targets),
message_format: options.flag_message_format,
target_rustdoc_args: None,
target_rustc_args: None,
&options.flag_bin, options.flag_bins,
&empty, false,
&empty, false,
- &empty, false),
+ &empty, false,
+ false),
message_format: options.flag_message_format,
release: options.flag_release,
mode: ops::CompileMode::Doc {
&options.flag_bin, options.flag_bins,
&[], false,
&options.flag_example, options.flag_examples,
- &[], false),
+ &[], false,
+ false),
message_format: ops::MessageFormat::Human,
target_rustc_args: None,
target_rustdoc_args: None,
release: options.flag_release,
mode: ops::CompileMode::Build,
filter: if examples.is_empty() && bins.is_empty() {
- ops::CompileFilter::Everything { required_features_filterable: false, }
+ ops::CompileFilter::Default { required_features_filterable: false, }
} else {
ops::CompileFilter::new(false,
&bins, false,
&[], false,
&examples, false,
- &[], false)
+ &[], false,
+ false)
},
message_format: options.flag_message_format,
target_rustdoc_args: None,
flag_tests: bool,
flag_bench: Vec<String>,
flag_benches: bool,
+ flag_all_targets: bool,
flag_profile: Option<String>,
flag_frozen: bool,
flag_locked: bool,
--tests Build all tests
--bench NAME Build only the specified bench target
--benches Build all benches
+ --all-targets Build all targets (lib and bin targets by default)
--release Build artifacts in release mode, with optimizations
--profile PROFILE Profile to build the selected target for
--features FEATURES Features to compile for the package
&options.flag_bin, options.flag_bins,
&options.flag_test, options.flag_tests,
&options.flag_example, options.flag_examples,
- &options.flag_bench, options.flag_benches,),
+ &options.flag_bench, options.flag_benches,
+ options.flag_all_targets),
message_format: options.flag_message_format,
target_rustdoc_args: None,
target_rustc_args: options.arg_opts.as_ref().map(|a| &a[..]),
flag_tests: bool,
flag_bench: Vec<String>,
flag_benches: bool,
+ flag_all_targets: bool,
flag_frozen: bool,
flag_locked: bool,
}
--tests Build all tests
--bench NAME Build only the specified bench target
--benches Build all benches
+ --all-targets Build all targets (default)
--release Build artifacts in release mode, with optimizations
--features FEATURES Space-separated list of features to also build
--all-features Build all available features
&options.flag_bin, options.flag_bins,
&options.flag_test, options.flag_tests,
&options.flag_example, options.flag_examples,
- &options.flag_bench, options.flag_benches,),
+ &options.flag_bench, options.flag_benches,
+ options.flag_all_targets),
message_format: options.flag_message_format,
mode: ops::CompileMode::Doc { deps: false },
target_rustdoc_args: Some(&options.arg_opts),
flag_tests: bool,
flag_bench: Vec<String>,
flag_benches: bool,
+ flag_all_targets: bool,
flag_verbose: u32,
flag_quiet: Option<bool>,
flag_color: Option<String>,
--tests Test all tests
--bench NAME ... Test only the specified bench target
--benches Test all benches
+ --all-targets Test all targets (default)
--no-run Compile, but don't run tests
-p SPEC, --package SPEC ... Package to run tests for
--all Test all packages in the workspace
if options.flag_doc {
mode = ops::CompileMode::Doctest;
filter = ops::CompileFilter::new(true, &empty, false, &empty, false,
- &empty, false, &empty, false);
+ &empty, false, &empty, false,
+ false);
} else {
mode = ops::CompileMode::Test;
filter = ops::CompileFilter::new(options.flag_lib,
&options.flag_bin, options.flag_bins,
&options.flag_test, options.flag_tests,
&options.flag_example, options.flag_examples,
- &options.flag_bench, options.flag_benches);
+ &options.flag_bench, options.flag_benches,
+ options.flag_all_targets);
}
let spec = Packages::from_flags(ws.is_virtual(),
spec: ops::Packages::Packages(&[]),
mode: mode,
release: false,
- filter: CompileFilter::Everything { required_features_filterable: false },
+ filter: CompileFilter::Default { required_features_filterable: false },
message_format: MessageFormat::Human,
target_rustdoc_args: None,
target_rustc_args: None,
#[derive(Debug)]
pub enum CompileFilter<'a> {
- Everything {
+ Default {
/// Flag whether targets can be safely skipped when required-features are not satisfied.
required_features_filterable: bool,
},
bins: &'a [String], all_bins: bool,
tsts: &'a [String], all_tsts: bool,
exms: &'a [String], all_exms: bool,
- bens: &'a [String], all_bens: bool) -> CompileFilter<'a> {
+ bens: &'a [String], all_bens: bool,
+ all_targets: bool) -> CompileFilter<'a> {
let rule_bins = FilterRule::new(bins, all_bins);
let rule_tsts = FilterRule::new(tsts, all_tsts);
let rule_exms = FilterRule::new(exms, all_exms);
let rule_bens = FilterRule::new(bens, all_bens);
- if lib_only || rule_bins.is_specific() || rule_tsts.is_specific()
+ if all_targets {
+ CompileFilter::Only {
+ lib: true, bins: FilterRule::All,
+ examples: FilterRule::All, benches: FilterRule::All,
+ tests: FilterRule::All,
+ }
+ } else if lib_only || rule_bins.is_specific() || rule_tsts.is_specific()
|| rule_exms.is_specific() || rule_bens.is_specific() {
CompileFilter::Only {
lib: lib_only, bins: rule_bins,
tests: rule_tsts,
}
} else {
- CompileFilter::Everything {
+ CompileFilter::Default {
required_features_filterable: true,
}
}
pub fn matches(&self, target: &Target) -> bool {
match *self {
- CompileFilter::Everything { .. } => true,
+ CompileFilter::Default { .. } => true,
CompileFilter::Only { lib, bins, examples, tests, benches } => {
let rule = match *target.kind() {
TargetKind::Bin => bins,
pub fn is_specific(&self) -> bool {
match *self {
- CompileFilter::Everything { .. } => false,
+ CompileFilter::Default { .. } => false,
CompileFilter::Only { .. } => true,
}
}
};
let targets = match *filter {
- CompileFilter::Everything { required_features_filterable } => {
+ CompileFilter::Default { required_features_filterable } => {
let deps = if release {
&profiles.bench_deps
} else {
}
};
match *filter {
- CompileFilter::Everything { .. } => {
+ CompileFilter::Default { .. } => {
pkg.targets().iter()
.filter(|t| t.is_bin())
.filter_map(|t| check(t.name().to_string()))
no_default_features: false,
all_features: false,
spec: ops::Packages::Packages(&[]),
- filter: ops::CompileFilter::Everything { required_features_filterable: true },
+ filter: ops::CompileFilter::Default { required_features_filterable: true },
release: false,
message_format: ops::MessageFormat::Human,
mode: ops::CompileMode::Build,
.with_stderr_contains("[..] --crate-name bar bar[/]src[/]lib.rs [..]")
);
}
+
+#[test]
+fn check_all_targets() {
+ let foo = project("foo")
+ .file("Cargo.toml", r#"
+ [package]
+ name = "foo"
+ version = "0.0.1"
+ authors = []
+ "#)
+ .file("src/main.rs", "fn main() {}")
+ .file("src/lib.rs", "pub fn smth() {}")
+ .file("examples/example1.rs", "fn main() {}")
+ .file("tests/test2.rs", "#[test] fn t() {}")
+ .file("benches/bench3.rs", "")
+ ;
+
+ assert_that(foo.cargo_process("check").arg("--all-targets").arg("-v"),
+ execs().with_status(0)
+ .with_stderr_contains("[..] --crate-name foo src[/]lib.rs [..]")
+ .with_stderr_contains("[..] --crate-name foo src[/]main.rs [..]")
+ .with_stderr_contains("[..] --crate-name example1 examples[/]example1.rs [..]")
+ .with_stderr_contains("[..] --crate-name test2 tests[/]test2.rs [..]")
+ .with_stderr_contains("[..] --crate-name bench3 benches[/]bench3.rs [..]")
+ );
+}