diff --git a/crates/cargo-test-support/src/lib.rs b/crates/cargo-test-support/src/lib.rs index bccbe068ea1..1973b5c69e5 100644 --- a/crates/cargo-test-support/src/lib.rs +++ b/crates/cargo-test-support/src/lib.rs @@ -1638,8 +1638,12 @@ impl ChannelChanger for cargo::util::ProcessBuilder { } fn split_and_add_args(p: &mut ProcessBuilder, s: &str) { - for arg in s.split_whitespace() { - if arg.contains('"') || arg.contains('\'') { + for mut arg in s.split_whitespace() { + if (arg.starts_with('"') && arg.ends_with('"')) + || (arg.starts_with('\'') && arg.ends_with('\'')) + { + arg = &arg[1..(arg.len() - 1).max(1)]; + } else if arg.contains(&['"', '\''][..]) { panic!("shell-style argument parsing is not supported") } p.arg(arg); diff --git a/src/bin/cargo/commands/run.rs b/src/bin/cargo/commands/run.rs index d16bfd31f3c..344d5f19b6c 100644 --- a/src/bin/cargo/commands/run.rs +++ b/src/bin/cargo/commands/run.rs @@ -1,7 +1,8 @@ use crate::command_prelude::*; +use crate::util::restricted_names::is_glob_pattern; use crate::util::ProcessError; use cargo::core::Verbosity; -use cargo::ops::{self, CompileFilter}; +use cargo::ops::{self, CompileFilter, Packages}; pub fn cli() -> App { subcommand("run") @@ -38,6 +39,17 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult { ProfileChecking::Checked, )?; + // Disallow `spec` to be an glob pattern + if let Packages::Packages(opt_in) = &compile_opts.spec { + if let Some(pattern) = opt_in.iter().find(|s| is_glob_pattern(s)) { + return Err(anyhow::anyhow!( + "`cargo run` does not support glob pattern `{}` on package selection", + pattern, + ) + .into()); + } + } + if !args.is_present("example") && !args.is_present("bin") { let default_runs: Vec<_> = compile_opts .spec diff --git a/src/cargo/ops/cargo_compile.rs b/src/cargo/ops/cargo_compile.rs index 8056c708918..f1464b7337c 100644 --- a/src/cargo/ops/cargo_compile.rs +++ b/src/cargo/ops/cargo_compile.rs @@ -24,7 +24,6 @@ use std::collections::{BTreeSet, HashMap, HashSet}; use std::hash::{Hash, Hasher}; -use std::iter::FromIterator; use std::sync::Arc; use crate::core::compiler::standard_lib; @@ -41,8 +40,11 @@ use crate::core::{PackageId, PackageIdSpec, TargetKind, Workspace}; use crate::ops; use crate::ops::resolve::WorkspaceResolve; use crate::util::config::Config; +use crate::util::restricted_names::is_glob_pattern; use crate::util::{closest_msg, profile, CargoResult, StableHasher}; +use anyhow::Context as _; + /// Contains information about how a package should be compiled. /// /// Note on distinction between `CompileOptions` and `BuildConfig`: @@ -116,6 +118,7 @@ impl Packages { }) } + /// Converts selected packages from a workspace to `PackageIdSpec`s. pub fn to_package_id_specs(&self, ws: &Workspace<'_>) -> CargoResult> { let specs = match self { Packages::All => ws @@ -124,33 +127,40 @@ impl Packages { .map(PackageIdSpec::from_package_id) .collect(), Packages::OptOut(opt_out) => { - let mut opt_out = BTreeSet::from_iter(opt_out.iter().cloned()); - let packages = ws + let (mut patterns, mut names) = opt_patterns_and_names(opt_out)?; + let specs = ws .members() - .filter(|pkg| !opt_out.remove(pkg.name().as_str())) + .filter(|pkg| { + !names.remove(pkg.name().as_str()) && !match_patterns(pkg, &mut patterns) + }) .map(Package::package_id) .map(PackageIdSpec::from_package_id) .collect(); - if !opt_out.is_empty() { - ws.config().shell().warn(format!( - "excluded package(s) {} not found in workspace `{}`", - opt_out - .iter() - .map(|x| x.as_ref()) - .collect::>() - .join(", "), - ws.root().display(), - ))?; - } - packages + let warn = |e| ws.config().shell().warn(e); + emit_package_not_found(ws, names, true).or_else(warn)?; + emit_pattern_not_found(ws, patterns, true).or_else(warn)?; + specs } Packages::Packages(packages) if packages.is_empty() => { vec![PackageIdSpec::from_package_id(ws.current()?.package_id())] } - Packages::Packages(packages) => packages - .iter() - .map(|p| PackageIdSpec::parse(p)) - .collect::>>()?, + Packages::Packages(opt_in) => { + let (mut patterns, packages) = opt_patterns_and_names(opt_in)?; + let mut specs = packages + .iter() + .map(|p| PackageIdSpec::parse(p)) + .collect::>>()?; + if !patterns.is_empty() { + let matched_pkgs = ws + .members() + .filter(|pkg| match_patterns(pkg, &mut patterns)) + .map(Package::package_id) + .map(PackageIdSpec::from_package_id); + specs.extend(matched_pkgs); + } + emit_pattern_not_found(ws, patterns, false)?; + specs + } Packages::Default => ws .default_members() .map(Package::package_id) @@ -170,27 +180,35 @@ impl Packages { Ok(specs) } + /// Gets a list of selected packages from a workspace. pub fn get_packages<'ws>(&self, ws: &'ws Workspace<'_>) -> CargoResult> { let packages: Vec<_> = match self { Packages::Default => ws.default_members().collect(), Packages::All => ws.members().collect(), - Packages::OptOut(opt_out) => ws - .members() - .filter(|pkg| !opt_out.iter().any(|name| pkg.name().as_str() == name)) - .collect(), - Packages::Packages(packages) => packages - .iter() - .map(|name| { - ws.members() - .find(|pkg| pkg.name().as_str() == name) - .ok_or_else(|| { - anyhow::format_err!( - "package `{}` is not a member of the workspace", - name - ) - }) - }) - .collect::>>()?, + Packages::OptOut(opt_out) => { + let (mut patterns, mut names) = opt_patterns_and_names(opt_out)?; + let packages = ws + .members() + .filter(|pkg| { + !names.remove(pkg.name().as_str()) && !match_patterns(pkg, &mut patterns) + }) + .collect(); + emit_package_not_found(ws, names, true)?; + emit_pattern_not_found(ws, patterns, true)?; + packages + } + Packages::Packages(opt_in) => { + let (mut patterns, mut names) = opt_patterns_and_names(opt_in)?; + let packages = ws + .members() + .filter(|pkg| { + names.remove(pkg.name().as_str()) || match_patterns(pkg, &mut patterns) + }) + .collect(); + emit_package_not_found(ws, names, false)?; + emit_pattern_not_found(ws, patterns, false)?; + packages + } }; Ok(packages) } @@ -577,6 +595,13 @@ impl FilterRule { FilterRule::Just(ref targets) => Some(targets.clone()), } } + + pub(crate) fn contains_glob_patterns(&self) -> bool { + match self { + FilterRule::All => false, + FilterRule::Just(targets) => targets.iter().any(is_glob_pattern), + } + } } impl CompileFilter { @@ -706,6 +731,24 @@ impl CompileFilter { CompileFilter::Only { .. } => true, } } + + pub(crate) fn contains_glob_patterns(&self) -> bool { + match self { + CompileFilter::Default { .. } => false, + CompileFilter::Only { + bins, + examples, + tests, + benches, + .. + } => { + bins.contains_glob_patterns() + || examples.contains_glob_patterns() + || tests.contains_glob_patterns() + || benches.contains_glob_patterns() + } + } + } } /// A proposed target. @@ -1163,8 +1206,16 @@ fn find_named_targets<'a>( is_expected_kind: fn(&Target) -> bool, mode: CompileMode, ) -> CargoResult>> { - let filter = |t: &Target| t.name() == target_name && is_expected_kind(t); - let proposals = filter_targets(packages, filter, true, mode); + let is_glob = is_glob_pattern(target_name); + let proposals = if is_glob { + let pattern = build_glob(target_name)?; + let filter = |t: &Target| is_expected_kind(t) && pattern.matches(t.name()); + filter_targets(packages, filter, true, mode) + } else { + let filter = |t: &Target| t.name() == target_name && is_expected_kind(t); + filter_targets(packages, filter, true, mode) + }; + if proposals.is_empty() { let targets = packages.iter().flat_map(|pkg| { pkg.targets() @@ -1173,8 +1224,9 @@ fn find_named_targets<'a>( }); let suggestion = closest_msg(target_name, targets, |t| t.name()); anyhow::bail!( - "no {} target named `{}`{}", + "no {} target {} `{}`{}", target_desc, + if is_glob { "matches pattern" } else { "named" }, target_name, suggestion ); @@ -1291,3 +1343,86 @@ fn traverse_and_share( new_graph.entry(new_unit.clone()).or_insert(new_deps); new_unit } + +/// Build `glob::Pattern` with informative context. +fn build_glob(pat: &str) -> CargoResult { + glob::Pattern::new(pat).with_context(|| format!("cannot build glob pattern from `{}`", pat)) +} + +/// Emits "package not found" error. +/// +/// > This function should be used only in package selection processes such like +/// `Packages::to_package_id_specs` and `Packages::get_packages`. +fn emit_package_not_found( + ws: &Workspace<'_>, + opt_names: BTreeSet<&str>, + opt_out: bool, +) -> CargoResult<()> { + if !opt_names.is_empty() { + anyhow::bail!( + "{}package(s) `{}` not found in workspace `{}`", + if opt_out { "excluded " } else { "" }, + opt_names.into_iter().collect::>().join(", "), + ws.root().display(), + ) + } + Ok(()) +} + +/// Emits "glob pattern not found" error. +/// +/// > This function should be used only in package selection processes such like +/// `Packages::to_package_id_specs` and `Packages::get_packages`. +fn emit_pattern_not_found( + ws: &Workspace<'_>, + opt_patterns: Vec<(glob::Pattern, bool)>, + opt_out: bool, +) -> CargoResult<()> { + let not_matched = opt_patterns + .iter() + .filter(|(_, matched)| !*matched) + .map(|(pat, _)| pat.as_str()) + .collect::>(); + if !not_matched.is_empty() { + anyhow::bail!( + "{}package pattern(s) `{}` not found in workspace `{}`", + if opt_out { "excluded " } else { "" }, + not_matched.join(", "), + ws.root().display(), + ) + } + Ok(()) +} + +/// Checks whether a package matches any of a list of glob patterns generated +/// from `opt_patterns_and_names`. +/// +/// > This function should be used only in package selection processes such like +/// `Packages::to_package_id_specs` and `Packages::get_packages`. +fn match_patterns(pkg: &Package, patterns: &mut Vec<(glob::Pattern, bool)>) -> bool { + patterns.iter_mut().any(|(m, matched)| { + let is_matched = m.matches(pkg.name().as_str()); + *matched |= is_matched; + is_matched + }) +} + +/// Given a list opt-in or opt-out package selection strings, generates two +/// collections that represent glob patterns and package names respectively. +/// +/// > This function should be used only in package selection processes such like +/// `Packages::to_package_id_specs` and `Packages::get_packages`. +fn opt_patterns_and_names( + opt: &[String], +) -> CargoResult<(Vec<(glob::Pattern, bool)>, BTreeSet<&str>)> { + let mut opt_patterns = Vec::new(); + let mut opt_names = BTreeSet::new(); + for x in opt.iter() { + if is_glob_pattern(x) { + opt_patterns.push((build_glob(x)?, false)); + } else { + opt_names.insert(String::as_str(x)); + } + } + Ok((opt_patterns, opt_names)) +} diff --git a/src/cargo/ops/cargo_run.rs b/src/cargo/ops/cargo_run.rs index ab4667bd24b..d95b0185176 100644 --- a/src/cargo/ops/cargo_run.rs +++ b/src/cargo/ops/cargo_run.rs @@ -13,6 +13,10 @@ pub fn run( ) -> CargoResult<()> { let config = ws.config(); + if options.filter.contains_glob_patterns() { + anyhow::bail!("`cargo run` does not support glob patterns on target selection") + } + // We compute the `bins` here *just for diagnosis*. The actual set of // packages to be run is determined by the `ops::compile` call below. let packages = options.spec.get_packages(ws)?; diff --git a/src/cargo/util/command_prelude.rs b/src/cargo/util/command_prelude.rs index 48615358252..6800e00118b 100644 --- a/src/cargo/util/command_prelude.rs +++ b/src/cargo/util/command_prelude.rs @@ -4,6 +4,7 @@ use crate::ops::{CompileFilter, CompileOptions, NewOptions, Packages, VersionCon use crate::sources::CRATES_IO_REGISTRY; use crate::util::important_paths::find_root_manifest_for_wd; use crate::util::interning::InternedString; +use crate::util::restricted_names::is_glob_pattern; use crate::util::{paths, toml::TomlProfile, validate_package_name}; use crate::util::{ print_available_benches, print_available_binaries, print_available_examples, @@ -510,7 +511,11 @@ pub trait ArgMatchesExt { profile_checking: ProfileChecking, ) -> CargoResult { let mut compile_opts = self.compile_options(config, mode, workspace, profile_checking)?; - compile_opts.spec = Packages::Packages(self._values_of("package")); + let spec = self._values_of("package"); + if spec.iter().any(is_glob_pattern) { + anyhow::bail!("Glob patterns on package selection are not supported.") + } + compile_opts.spec = Packages::Packages(spec); Ok(compile_opts) } diff --git a/src/cargo/util/restricted_names.rs b/src/cargo/util/restricted_names.rs index 3e1cb036de8..650ae233059 100644 --- a/src/cargo/util/restricted_names.rs +++ b/src/cargo/util/restricted_names.rs @@ -83,7 +83,7 @@ pub fn validate_package_name(name: &str, what: &str, help: &str) -> CargoResult< Ok(()) } -// Check the entire path for names reserved in Windows. +/// Check the entire path for names reserved in Windows. pub fn is_windows_reserved_path(path: &Path) -> bool { path.iter() .filter_map(|component| component.to_str()) @@ -92,3 +92,8 @@ pub fn is_windows_reserved_path(path: &Path) -> bool { is_windows_reserved(stem) }) } + +/// Returns `true` if the name contains any glob pattern wildcards. +pub fn is_glob_pattern>(name: T) -> bool { + name.as_ref().contains(&['*', '?', '[', ']'][..]) +} diff --git a/src/doc/man/generated_txt/cargo-bench.txt b/src/doc/man/generated_txt/cargo-bench.txt index 2ffb4a92a10..963e5f5ff41 100644 --- a/src/doc/man/generated_txt/cargo-bench.txt +++ b/src/doc/man/generated_txt/cargo-bench.txt @@ -65,7 +65,11 @@ OPTIONS -p spec..., --package spec... Benchmark only the specified packages. See cargo-pkgid(1) for the - SPEC format. This flag may be specified multiple times. + SPEC format. This flag may be specified multiple times and supports + common Unix glob patterns like *, ? and []. However, to avoid your + shell accidentally expanding glob patterns before Cargo handles + them, you must use single quotes or double quotes around each + pattern. --workspace Benchmark all members in the workspace. @@ -75,7 +79,11 @@ OPTIONS --exclude SPEC... Exclude the specified packages. Must be used in conjunction with the - --workspace flag. This flag may be specified multiple times. + --workspace flag. This flag may be specified multiple times and + supports common Unix glob patterns like *, ? and []. However, to + avoid your shell accidentally expanding glob patterns before Cargo + handles them, you must use single quotes or double quotes around + each pattern. Target Selection When no target selection options are given, cargo bench will build the @@ -102,26 +110,31 @@ OPTIONS Passing target selection flags will benchmark only the specified targets. + Note that --bin, --example, --test and --bench flags also support common + Unix glob patterns like *, ? and []. However, to avoid your shell + accidentally expanding glob patterns before Cargo handles them, you must + use single quotes or double quotes around each glob pattern. + --lib Benchmark the package's library. --bin name... Benchmark the specified binary. This flag may be specified multiple - times. + times and supports common Unix glob patterns. --bins Benchmark all binary targets. --example name... Benchmark the specified example. This flag may be specified multiple - times. + times and supports common Unix glob patterns. --examples Benchmark all example targets. --test name... Benchmark the specified integration test. This flag may be specified - multiple times. + multiple times and supports common Unix glob patterns. --tests Benchmark all targets in test mode that have the test = true @@ -134,7 +147,7 @@ OPTIONS --bench name... Benchmark the specified benchmark. This flag may be specified - multiple times. + multiple times and supports common Unix glob patterns. --benches Benchmark all targets in benchmark mode that have the bench = true diff --git a/src/doc/man/generated_txt/cargo-build.txt b/src/doc/man/generated_txt/cargo-build.txt index 49bec89e1c6..3c49fb8f318 100644 --- a/src/doc/man/generated_txt/cargo-build.txt +++ b/src/doc/man/generated_txt/cargo-build.txt @@ -26,7 +26,11 @@ OPTIONS -p spec..., --package spec... Build only the specified packages. See cargo-pkgid(1) for the SPEC - format. This flag may be specified multiple times. + format. This flag may be specified multiple times and supports + common Unix glob patterns like *, ? and []. However, to avoid your + shell accidentally expanding glob patterns before Cargo handles + them, you must use single quotes or double quotes around each + pattern. --workspace Build all members in the workspace. @@ -36,7 +40,11 @@ OPTIONS --exclude SPEC... Exclude the specified packages. Must be used in conjunction with the - --workspace flag. This flag may be specified multiple times. + --workspace flag. This flag may be specified multiple times and + supports common Unix glob patterns like *, ? and []. However, to + avoid your shell accidentally expanding glob patterns before Cargo + handles them, you must use single quotes or double quotes around + each pattern. Target Selection When no target selection options are given, cargo build will build all @@ -45,26 +53,31 @@ OPTIONS Passing target selection flags will build only the specified targets. + Note that --bin, --example, --test and --bench flags also support common + Unix glob patterns like *, ? and []. However, to avoid your shell + accidentally expanding glob patterns before Cargo handles them, you must + use single quotes or double quotes around each glob pattern. + --lib Build the package's library. --bin name... Build the specified binary. This flag may be specified multiple - times. + times and supports common Unix glob patterns. --bins Build all binary targets. --example name... Build the specified example. This flag may be specified multiple - times. + times and supports common Unix glob patterns. --examples Build all example targets. --test name... Build the specified integration test. This flag may be specified - multiple times. + multiple times and supports common Unix glob patterns. --tests Build all targets in test mode that have the test = true manifest @@ -77,7 +90,7 @@ OPTIONS --bench name... Build the specified benchmark. This flag may be specified multiple - times. + times and supports common Unix glob patterns. --benches Build all targets in benchmark mode that have the bench = true diff --git a/src/doc/man/generated_txt/cargo-check.txt b/src/doc/man/generated_txt/cargo-check.txt index 800af25444d..e61cad5da2c 100644 --- a/src/doc/man/generated_txt/cargo-check.txt +++ b/src/doc/man/generated_txt/cargo-check.txt @@ -32,7 +32,11 @@ OPTIONS -p spec..., --package spec... Check only the specified packages. See cargo-pkgid(1) for the SPEC - format. This flag may be specified multiple times. + format. This flag may be specified multiple times and supports + common Unix glob patterns like *, ? and []. However, to avoid your + shell accidentally expanding glob patterns before Cargo handles + them, you must use single quotes or double quotes around each + pattern. --workspace Check all members in the workspace. @@ -42,7 +46,11 @@ OPTIONS --exclude SPEC... Exclude the specified packages. Must be used in conjunction with the - --workspace flag. This flag may be specified multiple times. + --workspace flag. This flag may be specified multiple times and + supports common Unix glob patterns like *, ? and []. However, to + avoid your shell accidentally expanding glob patterns before Cargo + handles them, you must use single quotes or double quotes around + each pattern. Target Selection When no target selection options are given, cargo check will check all @@ -51,26 +59,31 @@ OPTIONS Passing target selection flags will check only the specified targets. + Note that --bin, --example, --test and --bench flags also support common + Unix glob patterns like *, ? and []. However, to avoid your shell + accidentally expanding glob patterns before Cargo handles them, you must + use single quotes or double quotes around each glob pattern. + --lib Check the package's library. --bin name... Check the specified binary. This flag may be specified multiple - times. + times and supports common Unix glob patterns. --bins Check all binary targets. --example name... Check the specified example. This flag may be specified multiple - times. + times and supports common Unix glob patterns. --examples Check all example targets. --test name... Check the specified integration test. This flag may be specified - multiple times. + multiple times and supports common Unix glob patterns. --tests Check all targets in test mode that have the test = true manifest @@ -83,7 +96,7 @@ OPTIONS --bench name... Check the specified benchmark. This flag may be specified multiple - times. + times and supports common Unix glob patterns. --benches Check all targets in benchmark mode that have the bench = true diff --git a/src/doc/man/generated_txt/cargo-doc.txt b/src/doc/man/generated_txt/cargo-doc.txt index 044bcd9c0d2..bdcb9b1bc3f 100644 --- a/src/doc/man/generated_txt/cargo-doc.txt +++ b/src/doc/man/generated_txt/cargo-doc.txt @@ -39,7 +39,11 @@ OPTIONS -p spec..., --package spec... Document only the specified packages. See cargo-pkgid(1) for the - SPEC format. This flag may be specified multiple times. + SPEC format. This flag may be specified multiple times and supports + common Unix glob patterns like *, ? and []. However, to avoid your + shell accidentally expanding glob patterns before Cargo handles + them, you must use single quotes or double quotes around each + pattern. --workspace Document all members in the workspace. @@ -49,7 +53,11 @@ OPTIONS --exclude SPEC... Exclude the specified packages. Must be used in conjunction with the - --workspace flag. This flag may be specified multiple times. + --workspace flag. This flag may be specified multiple times and + supports common Unix glob patterns like *, ? and []. However, to + avoid your shell accidentally expanding glob patterns before Cargo + handles them, you must use single quotes or double quotes around + each pattern. Target Selection When no target selection options are given, cargo doc will document all @@ -66,7 +74,7 @@ OPTIONS --bin name... Document the specified binary. This flag may be specified multiple - times. + times and supports common Unix glob patterns. --bins Document all binary targets. diff --git a/src/doc/man/generated_txt/cargo-fix.txt b/src/doc/man/generated_txt/cargo-fix.txt index 707235d2397..3c5eb4cbacf 100644 --- a/src/doc/man/generated_txt/cargo-fix.txt +++ b/src/doc/man/generated_txt/cargo-fix.txt @@ -81,7 +81,11 @@ OPTIONS -p spec..., --package spec... Fix only the specified packages. See cargo-pkgid(1) for the SPEC - format. This flag may be specified multiple times. + format. This flag may be specified multiple times and supports + common Unix glob patterns like *, ? and []. However, to avoid your + shell accidentally expanding glob patterns before Cargo handles + them, you must use single quotes or double quotes around each + pattern. --workspace Fix all members in the workspace. @@ -91,7 +95,11 @@ OPTIONS --exclude SPEC... Exclude the specified packages. Must be used in conjunction with the - --workspace flag. This flag may be specified multiple times. + --workspace flag. This flag may be specified multiple times and + supports common Unix glob patterns like *, ? and []. However, to + avoid your shell accidentally expanding glob patterns before Cargo + handles them, you must use single quotes or double quotes around + each pattern. Target Selection When no target selection options are given, cargo fix will fix all @@ -100,25 +108,31 @@ OPTIONS Passing target selection flags will fix only the specified targets. + Note that --bin, --example, --test and --bench flags also support common + Unix glob patterns like *, ? and []. However, to avoid your shell + accidentally expanding glob patterns before Cargo handles them, you must + use single quotes or double quotes around each glob pattern. + --lib Fix the package's library. --bin name... - Fix the specified binary. This flag may be specified multiple times. + Fix the specified binary. This flag may be specified multiple times + and supports common Unix glob patterns. --bins Fix all binary targets. --example name... - Fix the specified example. This flag may be specified multiple - times. + Fix the specified example. This flag may be specified multiple times + and supports common Unix glob patterns. --examples Fix all example targets. --test name... Fix the specified integration test. This flag may be specified - multiple times. + multiple times and supports common Unix glob patterns. --tests Fix all targets in test mode that have the test = true manifest flag @@ -131,7 +145,7 @@ OPTIONS --bench name... Fix the specified benchmark. This flag may be specified multiple - times. + times and supports common Unix glob patterns. --benches Fix all targets in benchmark mode that have the bench = true diff --git a/src/doc/man/generated_txt/cargo-rustc.txt b/src/doc/man/generated_txt/cargo-rustc.txt index ae31b22822c..d1ced70f219 100644 --- a/src/doc/man/generated_txt/cargo-rustc.txt +++ b/src/doc/man/generated_txt/cargo-rustc.txt @@ -44,26 +44,31 @@ OPTIONS Passing target selection flags will build only the specified targets. + Note that --bin, --example, --test and --bench flags also support common + Unix glob patterns like *, ? and []. However, to avoid your shell + accidentally expanding glob patterns before Cargo handles them, you must + use single quotes or double quotes around each glob pattern. + --lib Build the package's library. --bin name... Build the specified binary. This flag may be specified multiple - times. + times and supports common Unix glob patterns. --bins Build all binary targets. --example name... Build the specified example. This flag may be specified multiple - times. + times and supports common Unix glob patterns. --examples Build all example targets. --test name... Build the specified integration test. This flag may be specified - multiple times. + multiple times and supports common Unix glob patterns. --tests Build all targets in test mode that have the test = true manifest @@ -76,7 +81,7 @@ OPTIONS --bench name... Build the specified benchmark. This flag may be specified multiple - times. + times and supports common Unix glob patterns. --benches Build all targets in benchmark mode that have the bench = true diff --git a/src/doc/man/generated_txt/cargo-rustdoc.txt b/src/doc/man/generated_txt/cargo-rustdoc.txt index e7cbb857585..61ccdecc798 100644 --- a/src/doc/man/generated_txt/cargo-rustdoc.txt +++ b/src/doc/man/generated_txt/cargo-rustdoc.txt @@ -51,26 +51,31 @@ OPTIONS Passing target selection flags will document only the specified targets. + Note that --bin, --example, --test and --bench flags also support common + Unix glob patterns like *, ? and []. However, to avoid your shell + accidentally expanding glob patterns before Cargo handles them, you must + use single quotes or double quotes around each glob pattern. + --lib Document the package's library. --bin name... Document the specified binary. This flag may be specified multiple - times. + times and supports common Unix glob patterns. --bins Document all binary targets. --example name... Document the specified example. This flag may be specified multiple - times. + times and supports common Unix glob patterns. --examples Document all example targets. --test name... Document the specified integration test. This flag may be specified - multiple times. + multiple times and supports common Unix glob patterns. --tests Document all targets in test mode that have the test = true manifest @@ -83,7 +88,7 @@ OPTIONS --bench name... Document the specified benchmark. This flag may be specified - multiple times. + multiple times and supports common Unix glob patterns. --benches Document all targets in benchmark mode that have the bench = true diff --git a/src/doc/man/generated_txt/cargo-test.txt b/src/doc/man/generated_txt/cargo-test.txt index 73f5be88cb7..0e625dae6f9 100644 --- a/src/doc/man/generated_txt/cargo-test.txt +++ b/src/doc/man/generated_txt/cargo-test.txt @@ -63,7 +63,11 @@ OPTIONS -p spec..., --package spec... Test only the specified packages. See cargo-pkgid(1) for the SPEC - format. This flag may be specified multiple times. + format. This flag may be specified multiple times and supports + common Unix glob patterns like *, ? and []. However, to avoid your + shell accidentally expanding glob patterns before Cargo handles + them, you must use single quotes or double quotes around each + pattern. --workspace Test all members in the workspace. @@ -73,7 +77,11 @@ OPTIONS --exclude SPEC... Exclude the specified packages. Must be used in conjunction with the - --workspace flag. This flag may be specified multiple times. + --workspace flag. This flag may be specified multiple times and + supports common Unix glob patterns like *, ? and []. However, to + avoid your shell accidentally expanding glob patterns before Cargo + handles them, you must use single quotes or double quotes around + each pattern. Target Selection When no target selection options are given, cargo test will build the @@ -116,26 +124,31 @@ OPTIONS Passing target selection flags will test only the specified targets. + Note that --bin, --example, --test and --bench flags also support common + Unix glob patterns like *, ? and []. However, to avoid your shell + accidentally expanding glob patterns before Cargo handles them, you must + use single quotes or double quotes around each glob pattern. + --lib Test the package's library. --bin name... - Test the specified binary. This flag may be specified multiple - times. + Test the specified binary. This flag may be specified multiple times + and supports common Unix glob patterns. --bins Test all binary targets. --example name... Test the specified example. This flag may be specified multiple - times. + times and supports common Unix glob patterns. --examples Test all example targets. --test name... Test the specified integration test. This flag may be specified - multiple times. + multiple times and supports common Unix glob patterns. --tests Test all targets in test mode that have the test = true manifest @@ -148,7 +161,7 @@ OPTIONS --bench name... Test the specified benchmark. This flag may be specified multiple - times. + times and supports common Unix glob patterns. --benches Test all targets in benchmark mode that have the bench = true diff --git a/src/doc/man/generated_txt/cargo-tree.txt b/src/doc/man/generated_txt/cargo-tree.txt index 268e5ab6dc4..941a1c848bc 100644 --- a/src/doc/man/generated_txt/cargo-tree.txt +++ b/src/doc/man/generated_txt/cargo-tree.txt @@ -155,14 +155,22 @@ OPTIONS -p spec..., --package spec... Display only the specified packages. See cargo-pkgid(1) for the SPEC - format. This flag may be specified multiple times. + format. This flag may be specified multiple times and supports + common Unix glob patterns like *, ? and []. However, to avoid your + shell accidentally expanding glob patterns before Cargo handles + them, you must use single quotes or double quotes around each + pattern. --workspace Display all members in the workspace. --exclude SPEC... Exclude the specified packages. Must be used in conjunction with the - --workspace flag. This flag may be specified multiple times. + --workspace flag. This flag may be specified multiple times and + supports common Unix glob patterns like *, ? and []. However, to + avoid your shell accidentally expanding glob patterns before Cargo + handles them, you must use single quotes or double quotes around + each pattern. Manifest Options --manifest-path path diff --git a/src/doc/man/includes/options-targets-lib-bin.md b/src/doc/man/includes/options-targets-lib-bin.md index 60721ebf24e..14342acfad9 100644 --- a/src/doc/man/includes/options-targets-lib-bin.md +++ b/src/doc/man/includes/options-targets-lib-bin.md @@ -3,7 +3,8 @@ {{/option}} {{#option "`--bin` _name_..." }} -{{actionverb}} the specified binary. This flag may be specified multiple times. +{{actionverb}} the specified binary. This flag may be specified multiple times +and supports common Unix glob patterns. {{/option}} {{#option "`--bins`" }} diff --git a/src/doc/man/includes/options-targets.md b/src/doc/man/includes/options-targets.md index da8dba2c8dc..3332001b0e6 100644 --- a/src/doc/man/includes/options-targets.md +++ b/src/doc/man/includes/options-targets.md @@ -1,12 +1,18 @@ Passing target selection flags will {{lower actionverb}} only the specified -targets. +targets. + +Note that `--bin`, `--example`, `--test` and `--bench` flags also +support common Unix glob patterns like `*`, `?` and `[]`. However, to avoid your +shell accidentally expanding glob patterns before Cargo handles them, you must +use single quotes or double quotes around each glob pattern. {{#options}} {{> options-targets-lib-bin }} {{#option "`--example` _name_..." }} -{{actionverb}} the specified example. This flag may be specified multiple times. +{{actionverb}} the specified example. This flag may be specified multiple times +and supports common Unix glob patterns. {{/option}} {{#option "`--examples`" }} @@ -15,7 +21,7 @@ targets. {{#option "`--test` _name_..." }} {{actionverb}} the specified integration test. This flag may be specified -multiple times. +multiple times and supports common Unix glob patterns. {{/option}} {{#option "`--tests`" }} @@ -29,7 +35,8 @@ manifest settings for the target. {{/option}} {{#option "`--bench` _name_..." }} -{{actionverb}} the specified benchmark. This flag may be specified multiple times. +{{actionverb}} the specified benchmark. This flag may be specified multiple +times and supports common Unix glob patterns. {{/option}} {{#option "`--benches`" }} diff --git a/src/doc/man/includes/section-package-selection.md b/src/doc/man/includes/section-package-selection.md index 0c4a8629ed0..8d7d62180cd 100644 --- a/src/doc/man/includes/section-package-selection.md +++ b/src/doc/man/includes/section-package-selection.md @@ -15,7 +15,10 @@ virtual workspace will include all workspace members (equivalent to passing {{#option "`-p` _spec_..." "`--package` _spec_..."}} {{actionverb}} only the specified packages. See {{man "cargo-pkgid" 1}} for the -SPEC format. This flag may be specified multiple times. +SPEC format. This flag may be specified multiple times and supports common Unix +glob patterns like `*`, `?` and `[]`. However, to avoid your shell accidentally +expanding glob patterns before Cargo handles them, you must use single quotes or +double quotes around each pattern. {{/option}} {{#option "`--workspace`" }} @@ -30,7 +33,10 @@ Deprecated alias for `--workspace`. {{#option "`--exclude` _SPEC_..." }} Exclude the specified packages. Must be used in conjunction with the -`--workspace` flag. This flag may be specified multiple times. +`--workspace` flag. This flag may be specified multiple times and supports +common Unix glob patterns like `*`, `?` and `[]`. However, to avoid your shell +accidentally expanding glob patterns before Cargo handles them, you must use +single quotes or double quotes around each pattern. {{/option}} {{/options}} diff --git a/src/doc/src/commands/cargo-bench.md b/src/doc/src/commands/cargo-bench.md index 4aca31ee7dc..ebb75c63364 100644 --- a/src/doc/src/commands/cargo-bench.md +++ b/src/doc/src/commands/cargo-bench.md @@ -81,7 +81,10 @@ virtual workspace will include all workspace members (equivalent to passing
-p spec...
--package spec...
Benchmark only the specified packages. See cargo-pkgid(1) for the -SPEC format. This flag may be specified multiple times.
+SPEC format. This flag may be specified multiple times and supports common Unix +glob patterns like *, ? and []. However, to avoid your shell accidentally +expanding glob patterns before Cargo handles them, you must use single quotes or +double quotes around each pattern.
--workspace
@@ -96,7 +99,10 @@ SPEC format. This flag may be specified multiple times.
--exclude SPEC...
Exclude the specified packages. Must be used in conjunction with the ---workspace flag. This flag may be specified multiple times.
+--workspace flag. This flag may be specified multiple times and supports +common Unix glob patterns like *, ? and []. However, to avoid your shell +accidentally expanding glob patterns before Cargo handles them, you must use +single quotes or double quotes around each pattern. @@ -122,7 +128,12 @@ target by name ignore the `bench` flag and will always benchmark the given target. Passing target selection flags will benchmark only the specified -targets. +targets. + +Note that `--bin`, `--example`, `--test` and `--bench` flags also +support common Unix glob patterns like `*`, `?` and `[]`. However, to avoid your +shell accidentally expanding glob patterns before Cargo handles them, you must +use single quotes or double quotes around each glob pattern.
@@ -131,7 +142,8 @@ targets.
--bin name...
-
Benchmark the specified binary. This flag may be specified multiple times.
+
Benchmark the specified binary. This flag may be specified multiple times +and supports common Unix glob patterns.
--bins
@@ -140,7 +152,8 @@ targets.
--example name...
-
Benchmark the specified example. This flag may be specified multiple times.
+
Benchmark the specified example. This flag may be specified multiple times +and supports common Unix glob patterns.
--examples
@@ -149,7 +162,7 @@ targets.
--test name...
Benchmark the specified integration test. This flag may be specified -multiple times.
+multiple times and supports common Unix glob patterns.
--tests
@@ -163,7 +176,8 @@ manifest settings for the target.
--bench name...
-
Benchmark the specified benchmark. This flag may be specified multiple times.
+
Benchmark the specified benchmark. This flag may be specified multiple +times and supports common Unix glob patterns.
--benches
diff --git a/src/doc/src/commands/cargo-build.md b/src/doc/src/commands/cargo-build.md index 5f2cc54d931..d73abb0bc59 100644 --- a/src/doc/src/commands/cargo-build.md +++ b/src/doc/src/commands/cargo-build.md @@ -33,7 +33,10 @@ virtual workspace will include all workspace members (equivalent to passing
-p spec...
--package spec...
Build only the specified packages. See cargo-pkgid(1) for the -SPEC format. This flag may be specified multiple times.
+SPEC format. This flag may be specified multiple times and supports common Unix +glob patterns like *, ? and []. However, to avoid your shell accidentally +expanding glob patterns before Cargo handles them, you must use single quotes or +double quotes around each pattern.
--workspace
@@ -48,7 +51,10 @@ SPEC format. This flag may be specified multiple times.
--exclude SPEC...
Exclude the specified packages. Must be used in conjunction with the ---workspace flag. This flag may be specified multiple times.
+--workspace flag. This flag may be specified multiple times and supports +common Unix glob patterns like *, ? and []. However, to avoid your shell +accidentally expanding glob patterns before Cargo handles them, you must use +single quotes or double quotes around each pattern.
@@ -61,7 +67,12 @@ binary and library targets of the selected packages. Binaries are skipped if they have `required-features` that are missing. Passing target selection flags will build only the specified -targets. +targets. + +Note that `--bin`, `--example`, `--test` and `--bench` flags also +support common Unix glob patterns like `*`, `?` and `[]`. However, to avoid your +shell accidentally expanding glob patterns before Cargo handles them, you must +use single quotes or double quotes around each glob pattern.
@@ -70,7 +81,8 @@ targets.
--bin name...
-
Build the specified binary. This flag may be specified multiple times.
+
Build the specified binary. This flag may be specified multiple times +and supports common Unix glob patterns.
--bins
@@ -79,7 +91,8 @@ targets.
--example name...
-
Build the specified example. This flag may be specified multiple times.
+
Build the specified example. This flag may be specified multiple times +and supports common Unix glob patterns.
--examples
@@ -88,7 +101,7 @@ targets.
--test name...
Build the specified integration test. This flag may be specified -multiple times.
+multiple times and supports common Unix glob patterns.
--tests
@@ -102,7 +115,8 @@ manifest settings for the target.
--bench name...
-
Build the specified benchmark. This flag may be specified multiple times.
+
Build the specified benchmark. This flag may be specified multiple +times and supports common Unix glob patterns.
--benches
diff --git a/src/doc/src/commands/cargo-check.md b/src/doc/src/commands/cargo-check.md index db8c75ec95e..1ba6fa4abf2 100644 --- a/src/doc/src/commands/cargo-check.md +++ b/src/doc/src/commands/cargo-check.md @@ -38,7 +38,10 @@ virtual workspace will include all workspace members (equivalent to passing
-p spec...
--package spec...
Check only the specified packages. See cargo-pkgid(1) for the -SPEC format. This flag may be specified multiple times.
+SPEC format. This flag may be specified multiple times and supports common Unix +glob patterns like *, ? and []. However, to avoid your shell accidentally +expanding glob patterns before Cargo handles them, you must use single quotes or +double quotes around each pattern.
--workspace
@@ -53,7 +56,10 @@ SPEC format. This flag may be specified multiple times.
--exclude SPEC...
Exclude the specified packages. Must be used in conjunction with the ---workspace flag. This flag may be specified multiple times.
+--workspace flag. This flag may be specified multiple times and supports +common Unix glob patterns like *, ? and []. However, to avoid your shell +accidentally expanding glob patterns before Cargo handles them, you must use +single quotes or double quotes around each pattern.
@@ -66,7 +72,12 @@ binary and library targets of the selected packages. Binaries are skipped if they have `required-features` that are missing. Passing target selection flags will check only the specified -targets. +targets. + +Note that `--bin`, `--example`, `--test` and `--bench` flags also +support common Unix glob patterns like `*`, `?` and `[]`. However, to avoid your +shell accidentally expanding glob patterns before Cargo handles them, you must +use single quotes or double quotes around each glob pattern.
@@ -75,7 +86,8 @@ targets.
--bin name...
-
Check the specified binary. This flag may be specified multiple times.
+
Check the specified binary. This flag may be specified multiple times +and supports common Unix glob patterns.
--bins
@@ -84,7 +96,8 @@ targets.
--example name...
-
Check the specified example. This flag may be specified multiple times.
+
Check the specified example. This flag may be specified multiple times +and supports common Unix glob patterns.
--examples
@@ -93,7 +106,7 @@ targets.
--test name...
Check the specified integration test. This flag may be specified -multiple times.
+multiple times and supports common Unix glob patterns.
--tests
@@ -107,7 +120,8 @@ manifest settings for the target.
--bench name...
-
Check the specified benchmark. This flag may be specified multiple times.
+
Check the specified benchmark. This flag may be specified multiple +times and supports common Unix glob patterns.
--benches
diff --git a/src/doc/src/commands/cargo-doc.md b/src/doc/src/commands/cargo-doc.md index 92fe677cd07..ea3d58f5b96 100644 --- a/src/doc/src/commands/cargo-doc.md +++ b/src/doc/src/commands/cargo-doc.md @@ -53,7 +53,10 @@ virtual workspace will include all workspace members (equivalent to passing
-p spec...
--package spec...
Document only the specified packages. See cargo-pkgid(1) for the -SPEC format. This flag may be specified multiple times.
+SPEC format. This flag may be specified multiple times and supports common Unix +glob patterns like *, ? and []. However, to avoid your shell accidentally +expanding glob patterns before Cargo handles them, you must use single quotes or +double quotes around each pattern.
--workspace
@@ -68,7 +71,10 @@ SPEC format. This flag may be specified multiple times.
--exclude SPEC...
Exclude the specified packages. Must be used in conjunction with the ---workspace flag. This flag may be specified multiple times.
+--workspace flag. This flag may be specified multiple times and supports +common Unix glob patterns like *, ? and []. However, to avoid your shell +accidentally expanding glob patterns before Cargo handles them, you must use +single quotes or double quotes around each pattern.
@@ -91,7 +97,8 @@ flag and will always document the given target.
--bin name...
-
Document the specified binary. This flag may be specified multiple times.
+
Document the specified binary. This flag may be specified multiple times +and supports common Unix glob patterns.
--bins
diff --git a/src/doc/src/commands/cargo-fix.md b/src/doc/src/commands/cargo-fix.md index ebfe443446d..8a96daaef41 100644 --- a/src/doc/src/commands/cargo-fix.md +++ b/src/doc/src/commands/cargo-fix.md @@ -98,7 +98,10 @@ virtual workspace will include all workspace members (equivalent to passing
-p spec...
--package spec...
Fix only the specified packages. See cargo-pkgid(1) for the -SPEC format. This flag may be specified multiple times.
+SPEC format. This flag may be specified multiple times and supports common Unix +glob patterns like *, ? and []. However, to avoid your shell accidentally +expanding glob patterns before Cargo handles them, you must use single quotes or +double quotes around each pattern.
--workspace
@@ -113,7 +116,10 @@ SPEC format. This flag may be specified multiple times.
--exclude SPEC...
Exclude the specified packages. Must be used in conjunction with the ---workspace flag. This flag may be specified multiple times.
+--workspace flag. This flag may be specified multiple times and supports +common Unix glob patterns like *, ? and []. However, to avoid your shell +accidentally expanding glob patterns before Cargo handles them, you must use +single quotes or double quotes around each pattern. @@ -126,7 +132,12 @@ When no target selection options are given, `cargo fix` will fix all targets `required-features` that are missing. Passing target selection flags will fix only the specified -targets. +targets. + +Note that `--bin`, `--example`, `--test` and `--bench` flags also +support common Unix glob patterns like `*`, `?` and `[]`. However, to avoid your +shell accidentally expanding glob patterns before Cargo handles them, you must +use single quotes or double quotes around each glob pattern.
@@ -135,7 +146,8 @@ targets.
--bin name...
-
Fix the specified binary. This flag may be specified multiple times.
+
Fix the specified binary. This flag may be specified multiple times +and supports common Unix glob patterns.
--bins
@@ -144,7 +156,8 @@ targets.
--example name...
-
Fix the specified example. This flag may be specified multiple times.
+
Fix the specified example. This flag may be specified multiple times +and supports common Unix glob patterns.
--examples
@@ -153,7 +166,7 @@ targets.
--test name...
Fix the specified integration test. This flag may be specified -multiple times.
+multiple times and supports common Unix glob patterns.
--tests
@@ -167,7 +180,8 @@ manifest settings for the target.
--bench name...
-
Fix the specified benchmark. This flag may be specified multiple times.
+
Fix the specified benchmark. This flag may be specified multiple +times and supports common Unix glob patterns.
--benches
diff --git a/src/doc/src/commands/cargo-rustc.md b/src/doc/src/commands/cargo-rustc.md index de0ded69347..cf3fd0a3d21 100644 --- a/src/doc/src/commands/cargo-rustc.md +++ b/src/doc/src/commands/cargo-rustc.md @@ -54,7 +54,12 @@ When no target selection options are given, `cargo rustc` will build all binary and library targets of the selected package. Passing target selection flags will build only the specified -targets. +targets. + +Note that `--bin`, `--example`, `--test` and `--bench` flags also +support common Unix glob patterns like `*`, `?` and `[]`. However, to avoid your +shell accidentally expanding glob patterns before Cargo handles them, you must +use single quotes or double quotes around each glob pattern.
@@ -63,7 +68,8 @@ targets.
--bin name...
-
Build the specified binary. This flag may be specified multiple times.
+
Build the specified binary. This flag may be specified multiple times +and supports common Unix glob patterns.
--bins
@@ -72,7 +78,8 @@ targets.
--example name...
-
Build the specified example. This flag may be specified multiple times.
+
Build the specified example. This flag may be specified multiple times +and supports common Unix glob patterns.
--examples
@@ -81,7 +88,7 @@ targets.
--test name...
Build the specified integration test. This flag may be specified -multiple times.
+multiple times and supports common Unix glob patterns.
--tests
@@ -95,7 +102,8 @@ manifest settings for the target.
--bench name...
-
Build the specified benchmark. This flag may be specified multiple times.
+
Build the specified benchmark. This flag may be specified multiple +times and supports common Unix glob patterns.
--benches
diff --git a/src/doc/src/commands/cargo-rustdoc.md b/src/doc/src/commands/cargo-rustdoc.md index bf8edb06c0a..fbf11b44ed3 100644 --- a/src/doc/src/commands/cargo-rustdoc.md +++ b/src/doc/src/commands/cargo-rustdoc.md @@ -67,7 +67,12 @@ if its name is the same as the lib target. Binaries are skipped if they have `required-features` that are missing. Passing target selection flags will document only the specified -targets. +targets. + +Note that `--bin`, `--example`, `--test` and `--bench` flags also +support common Unix glob patterns like `*`, `?` and `[]`. However, to avoid your +shell accidentally expanding glob patterns before Cargo handles them, you must +use single quotes or double quotes around each glob pattern.
@@ -76,7 +81,8 @@ targets.
--bin name...
-
Document the specified binary. This flag may be specified multiple times.
+
Document the specified binary. This flag may be specified multiple times +and supports common Unix glob patterns.
--bins
@@ -85,7 +91,8 @@ targets.
--example name...
-
Document the specified example. This flag may be specified multiple times.
+
Document the specified example. This flag may be specified multiple times +and supports common Unix glob patterns.
--examples
@@ -94,7 +101,7 @@ targets.
--test name...
Document the specified integration test. This flag may be specified -multiple times.
+multiple times and supports common Unix glob patterns.
--tests
@@ -108,7 +115,8 @@ manifest settings for the target.
--bench name...
-
Document the specified benchmark. This flag may be specified multiple times.
+
Document the specified benchmark. This flag may be specified multiple +times and supports common Unix glob patterns.
--benches
diff --git a/src/doc/src/commands/cargo-test.md b/src/doc/src/commands/cargo-test.md index 702ad796838..f8df6ce6c77 100644 --- a/src/doc/src/commands/cargo-test.md +++ b/src/doc/src/commands/cargo-test.md @@ -79,7 +79,10 @@ virtual workspace will include all workspace members (equivalent to passing
-p spec...
--package spec...
Test only the specified packages. See cargo-pkgid(1) for the -SPEC format. This flag may be specified multiple times.
+SPEC format. This flag may be specified multiple times and supports common Unix +glob patterns like *, ? and []. However, to avoid your shell accidentally +expanding glob patterns before Cargo handles them, you must use single quotes or +double quotes around each pattern.
--workspace
@@ -94,7 +97,10 @@ SPEC format. This flag may be specified multiple times.
--exclude SPEC...
Exclude the specified packages. Must be used in conjunction with the ---workspace flag. This flag may be specified multiple times.
+--workspace flag. This flag may be specified multiple times and supports +common Unix glob patterns like *, ? and []. However, to avoid your shell +accidentally expanding glob patterns before Cargo handles them, you must use +single quotes or double quotes around each pattern.
@@ -132,7 +138,12 @@ is set when the integration test is built so that it can use the executable. Passing target selection flags will test only the specified -targets. +targets. + +Note that `--bin`, `--example`, `--test` and `--bench` flags also +support common Unix glob patterns like `*`, `?` and `[]`. However, to avoid your +shell accidentally expanding glob patterns before Cargo handles them, you must +use single quotes or double quotes around each glob pattern.
@@ -141,7 +152,8 @@ targets.
--bin name...
-
Test the specified binary. This flag may be specified multiple times.
+
Test the specified binary. This flag may be specified multiple times +and supports common Unix glob patterns.
--bins
@@ -150,7 +162,8 @@ targets.
--example name...
-
Test the specified example. This flag may be specified multiple times.
+
Test the specified example. This flag may be specified multiple times +and supports common Unix glob patterns.
--examples
@@ -159,7 +172,7 @@ targets.
--test name...
Test the specified integration test. This flag may be specified -multiple times.
+multiple times and supports common Unix glob patterns.
--tests
@@ -173,7 +186,8 @@ manifest settings for the target.
--bench name...
-
Test the specified benchmark. This flag may be specified multiple times.
+
Test the specified benchmark. This flag may be specified multiple +times and supports common Unix glob patterns.
--benches
diff --git a/src/doc/src/commands/cargo-tree.md b/src/doc/src/commands/cargo-tree.md index 470056e0d26..70f1f6690f7 100644 --- a/src/doc/src/commands/cargo-tree.md +++ b/src/doc/src/commands/cargo-tree.md @@ -166,7 +166,10 @@ virtual workspace will include all workspace members (equivalent to passing
-p spec...
--package spec...
Display only the specified packages. See cargo-pkgid(1) for the -SPEC format. This flag may be specified multiple times.
+SPEC format. This flag may be specified multiple times and supports common Unix +glob patterns like *, ? and []. However, to avoid your shell accidentally +expanding glob patterns before Cargo handles them, you must use single quotes or +double quotes around each pattern.
--workspace
@@ -177,7 +180,10 @@ SPEC format. This flag may be specified multiple times.
--exclude SPEC...
Exclude the specified packages. Must be used in conjunction with the ---workspace flag. This flag may be specified multiple times.
+--workspace flag. This flag may be specified multiple times and supports +common Unix glob patterns like *, ? and []. However, to avoid your shell +accidentally expanding glob patterns before Cargo handles them, you must use +single quotes or double quotes around each pattern.
diff --git a/src/etc/man/cargo-bench.1 b/src/etc/man/cargo-bench.1 index 2543926ee18..f0875b1a4b4 100644 --- a/src/etc/man/cargo-bench.1 +++ b/src/etc/man/cargo-bench.1 @@ -78,7 +78,10 @@ virtual workspace will include all workspace members (equivalent to passing \fB\-\-package\fR \fIspec\fR\&... .RS 4 Benchmark only the specified packages. See \fBcargo\-pkgid\fR(1) for the -SPEC format. This flag may be specified multiple times. +SPEC format. This flag may be specified multiple times and supports common Unix +glob patterns like \fB*\fR, \fB?\fR and \fB[]\fR\&. However, to avoid your shell accidentally +expanding glob patterns before Cargo handles them, you must use single quotes or +double quotes around each pattern. .RE .sp \fB\-\-workspace\fR @@ -94,7 +97,10 @@ Deprecated alias for \fB\-\-workspace\fR\&. \fB\-\-exclude\fR \fISPEC\fR\&... .RS 4 Exclude the specified packages. Must be used in conjunction with the -\fB\-\-workspace\fR flag. This flag may be specified multiple times. +\fB\-\-workspace\fR flag. This flag may be specified multiple times and supports +common Unix glob patterns like \fB*\fR, \fB?\fR and \fB[]\fR\&. However, to avoid your shell +accidentally expanding glob patterns before Cargo handles them, you must use +single quotes or double quotes around each pattern. .RE .SS "Target Selection" When no target selection options are given, \fBcargo bench\fR will build the @@ -129,7 +135,12 @@ target by name ignore the \fBbench\fR flag and will always benchmark the given target. .sp Passing target selection flags will benchmark only the specified -targets. +targets. +.sp +Note that \fB\-\-bin\fR, \fB\-\-example\fR, \fB\-\-test\fR and \fB\-\-bench\fR flags also +support common Unix glob patterns like \fB*\fR, \fB?\fR and \fB[]\fR\&. However, to avoid your +shell accidentally expanding glob patterns before Cargo handles them, you must +use single quotes or double quotes around each glob pattern. .sp \fB\-\-lib\fR .RS 4 @@ -138,7 +149,8 @@ Benchmark the package's library. .sp \fB\-\-bin\fR \fIname\fR\&... .RS 4 -Benchmark the specified binary. This flag may be specified multiple times. +Benchmark the specified binary. This flag may be specified multiple times +and supports common Unix glob patterns. .RE .sp \fB\-\-bins\fR @@ -148,7 +160,8 @@ Benchmark all binary targets. .sp \fB\-\-example\fR \fIname\fR\&... .RS 4 -Benchmark the specified example. This flag may be specified multiple times. +Benchmark the specified example. This flag may be specified multiple times +and supports common Unix glob patterns. .RE .sp \fB\-\-examples\fR @@ -159,7 +172,7 @@ Benchmark all example targets. \fB\-\-test\fR \fIname\fR\&... .RS 4 Benchmark the specified integration test. This flag may be specified -multiple times. +multiple times and supports common Unix glob patterns. .RE .sp \fB\-\-tests\fR @@ -175,7 +188,8 @@ manifest settings for the target. .sp \fB\-\-bench\fR \fIname\fR\&... .RS 4 -Benchmark the specified benchmark. This flag may be specified multiple times. +Benchmark the specified benchmark. This flag may be specified multiple +times and supports common Unix glob patterns. .RE .sp \fB\-\-benches\fR diff --git a/src/etc/man/cargo-build.1 b/src/etc/man/cargo-build.1 index d5d2dc887cf..6f25076f277 100644 --- a/src/etc/man/cargo-build.1 +++ b/src/etc/man/cargo-build.1 @@ -26,7 +26,10 @@ virtual workspace will include all workspace members (equivalent to passing \fB\-\-package\fR \fIspec\fR\&... .RS 4 Build only the specified packages. See \fBcargo\-pkgid\fR(1) for the -SPEC format. This flag may be specified multiple times. +SPEC format. This flag may be specified multiple times and supports common Unix +glob patterns like \fB*\fR, \fB?\fR and \fB[]\fR\&. However, to avoid your shell accidentally +expanding glob patterns before Cargo handles them, you must use single quotes or +double quotes around each pattern. .RE .sp \fB\-\-workspace\fR @@ -42,7 +45,10 @@ Deprecated alias for \fB\-\-workspace\fR\&. \fB\-\-exclude\fR \fISPEC\fR\&... .RS 4 Exclude the specified packages. Must be used in conjunction with the -\fB\-\-workspace\fR flag. This flag may be specified multiple times. +\fB\-\-workspace\fR flag. This flag may be specified multiple times and supports +common Unix glob patterns like \fB*\fR, \fB?\fR and \fB[]\fR\&. However, to avoid your shell +accidentally expanding glob patterns before Cargo handles them, you must use +single quotes or double quotes around each pattern. .RE .SS "Target Selection" When no target selection options are given, \fBcargo build\fR will build all @@ -50,7 +56,12 @@ binary and library targets of the selected packages. Binaries are skipped if they have \fBrequired\-features\fR that are missing. .sp Passing target selection flags will build only the specified -targets. +targets. +.sp +Note that \fB\-\-bin\fR, \fB\-\-example\fR, \fB\-\-test\fR and \fB\-\-bench\fR flags also +support common Unix glob patterns like \fB*\fR, \fB?\fR and \fB[]\fR\&. However, to avoid your +shell accidentally expanding glob patterns before Cargo handles them, you must +use single quotes or double quotes around each glob pattern. .sp \fB\-\-lib\fR .RS 4 @@ -59,7 +70,8 @@ Build the package's library. .sp \fB\-\-bin\fR \fIname\fR\&... .RS 4 -Build the specified binary. This flag may be specified multiple times. +Build the specified binary. This flag may be specified multiple times +and supports common Unix glob patterns. .RE .sp \fB\-\-bins\fR @@ -69,7 +81,8 @@ Build all binary targets. .sp \fB\-\-example\fR \fIname\fR\&... .RS 4 -Build the specified example. This flag may be specified multiple times. +Build the specified example. This flag may be specified multiple times +and supports common Unix glob patterns. .RE .sp \fB\-\-examples\fR @@ -80,7 +93,7 @@ Build all example targets. \fB\-\-test\fR \fIname\fR\&... .RS 4 Build the specified integration test. This flag may be specified -multiple times. +multiple times and supports common Unix glob patterns. .RE .sp \fB\-\-tests\fR @@ -96,7 +109,8 @@ manifest settings for the target. .sp \fB\-\-bench\fR \fIname\fR\&... .RS 4 -Build the specified benchmark. This flag may be specified multiple times. +Build the specified benchmark. This flag may be specified multiple +times and supports common Unix glob patterns. .RE .sp \fB\-\-benches\fR diff --git a/src/etc/man/cargo-check.1 b/src/etc/man/cargo-check.1 index fdbfedfeaff..b088a1392d5 100644 --- a/src/etc/man/cargo-check.1 +++ b/src/etc/man/cargo-check.1 @@ -31,7 +31,10 @@ virtual workspace will include all workspace members (equivalent to passing \fB\-\-package\fR \fIspec\fR\&... .RS 4 Check only the specified packages. See \fBcargo\-pkgid\fR(1) for the -SPEC format. This flag may be specified multiple times. +SPEC format. This flag may be specified multiple times and supports common Unix +glob patterns like \fB*\fR, \fB?\fR and \fB[]\fR\&. However, to avoid your shell accidentally +expanding glob patterns before Cargo handles them, you must use single quotes or +double quotes around each pattern. .RE .sp \fB\-\-workspace\fR @@ -47,7 +50,10 @@ Deprecated alias for \fB\-\-workspace\fR\&. \fB\-\-exclude\fR \fISPEC\fR\&... .RS 4 Exclude the specified packages. Must be used in conjunction with the -\fB\-\-workspace\fR flag. This flag may be specified multiple times. +\fB\-\-workspace\fR flag. This flag may be specified multiple times and supports +common Unix glob patterns like \fB*\fR, \fB?\fR and \fB[]\fR\&. However, to avoid your shell +accidentally expanding glob patterns before Cargo handles them, you must use +single quotes or double quotes around each pattern. .RE .SS "Target Selection" When no target selection options are given, \fBcargo check\fR will check all @@ -55,7 +61,12 @@ binary and library targets of the selected packages. Binaries are skipped if they have \fBrequired\-features\fR that are missing. .sp Passing target selection flags will check only the specified -targets. +targets. +.sp +Note that \fB\-\-bin\fR, \fB\-\-example\fR, \fB\-\-test\fR and \fB\-\-bench\fR flags also +support common Unix glob patterns like \fB*\fR, \fB?\fR and \fB[]\fR\&. However, to avoid your +shell accidentally expanding glob patterns before Cargo handles them, you must +use single quotes or double quotes around each glob pattern. .sp \fB\-\-lib\fR .RS 4 @@ -64,7 +75,8 @@ Check the package's library. .sp \fB\-\-bin\fR \fIname\fR\&... .RS 4 -Check the specified binary. This flag may be specified multiple times. +Check the specified binary. This flag may be specified multiple times +and supports common Unix glob patterns. .RE .sp \fB\-\-bins\fR @@ -74,7 +86,8 @@ Check all binary targets. .sp \fB\-\-example\fR \fIname\fR\&... .RS 4 -Check the specified example. This flag may be specified multiple times. +Check the specified example. This flag may be specified multiple times +and supports common Unix glob patterns. .RE .sp \fB\-\-examples\fR @@ -85,7 +98,7 @@ Check all example targets. \fB\-\-test\fR \fIname\fR\&... .RS 4 Check the specified integration test. This flag may be specified -multiple times. +multiple times and supports common Unix glob patterns. .RE .sp \fB\-\-tests\fR @@ -101,7 +114,8 @@ manifest settings for the target. .sp \fB\-\-bench\fR \fIname\fR\&... .RS 4 -Check the specified benchmark. This flag may be specified multiple times. +Check the specified benchmark. This flag may be specified multiple +times and supports common Unix glob patterns. .RE .sp \fB\-\-benches\fR diff --git a/src/etc/man/cargo-doc.1 b/src/etc/man/cargo-doc.1 index 11484848039..7d36e680850 100644 --- a/src/etc/man/cargo-doc.1 +++ b/src/etc/man/cargo-doc.1 @@ -44,7 +44,10 @@ virtual workspace will include all workspace members (equivalent to passing \fB\-\-package\fR \fIspec\fR\&... .RS 4 Document only the specified packages. See \fBcargo\-pkgid\fR(1) for the -SPEC format. This flag may be specified multiple times. +SPEC format. This flag may be specified multiple times and supports common Unix +glob patterns like \fB*\fR, \fB?\fR and \fB[]\fR\&. However, to avoid your shell accidentally +expanding glob patterns before Cargo handles them, you must use single quotes or +double quotes around each pattern. .RE .sp \fB\-\-workspace\fR @@ -60,7 +63,10 @@ Deprecated alias for \fB\-\-workspace\fR\&. \fB\-\-exclude\fR \fISPEC\fR\&... .RS 4 Exclude the specified packages. Must be used in conjunction with the -\fB\-\-workspace\fR flag. This flag may be specified multiple times. +\fB\-\-workspace\fR flag. This flag may be specified multiple times and supports +common Unix glob patterns like \fB*\fR, \fB?\fR and \fB[]\fR\&. However, to avoid your shell +accidentally expanding glob patterns before Cargo handles them, you must use +single quotes or double quotes around each pattern. .RE .SS "Target Selection" When no target selection options are given, \fBcargo doc\fR will document all @@ -79,7 +85,8 @@ Document the package's library. .sp \fB\-\-bin\fR \fIname\fR\&... .RS 4 -Document the specified binary. This flag may be specified multiple times. +Document the specified binary. This flag may be specified multiple times +and supports common Unix glob patterns. .RE .sp \fB\-\-bins\fR diff --git a/src/etc/man/cargo-fix.1 b/src/etc/man/cargo-fix.1 index 4bf9a276d22..80b4c34cd83 100644 --- a/src/etc/man/cargo-fix.1 +++ b/src/etc/man/cargo-fix.1 @@ -104,7 +104,10 @@ virtual workspace will include all workspace members (equivalent to passing \fB\-\-package\fR \fIspec\fR\&... .RS 4 Fix only the specified packages. See \fBcargo\-pkgid\fR(1) for the -SPEC format. This flag may be specified multiple times. +SPEC format. This flag may be specified multiple times and supports common Unix +glob patterns like \fB*\fR, \fB?\fR and \fB[]\fR\&. However, to avoid your shell accidentally +expanding glob patterns before Cargo handles them, you must use single quotes or +double quotes around each pattern. .RE .sp \fB\-\-workspace\fR @@ -120,7 +123,10 @@ Deprecated alias for \fB\-\-workspace\fR\&. \fB\-\-exclude\fR \fISPEC\fR\&... .RS 4 Exclude the specified packages. Must be used in conjunction with the -\fB\-\-workspace\fR flag. This flag may be specified multiple times. +\fB\-\-workspace\fR flag. This flag may be specified multiple times and supports +common Unix glob patterns like \fB*\fR, \fB?\fR and \fB[]\fR\&. However, to avoid your shell +accidentally expanding glob patterns before Cargo handles them, you must use +single quotes or double quotes around each pattern. .RE .SS "Target Selection" When no target selection options are given, \fBcargo fix\fR will fix all targets @@ -128,7 +134,12 @@ When no target selection options are given, \fBcargo fix\fR will fix all targets \fBrequired\-features\fR that are missing. .sp Passing target selection flags will fix only the specified -targets. +targets. +.sp +Note that \fB\-\-bin\fR, \fB\-\-example\fR, \fB\-\-test\fR and \fB\-\-bench\fR flags also +support common Unix glob patterns like \fB*\fR, \fB?\fR and \fB[]\fR\&. However, to avoid your +shell accidentally expanding glob patterns before Cargo handles them, you must +use single quotes or double quotes around each glob pattern. .sp \fB\-\-lib\fR .RS 4 @@ -137,7 +148,8 @@ Fix the package's library. .sp \fB\-\-bin\fR \fIname\fR\&... .RS 4 -Fix the specified binary. This flag may be specified multiple times. +Fix the specified binary. This flag may be specified multiple times +and supports common Unix glob patterns. .RE .sp \fB\-\-bins\fR @@ -147,7 +159,8 @@ Fix all binary targets. .sp \fB\-\-example\fR \fIname\fR\&... .RS 4 -Fix the specified example. This flag may be specified multiple times. +Fix the specified example. This flag may be specified multiple times +and supports common Unix glob patterns. .RE .sp \fB\-\-examples\fR @@ -158,7 +171,7 @@ Fix all example targets. \fB\-\-test\fR \fIname\fR\&... .RS 4 Fix the specified integration test. This flag may be specified -multiple times. +multiple times and supports common Unix glob patterns. .RE .sp \fB\-\-tests\fR @@ -174,7 +187,8 @@ manifest settings for the target. .sp \fB\-\-bench\fR \fIname\fR\&... .RS 4 -Fix the specified benchmark. This flag may be specified multiple times. +Fix the specified benchmark. This flag may be specified multiple +times and supports common Unix glob patterns. .RE .sp \fB\-\-benches\fR diff --git a/src/etc/man/cargo-rustc.1 b/src/etc/man/cargo-rustc.1 index c5c257b1c85..ca205f04786 100644 --- a/src/etc/man/cargo-rustc.1 +++ b/src/etc/man/cargo-rustc.1 @@ -42,7 +42,12 @@ When no target selection options are given, \fBcargo rustc\fR will build all binary and library targets of the selected package. .sp Passing target selection flags will build only the specified -targets. +targets. +.sp +Note that \fB\-\-bin\fR, \fB\-\-example\fR, \fB\-\-test\fR and \fB\-\-bench\fR flags also +support common Unix glob patterns like \fB*\fR, \fB?\fR and \fB[]\fR\&. However, to avoid your +shell accidentally expanding glob patterns before Cargo handles them, you must +use single quotes or double quotes around each glob pattern. .sp \fB\-\-lib\fR .RS 4 @@ -51,7 +56,8 @@ Build the package's library. .sp \fB\-\-bin\fR \fIname\fR\&... .RS 4 -Build the specified binary. This flag may be specified multiple times. +Build the specified binary. This flag may be specified multiple times +and supports common Unix glob patterns. .RE .sp \fB\-\-bins\fR @@ -61,7 +67,8 @@ Build all binary targets. .sp \fB\-\-example\fR \fIname\fR\&... .RS 4 -Build the specified example. This flag may be specified multiple times. +Build the specified example. This flag may be specified multiple times +and supports common Unix glob patterns. .RE .sp \fB\-\-examples\fR @@ -72,7 +79,7 @@ Build all example targets. \fB\-\-test\fR \fIname\fR\&... .RS 4 Build the specified integration test. This flag may be specified -multiple times. +multiple times and supports common Unix glob patterns. .RE .sp \fB\-\-tests\fR @@ -88,7 +95,8 @@ manifest settings for the target. .sp \fB\-\-bench\fR \fIname\fR\&... .RS 4 -Build the specified benchmark. This flag may be specified multiple times. +Build the specified benchmark. This flag may be specified multiple +times and supports common Unix glob patterns. .RE .sp \fB\-\-benches\fR diff --git a/src/etc/man/cargo-rustdoc.1 b/src/etc/man/cargo-rustdoc.1 index 0a27df44c7b..511141b61a0 100644 --- a/src/etc/man/cargo-rustdoc.1 +++ b/src/etc/man/cargo-rustdoc.1 @@ -51,7 +51,12 @@ if its name is the same as the lib target. Binaries are skipped if they have \fBrequired\-features\fR that are missing. .sp Passing target selection flags will document only the specified -targets. +targets. +.sp +Note that \fB\-\-bin\fR, \fB\-\-example\fR, \fB\-\-test\fR and \fB\-\-bench\fR flags also +support common Unix glob patterns like \fB*\fR, \fB?\fR and \fB[]\fR\&. However, to avoid your +shell accidentally expanding glob patterns before Cargo handles them, you must +use single quotes or double quotes around each glob pattern. .sp \fB\-\-lib\fR .RS 4 @@ -60,7 +65,8 @@ Document the package's library. .sp \fB\-\-bin\fR \fIname\fR\&... .RS 4 -Document the specified binary. This flag may be specified multiple times. +Document the specified binary. This flag may be specified multiple times +and supports common Unix glob patterns. .RE .sp \fB\-\-bins\fR @@ -70,7 +76,8 @@ Document all binary targets. .sp \fB\-\-example\fR \fIname\fR\&... .RS 4 -Document the specified example. This flag may be specified multiple times. +Document the specified example. This flag may be specified multiple times +and supports common Unix glob patterns. .RE .sp \fB\-\-examples\fR @@ -81,7 +88,7 @@ Document all example targets. \fB\-\-test\fR \fIname\fR\&... .RS 4 Document the specified integration test. This flag may be specified -multiple times. +multiple times and supports common Unix glob patterns. .RE .sp \fB\-\-tests\fR @@ -97,7 +104,8 @@ manifest settings for the target. .sp \fB\-\-bench\fR \fIname\fR\&... .RS 4 -Document the specified benchmark. This flag may be specified multiple times. +Document the specified benchmark. This flag may be specified multiple +times and supports common Unix glob patterns. .RE .sp \fB\-\-benches\fR diff --git a/src/etc/man/cargo-test.1 b/src/etc/man/cargo-test.1 index fa1f2637dca..fa66fc71451 100644 --- a/src/etc/man/cargo-test.1 +++ b/src/etc/man/cargo-test.1 @@ -71,7 +71,10 @@ virtual workspace will include all workspace members (equivalent to passing \fB\-\-package\fR \fIspec\fR\&... .RS 4 Test only the specified packages. See \fBcargo\-pkgid\fR(1) for the -SPEC format. This flag may be specified multiple times. +SPEC format. This flag may be specified multiple times and supports common Unix +glob patterns like \fB*\fR, \fB?\fR and \fB[]\fR\&. However, to avoid your shell accidentally +expanding glob patterns before Cargo handles them, you must use single quotes or +double quotes around each pattern. .RE .sp \fB\-\-workspace\fR @@ -87,7 +90,10 @@ Deprecated alias for \fB\-\-workspace\fR\&. \fB\-\-exclude\fR \fISPEC\fR\&... .RS 4 Exclude the specified packages. Must be used in conjunction with the -\fB\-\-workspace\fR flag. This flag may be specified multiple times. +\fB\-\-workspace\fR flag. This flag may be specified multiple times and supports +common Unix glob patterns like \fB*\fR, \fB?\fR and \fB[]\fR\&. However, to avoid your shell +accidentally expanding glob patterns before Cargo handles them, you must use +single quotes or double quotes around each pattern. .RE .SS "Target Selection" When no target selection options are given, \fBcargo test\fR will build the @@ -140,7 +146,12 @@ is set when the integration test is built so that it can use the executable. .sp Passing target selection flags will test only the specified -targets. +targets. +.sp +Note that \fB\-\-bin\fR, \fB\-\-example\fR, \fB\-\-test\fR and \fB\-\-bench\fR flags also +support common Unix glob patterns like \fB*\fR, \fB?\fR and \fB[]\fR\&. However, to avoid your +shell accidentally expanding glob patterns before Cargo handles them, you must +use single quotes or double quotes around each glob pattern. .sp \fB\-\-lib\fR .RS 4 @@ -149,7 +160,8 @@ Test the package's library. .sp \fB\-\-bin\fR \fIname\fR\&... .RS 4 -Test the specified binary. This flag may be specified multiple times. +Test the specified binary. This flag may be specified multiple times +and supports common Unix glob patterns. .RE .sp \fB\-\-bins\fR @@ -159,7 +171,8 @@ Test all binary targets. .sp \fB\-\-example\fR \fIname\fR\&... .RS 4 -Test the specified example. This flag may be specified multiple times. +Test the specified example. This flag may be specified multiple times +and supports common Unix glob patterns. .RE .sp \fB\-\-examples\fR @@ -170,7 +183,7 @@ Test all example targets. \fB\-\-test\fR \fIname\fR\&... .RS 4 Test the specified integration test. This flag may be specified -multiple times. +multiple times and supports common Unix glob patterns. .RE .sp \fB\-\-tests\fR @@ -186,7 +199,8 @@ manifest settings for the target. .sp \fB\-\-bench\fR \fIname\fR\&... .RS 4 -Test the specified benchmark. This flag may be specified multiple times. +Test the specified benchmark. This flag may be specified multiple +times and supports common Unix glob patterns. .RE .sp \fB\-\-benches\fR diff --git a/src/etc/man/cargo-tree.1 b/src/etc/man/cargo-tree.1 index 0fcdd384976..34afebc18a9 100644 --- a/src/etc/man/cargo-tree.1 +++ b/src/etc/man/cargo-tree.1 @@ -204,7 +204,10 @@ virtual workspace will include all workspace members (equivalent to passing \fB\-\-package\fR \fIspec\fR\&... .RS 4 Display only the specified packages. See \fBcargo\-pkgid\fR(1) for the -SPEC format. This flag may be specified multiple times. +SPEC format. This flag may be specified multiple times and supports common Unix +glob patterns like \fB*\fR, \fB?\fR and \fB[]\fR\&. However, to avoid your shell accidentally +expanding glob patterns before Cargo handles them, you must use single quotes or +double quotes around each pattern. .RE .sp \fB\-\-workspace\fR @@ -215,7 +218,10 @@ Display all members in the workspace. \fB\-\-exclude\fR \fISPEC\fR\&... .RS 4 Exclude the specified packages. Must be used in conjunction with the -\fB\-\-workspace\fR flag. This flag may be specified multiple times. +\fB\-\-workspace\fR flag. This flag may be specified multiple times and supports +common Unix glob patterns like \fB*\fR, \fB?\fR and \fB[]\fR\&. However, to avoid your shell +accidentally expanding glob patterns before Cargo handles them, you must use +single quotes or double quotes around each pattern. .RE .SS "Manifest Options" .sp diff --git a/tests/testsuite/bench.rs b/tests/testsuite/bench.rs index 30661521782..6f2c39901c6 100644 --- a/tests/testsuite/bench.rs +++ b/tests/testsuite/bench.rs @@ -1458,6 +1458,55 @@ test bar ... bench: [..] ns/iter (+/- [..])", .run(); } +#[cargo_test] +fn bench_all_exclude_glob() { + if !is_nightly() { + return; + } + + let p = project() + .file( + "Cargo.toml", + r#" + [project] + name = "foo" + version = "0.1.0" + + [workspace] + members = ["bar", "baz"] + "#, + ) + .file("src/main.rs", "fn main() {}") + .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) + .file( + "bar/src/lib.rs", + r#" + #![feature(test)] + #[cfg(test)] + extern crate test; + + #[bench] + pub fn bar(b: &mut test::Bencher) { + b.iter(|| {}); + } + "#, + ) + .file("baz/Cargo.toml", &basic_manifest("baz", "0.1.0")) + .file( + "baz/src/lib.rs", + "#[test] pub fn baz() { break_the_build(); }", + ) + .build(); + + p.cargo("bench --workspace --exclude '*z'") + .with_stdout_contains( + "\ +running 1 test +test bar ... bench: [..] ns/iter (+/- [..])", + ) + .run(); +} + #[cargo_test] fn bench_all_virtual_manifest() { if !is_nightly() { @@ -1511,6 +1560,59 @@ fn bench_all_virtual_manifest() { .run(); } +#[cargo_test] +fn bench_virtual_manifest_glob() { + if !is_nightly() { + return; + } + + let p = project() + .file( + "Cargo.toml", + r#" + [workspace] + members = ["bar", "baz"] + "#, + ) + .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) + .file("bar/src/lib.rs", "pub fn bar() { break_the_build(); }") + .file( + "bar/benches/bar.rs", + r#" + #![feature(test)] + extern crate test; + + use test::Bencher; + + #[bench] + fn bench_bar(_: &mut Bencher) -> () { break_the_build(); } + "#, + ) + .file("baz/Cargo.toml", &basic_manifest("baz", "0.1.0")) + .file("baz/src/lib.rs", "pub fn baz() {}") + .file( + "baz/benches/baz.rs", + r#" + #![feature(test)] + extern crate test; + + use test::Bencher; + + #[bench] + fn bench_baz(_: &mut Bencher) -> () { () } + "#, + ) + .build(); + + // The order in which bar and baz are built is not guaranteed + p.cargo("bench -p '*z'") + .with_stderr_contains("[RUNNING] target/release/deps/baz-[..][EXE]") + .with_stdout_contains("test bench_baz ... bench: [..]") + .with_stderr_does_not_contain("[RUNNING] target/release/deps/bar-[..][EXE]") + .with_stdout_does_not_contain("test bench_bar ... bench: [..]") + .run(); +} + // https://github.com/rust-lang/cargo/issues/4287 #[cargo_test] fn legacy_bench_name() { diff --git a/tests/testsuite/build.rs b/tests/testsuite/build.rs index a350286d55c..c1a245e337c 100644 --- a/tests/testsuite/build.rs +++ b/tests/testsuite/build.rs @@ -3450,9 +3450,11 @@ fn build_all_workspace() { p.cargo("build --workspace") .with_stderr( - "[..] Compiling bar v0.1.0 ([..])\n\ - [..] Compiling foo v0.1.0 ([..])\n\ - [..] Finished dev [unoptimized + debuginfo] target(s) in [..]\n", + "\ +[COMPILING] bar v0.1.0 ([..]) +[COMPILING] foo v0.1.0 ([..]) +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +", ) .run(); } @@ -3479,9 +3481,121 @@ fn build_all_exclude() { .build(); p.cargo("build --workspace --exclude baz") - .with_stderr_contains("[..]Compiling foo v0.1.0 [..]") - .with_stderr_contains("[..]Compiling bar v0.1.0 [..]") - .with_stderr_does_not_contain("[..]Compiling baz v0.1.0 [..]") + .with_stderr_does_not_contain("[COMPILING] baz v0.1.0 [..]") + .with_stderr_unordered( + "\ +[COMPILING] foo v0.1.0 ([..]) +[COMPILING] bar v0.1.0 ([..]) +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +", + ) + .run(); +} + +#[cargo_test] +fn build_all_exclude_not_found() { + let p = project() + .file( + "Cargo.toml", + r#" + [project] + name = "foo" + version = "0.1.0" + + [workspace] + members = ["bar"] + "#, + ) + .file("src/main.rs", "fn main() {}") + .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) + .file("bar/src/lib.rs", "pub fn bar() {}") + .build(); + + p.cargo("build --workspace --exclude baz") + .with_stderr_does_not_contain("[COMPILING] baz v0.1.0 [..]") + .with_stderr_unordered( + "\ +[WARNING] excluded package(s) `baz` not found in workspace [..] +[COMPILING] foo v0.1.0 ([..]) +[COMPILING] bar v0.1.0 ([..]) +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +", + ) + .run(); +} + +#[cargo_test] +fn build_all_exclude_glob() { + let p = project() + .file( + "Cargo.toml", + r#" + [project] + name = "foo" + version = "0.1.0" + + [workspace] + members = ["bar", "baz"] + "#, + ) + .file("src/main.rs", "fn main() {}") + .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) + .file("bar/src/lib.rs", "pub fn bar() {}") + .file("baz/Cargo.toml", &basic_manifest("baz", "0.1.0")) + .file("baz/src/lib.rs", "pub fn baz() { break_the_build(); }") + .build(); + + p.cargo("build --workspace --exclude '*z'") + .with_stderr_does_not_contain("[COMPILING] baz v0.1.0 [..]") + .with_stderr_unordered( + "\ +[COMPILING] foo v0.1.0 ([..]) +[COMPILING] bar v0.1.0 ([..]) +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +", + ) + .run(); +} + +#[cargo_test] +fn build_all_exclude_glob_not_found() { + let p = project() + .file( + "Cargo.toml", + r#" + [project] + name = "foo" + version = "0.1.0" + + [workspace] + members = ["bar"] + "#, + ) + .file("src/main.rs", "fn main() {}") + .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) + .file("bar/src/lib.rs", "pub fn bar() {}") + .build(); + + p.cargo("build --workspace --exclude '*z'") + .with_stderr_does_not_contain("[COMPILING] baz v0.1.0 [..]") + .with_stderr( + "\ +[WARNING] excluded package pattern(s) `*z` not found in workspace [..] +[COMPILING] [..] v0.1.0 ([..]) +[COMPILING] [..] v0.1.0 ([..]) +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +", + ) + .run(); +} + +#[cargo_test] +fn build_all_exclude_broken_glob() { + let p = project().file("src/main.rs", "fn main() {}").build(); + + p.cargo("build --workspace --exclude '[*z'") + .with_status(101) + .with_stderr_contains("[ERROR] cannot build glob pattern from `[*z`") .run(); } @@ -3549,12 +3663,12 @@ fn build_all_virtual_manifest() { // The order in which bar and baz are built is not guaranteed p.cargo("build --workspace") - .with_stderr_contains("[..] Compiling baz v0.1.0 ([..])") - .with_stderr_contains("[..] Compiling bar v0.1.0 ([..])") - .with_stderr( - "[..] Compiling [..] v0.1.0 ([..])\n\ - [..] Compiling [..] v0.1.0 ([..])\n\ - [..] Finished dev [unoptimized + debuginfo] target(s) in [..]\n", + .with_stderr_unordered( + "\ +[COMPILING] baz v0.1.0 ([..]) +[COMPILING] bar v0.1.0 ([..]) +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +", ) .run(); } @@ -3577,12 +3691,12 @@ fn build_virtual_manifest_all_implied() { // The order in which `bar` and `baz` are built is not guaranteed. p.cargo("build") - .with_stderr_contains("[..] Compiling baz v0.1.0 ([..])") - .with_stderr_contains("[..] Compiling bar v0.1.0 ([..])") - .with_stderr( - "[..] Compiling [..] v0.1.0 ([..])\n\ - [..] Compiling [..] v0.1.0 ([..])\n\ - [..] Finished dev [unoptimized + debuginfo] target(s) in [..]\n", + .with_stderr_unordered( + "\ +[COMPILING] baz v0.1.0 ([..]) +[COMPILING] bar v0.1.0 ([..]) +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +", ) .run(); } @@ -3600,16 +3714,84 @@ fn build_virtual_manifest_one_project() { .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("bar/src/lib.rs", "pub fn bar() {}") .file("baz/Cargo.toml", &basic_manifest("baz", "0.1.0")) - .file("baz/src/lib.rs", "pub fn baz() {}") + .file("baz/src/lib.rs", "pub fn baz() { break_the_build(); }") .build(); p.cargo("build -p bar") .with_stderr_does_not_contain("[..]baz[..]") - .with_stderr_contains("[..] Compiling bar v0.1.0 ([..])") .with_stderr( - "[..] Compiling [..] v0.1.0 ([..])\n\ - [..] Finished dev [unoptimized + debuginfo] target(s) in [..]\n", + "\ +[COMPILING] bar v0.1.0 ([..]) +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +", + ) + .run(); +} + +#[cargo_test] +fn build_virtual_manifest_glob() { + let p = project() + .file( + "Cargo.toml", + r#" + [workspace] + members = ["bar", "baz"] + "#, + ) + .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) + .file("bar/src/lib.rs", "pub fn bar() { break_the_build(); }") + .file("baz/Cargo.toml", &basic_manifest("baz", "0.1.0")) + .file("baz/src/lib.rs", "pub fn baz() {}") + .build(); + + p.cargo("build -p '*z'") + .with_stderr_does_not_contain("[..]bar[..]") + .with_stderr( + "\ +[COMPILING] baz v0.1.0 ([..]) +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +", + ) + .run(); +} + +#[cargo_test] +fn build_virtual_manifest_glob_not_found() { + let p = project() + .file( + "Cargo.toml", + r#" + [workspace] + members = ["bar"] + "#, + ) + .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) + .file("bar/src/lib.rs", "pub fn bar() {}") + .build(); + + p.cargo("build -p bar -p '*z'") + .with_status(101) + .with_stderr("[ERROR] package pattern(s) `*z` not found in workspace [..]") + .run(); +} + +#[cargo_test] +fn build_virtual_manifest_broken_glob() { + let p = project() + .file( + "Cargo.toml", + r#" + [workspace] + members = ["bar"] + "#, ) + .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) + .file("bar/src/lib.rs", "pub fn bar() {}") + .build(); + + p.cargo("build -p '[*z'") + .with_status(101) + .with_stderr_contains("[ERROR] cannot build glob pattern from `[*z`") .run(); } @@ -3639,12 +3821,12 @@ fn build_all_virtual_manifest_implicit_examples() { // The order in which bar and baz are built is not guaranteed p.cargo("build --workspace --examples") - .with_stderr_contains("[..] Compiling baz v0.1.0 ([..])") - .with_stderr_contains("[..] Compiling bar v0.1.0 ([..])") - .with_stderr( - "[..] Compiling [..] v0.1.0 ([..])\n\ - [..] Compiling [..] v0.1.0 ([..])\n\ - [..] Finished dev [unoptimized + debuginfo] target(s) in [..]\n", + .with_stderr_unordered( + "\ +[COMPILING] baz v0.1.0 ([..]) +[COMPILING] bar v0.1.0 ([..]) +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +", ) .run(); assert!(!p.bin("a").is_file()); @@ -4579,6 +4761,16 @@ fn target_filters_workspace() { "\ [ERROR] no example target named `ex` +Did you mean `ex1`?", + ) + .run(); + + ws.cargo("build -v --example 'ex??'") + .with_status(101) + .with_stderr( + "\ +[ERROR] no example target matches pattern `ex??` + Did you mean `ex1`?", ) .run(); diff --git a/tests/testsuite/check.rs b/tests/testsuite/check.rs index 1c10aa5d8bd..259c6bfdf15 100644 --- a/tests/testsuite/check.rs +++ b/tests/testsuite/check.rs @@ -414,6 +414,60 @@ fn check_all() { .run(); } +#[cargo_test] +fn check_all_exclude() { + let p = project() + .file( + "Cargo.toml", + r#" + [workspace] + members = ["bar", "baz"] + "#, + ) + .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) + .file("bar/src/lib.rs", "pub fn bar() {}") + .file("baz/Cargo.toml", &basic_manifest("baz", "0.1.0")) + .file("baz/src/lib.rs", "pub fn baz() { break_the_build(); }") + .build(); + + p.cargo("check --workspace --exclude baz") + .with_stderr_does_not_contain("[CHECKING] baz v0.1.0 [..]") + .with_stderr( + "\ +[CHECKING] bar v0.1.0 ([..]) +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +", + ) + .run(); +} + +#[cargo_test] +fn check_all_exclude_glob() { + let p = project() + .file( + "Cargo.toml", + r#" + [workspace] + members = ["bar", "baz"] + "#, + ) + .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) + .file("bar/src/lib.rs", "pub fn bar() {}") + .file("baz/Cargo.toml", &basic_manifest("baz", "0.1.0")) + .file("baz/src/lib.rs", "pub fn baz() { break_the_build(); }") + .build(); + + p.cargo("check --workspace --exclude '*z'") + .with_stderr_does_not_contain("[CHECKING] baz v0.1.0 [..]") + .with_stderr( + "\ +[CHECKING] bar v0.1.0 ([..]) +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +", + ) + .run(); +} + #[cargo_test] fn check_virtual_all_implied() { let p = project() @@ -436,6 +490,60 @@ fn check_virtual_all_implied() { .run(); } +#[cargo_test] +fn check_virtual_manifest_one_project() { + let p = project() + .file( + "Cargo.toml", + r#" + [workspace] + members = ["bar", "baz"] + "#, + ) + .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) + .file("bar/src/lib.rs", "pub fn bar() {}") + .file("baz/Cargo.toml", &basic_manifest("baz", "0.1.0")) + .file("baz/src/lib.rs", "pub fn baz() { break_the_build(); }") + .build(); + + p.cargo("check -p bar") + .with_stderr_does_not_contain("[CHECKING] baz v0.1.0 [..]") + .with_stderr( + "\ +[CHECKING] bar v0.1.0 ([..]) +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +", + ) + .run(); +} + +#[cargo_test] +fn check_virtual_manifest_glob() { + let p = project() + .file( + "Cargo.toml", + r#" + [workspace] + members = ["bar", "baz"] + "#, + ) + .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) + .file("bar/src/lib.rs", "pub fn bar() { break_the_build(); }") + .file("baz/Cargo.toml", &basic_manifest("baz", "0.1.0")) + .file("baz/src/lib.rs", "pub fn baz() {}") + .build(); + + p.cargo("check -p '*z'") + .with_stderr_does_not_contain("[CHECKING] bar v0.1.0 [..]") + .with_stderr( + "\ +[CHECKING] baz v0.1.0 ([..]) +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +", + ) + .run(); +} + #[cargo_test] fn exclude_warns_on_non_existing_package() { let p = project().file("src/lib.rs", "").build(); @@ -443,7 +551,7 @@ fn exclude_warns_on_non_existing_package() { .with_stdout("") .with_stderr( "\ -[WARNING] excluded package(s) bar not found in workspace `[CWD]` +[WARNING] excluded package(s) `bar` not found in workspace `[CWD]` [CHECKING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", diff --git a/tests/testsuite/doc.rs b/tests/testsuite/doc.rs index df8f1967b8e..8b1749f5e81 100644 --- a/tests/testsuite/doc.rs +++ b/tests/testsuite/doc.rs @@ -540,6 +540,60 @@ fn doc_dash_p() { .run(); } +#[cargo_test] +fn doc_all_exclude() { + let p = project() + .file( + "Cargo.toml", + r#" + [workspace] + members = ["bar", "baz"] + "#, + ) + .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) + .file("bar/src/lib.rs", "pub fn bar() {}") + .file("baz/Cargo.toml", &basic_manifest("baz", "0.1.0")) + .file("baz/src/lib.rs", "pub fn baz() { break_the_build(); }") + .build(); + + p.cargo("doc --workspace --exclude baz") + .with_stderr_does_not_contain("[DOCUMENTING] baz v0.1.0 [..]") + .with_stderr( + "\ +[DOCUMENTING] bar v0.1.0 ([..]) +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +", + ) + .run(); +} + +#[cargo_test] +fn doc_all_exclude_glob() { + let p = project() + .file( + "Cargo.toml", + r#" + [workspace] + members = ["bar", "baz"] + "#, + ) + .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) + .file("bar/src/lib.rs", "pub fn bar() {}") + .file("baz/Cargo.toml", &basic_manifest("baz", "0.1.0")) + .file("baz/src/lib.rs", "pub fn baz() { break_the_build(); }") + .build(); + + p.cargo("doc --workspace --exclude '*z'") + .with_stderr_does_not_contain("[DOCUMENTING] baz v0.1.0 [..]") + .with_stderr( + "\ +[DOCUMENTING] bar v0.1.0 ([..]) +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +", + ) + .run(); +} + #[cargo_test] fn doc_same_name() { let p = project() @@ -955,6 +1009,60 @@ fn doc_virtual_manifest_all_implied() { .run(); } +#[cargo_test] +fn doc_virtual_manifest_one_project() { + let p = project() + .file( + "Cargo.toml", + r#" + [workspace] + members = ["bar", "baz"] + "#, + ) + .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) + .file("bar/src/lib.rs", "pub fn bar() {}") + .file("baz/Cargo.toml", &basic_manifest("baz", "0.1.0")) + .file("baz/src/lib.rs", "pub fn baz() { break_the_build(); }") + .build(); + + p.cargo("doc -p bar") + .with_stderr_does_not_contain("[DOCUMENTING] baz v0.1.0 [..]") + .with_stderr( + "\ +[DOCUMENTING] bar v0.1.0 ([..]) +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +", + ) + .run(); +} + +#[cargo_test] +fn doc_virtual_manifest_glob() { + let p = project() + .file( + "Cargo.toml", + r#" + [workspace] + members = ["bar", "baz"] + "#, + ) + .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) + .file("bar/src/lib.rs", "pub fn bar() { break_the_build(); }") + .file("baz/Cargo.toml", &basic_manifest("baz", "0.1.0")) + .file("baz/src/lib.rs", "pub fn baz() {}") + .build(); + + p.cargo("doc -p '*z'") + .with_stderr_does_not_contain("[DOCUMENTING] bar v0.1.0 [..]") + .with_stderr( + "\ +[DOCUMENTING] baz v0.1.0 ([..]) +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +", + ) + .run(); +} + #[cargo_test] fn doc_all_member_dependency_same_name() { let p = project() diff --git a/tests/testsuite/glob_targets.rs b/tests/testsuite/glob_targets.rs new file mode 100644 index 00000000000..a2dc4fdff49 --- /dev/null +++ b/tests/testsuite/glob_targets.rs @@ -0,0 +1,535 @@ +//! Tests for target filter flags rith glob patterns. + +use cargo_test_support::{project, Project}; + +#[cargo_test] +fn build_example() { + full_project() + .cargo("build -v --example 'ex*1'") + .with_stderr( + "\ +[COMPILING] foo v0.0.1 ([CWD]) +[RUNNING] `rustc --crate-name example1 [..]` +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +", + ) + .run(); +} + +#[cargo_test] +fn build_bin() { + full_project() + .cargo("build -v --bin 'bi*1'") + .with_stderr( + "\ +[COMPILING] foo v0.0.1 ([CWD]) +[RUNNING] `rustc --crate-name bin1 [..]` +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +", + ) + .run(); +} + +#[cargo_test] +fn build_bench() { + full_project() + .cargo("build -v --bench 'be*1'") + .with_stderr_contains("[RUNNING] `rustc --crate-name bench1 [..]`") + .with_stderr_contains("[RUNNING] `rustc --crate-name bin2 [..]`") + .with_stderr_contains("[RUNNING] `rustc --crate-name bin1 [..]`") + .with_stderr_contains("[RUNNING] `rustc --crate-name foo [..]`") + .with_stderr( + "\ +[COMPILING] foo v0.0.1 ([CWD]) +[RUNNING] `rustc --crate-name [..]` +[RUNNING] `rustc --crate-name [..]` +[RUNNING] `rustc --crate-name [..]` +[RUNNING] `rustc --crate-name [..]` +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +", + ) + .run(); +} + +#[cargo_test] +fn build_test() { + full_project() + .cargo("build -v --test 'te*1'") + .with_stderr_contains("[RUNNING] `rustc --crate-name test1 [..]`") + .with_stderr_contains("[RUNNING] `rustc --crate-name bin2 [..]`") + .with_stderr_contains("[RUNNING] `rustc --crate-name bin1 [..]`") + .with_stderr_contains("[RUNNING] `rustc --crate-name foo [..]`") + .with_stderr( + "\ +[COMPILING] foo v0.0.1 ([CWD]) +[RUNNING] `rustc --crate-name [..]` +[RUNNING] `rustc --crate-name [..]` +[RUNNING] `rustc --crate-name [..]` +[RUNNING] `rustc --crate-name [..]` +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +", + ) + .run(); +} + +#[cargo_test] +fn check_example() { + full_project() + .cargo("check -v --example 'ex*1'") + .with_stderr( + "\ +[CHECKING] foo v0.0.1 ([CWD]) +[RUNNING] `rustc --crate-name example1 [..]` +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +", + ) + .run(); +} + +#[cargo_test] +fn check_bin() { + full_project() + .cargo("check -v --bin 'bi*1'") + .with_stderr( + "\ +[CHECKING] foo v0.0.1 ([CWD]) +[RUNNING] `rustc --crate-name bin1 [..]` +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +", + ) + .run(); +} + +#[cargo_test] +fn check_bench() { + full_project() + .cargo("check -v --bench 'be*1'") + .with_stderr( + "\ +[CHECKING] foo v0.0.1 ([CWD]) +[RUNNING] `rustc --crate-name bench1 [..]` +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +", + ) + .run(); +} + +#[cargo_test] +fn check_test() { + full_project() + .cargo("check -v --test 'te*1'") + .with_stderr( + "\ +[CHECKING] foo v0.0.1 ([CWD]) +[RUNNING] `rustc --crate-name test1 [..]` +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +", + ) + .run(); +} + +#[cargo_test] +fn doc_bin() { + full_project() + .cargo("doc -v --bin 'bi*1'") + .with_stderr( + "\ +[DOCUMENTING] foo v0.0.1 ([CWD]) +[RUNNING] `rustdoc --crate-type bin --crate-name bin1 [..]` +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +", + ) + .run(); +} + +#[cargo_test] +fn fix_example() { + full_project() + .cargo("fix -v --example 'ex*1' --allow-no-vcs") + .with_stderr( + "\ +[CHECKING] foo v0.0.1 ([CWD]) +[RUNNING] `[..] rustc --crate-name example1 [..]` +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +", + ) + .run(); +} + +#[cargo_test] +fn fix_bin() { + full_project() + .cargo("fix -v --bin 'bi*1' --allow-no-vcs") + .with_stderr( + "\ +[CHECKING] foo v0.0.1 ([CWD]) +[RUNNING] `[..] rustc --crate-name bin1 [..]` +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +", + ) + .run(); +} + +#[cargo_test] +fn fix_bench() { + full_project() + .cargo("fix -v --bench 'be*1' --allow-no-vcs") + .with_stderr( + "\ +[CHECKING] foo v0.0.1 ([CWD]) +[RUNNING] `[..] rustc --crate-name bench1 [..]` +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +", + ) + .run(); +} + +#[cargo_test] +fn fix_test() { + full_project() + .cargo("fix -v --test 'te*1' --allow-no-vcs") + .with_stderr( + "\ +[CHECKING] foo v0.0.1 ([CWD]) +[RUNNING] `[..] rustc --crate-name test1 [..]` +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +", + ) + .run(); +} + +#[cargo_test] +fn run_example_and_bin() { + let p = full_project(); + p.cargo("run -v --bin 'bi*1'") + .with_status(101) + .with_stderr("[ERROR] `cargo run` does not support glob patterns on target selection") + .run(); + + p.cargo("run -v --example 'ex*1'") + .with_status(101) + .with_stderr("[ERROR] `cargo run` does not support glob patterns on target selection") + .run(); +} + +#[cargo_test] +fn test_example() { + full_project() + .cargo("test -v --example 'ex*1'") + .with_stderr( + "\ +[COMPILING] foo v0.0.1 ([CWD]) +[RUNNING] `rustc --crate-name example1 [..]` +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] +[RUNNING] [..]example1[..] +", + ) + .run(); +} + +#[cargo_test] +fn test_bin() { + full_project() + .cargo("test -v --bin 'bi*1'") + .with_stderr( + "\ +[COMPILING] foo v0.0.1 ([CWD]) +[RUNNING] `rustc --crate-name bin1 [..]` +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] +[RUNNING] [..]bin1[..] +", + ) + .run(); +} + +#[cargo_test] +fn test_bench() { + full_project() + .cargo("test -v --bench 'be*1'") + .with_stderr_contains("[RUNNING] `rustc --crate-name bench1 [..]`") + .with_stderr_contains("[RUNNING] `rustc --crate-name bin2 [..]`") + .with_stderr_contains("[RUNNING] `rustc --crate-name bin1 [..]`") + .with_stderr_contains("[RUNNING] `rustc --crate-name foo [..]`") + .with_stderr( + "\ +[COMPILING] foo v0.0.1 ([CWD]) +[RUNNING] `rustc --crate-name [..]` +[RUNNING] `rustc --crate-name [..]` +[RUNNING] `rustc --crate-name [..]` +[RUNNING] `rustc --crate-name [..]` +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] +[RUNNING] [..]bench1[..] +", + ) + .run(); +} + +#[cargo_test] +fn test_test() { + full_project() + .cargo("test -v --test 'te*1'") + .with_stderr_contains("[RUNNING] `rustc --crate-name test1 [..]`") + .with_stderr_contains("[RUNNING] `rustc --crate-name bin2 [..]`") + .with_stderr_contains("[RUNNING] `rustc --crate-name bin1 [..]`") + .with_stderr_contains("[RUNNING] `rustc --crate-name foo [..]`") + .with_stderr( + "\ +[COMPILING] foo v0.0.1 ([CWD]) +[RUNNING] `rustc --crate-name [..]` +[RUNNING] `rustc --crate-name [..]` +[RUNNING] `rustc --crate-name [..]` +[RUNNING] `rustc --crate-name [..]` +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] +[RUNNING] [..]test1[..] +", + ) + .run(); +} + +#[cargo_test] +fn bench_example() { + full_project() + .cargo("bench -v --example 'ex*1'") + .with_stderr( + "\ +[COMPILING] foo v0.0.1 ([CWD]) +[RUNNING] `rustc --crate-name example1 [..]` +[FINISHED] bench [optimized] target(s) in [..] +[RUNNING] `[..]example1[..] --bench` +", + ) + .run(); +} + +#[cargo_test] +fn bench_bin() { + full_project() + .cargo("bench -v --bin 'bi*1'") + .with_stderr( + "\ +[COMPILING] foo v0.0.1 ([CWD]) +[RUNNING] `rustc --crate-name bin1 [..]` +[FINISHED] bench [optimized] target(s) in [..] +[RUNNING] `[..]bin1[..] --bench` +", + ) + .run(); +} + +#[cargo_test] +fn bench_bench() { + full_project() + .cargo("bench -v --bench 'be*1'") + .with_stderr_contains("[RUNNING] `rustc --crate-name bench1 [..]`") + .with_stderr_contains("[RUNNING] `rustc --crate-name bin2 [..]`") + .with_stderr_contains("[RUNNING] `rustc --crate-name bin1 [..]`") + .with_stderr_contains("[RUNNING] `rustc --crate-name foo [..]`") + .with_stderr( + "\ +[COMPILING] foo v0.0.1 ([CWD]) +[RUNNING] `rustc --crate-name [..]` +[RUNNING] `rustc --crate-name [..]` +[RUNNING] `rustc --crate-name [..]` +[RUNNING] `rustc --crate-name [..]` +[FINISHED] bench [optimized] target(s) in [..] +[RUNNING] `[..]bench1[..] --bench` +", + ) + .run(); +} + +#[cargo_test] +fn bench_test() { + full_project() + .cargo("bench -v --test 'te*1'") + .with_stderr_contains("[RUNNING] `rustc --crate-name test1 [..]`") + .with_stderr_contains("[RUNNING] `rustc --crate-name bin2 [..]`") + .with_stderr_contains("[RUNNING] `rustc --crate-name bin1 [..]`") + .with_stderr_contains("[RUNNING] `rustc --crate-name foo [..]`") + .with_stderr( + "\ +[COMPILING] foo v0.0.1 ([CWD]) +[RUNNING] `rustc --crate-name [..]` +[RUNNING] `rustc --crate-name [..]` +[RUNNING] `rustc --crate-name [..]` +[RUNNING] `rustc --crate-name [..]` +[FINISHED] bench [optimized] target(s) in [..] +[RUNNING] `[..]test1[..] --bench` +", + ) + .run(); +} + +#[cargo_test] +fn install_example() { + full_project() + .cargo("install --path . --example 'ex*1'") + .with_stderr( + "\ +[INSTALLING] foo v0.0.1 ([CWD]) +[COMPILING] foo v0.0.1 ([CWD]) +[FINISHED] release [optimized] target(s) in [..] +[INSTALLING] [..]/home/.cargo/bin/example1[EXE] +[INSTALLED] package `foo v0.0.1 ([CWD])` (executable `example1[EXE]`) +[WARNING] be sure to add [..] +", + ) + .run(); +} + +#[cargo_test] +fn install_bin() { + full_project() + .cargo("install --path . --bin 'bi*1'") + .with_stderr( + "\ +[INSTALLING] foo v0.0.1 ([CWD]) +[COMPILING] foo v0.0.1 ([CWD]) +[FINISHED] release [optimized] target(s) in [..] +[INSTALLING] [..]/home/.cargo/bin/bin1[EXE] +[INSTALLED] package `foo v0.0.1 ([CWD])` (executable `bin1[EXE]`) +[WARNING] be sure to add [..] +", + ) + .run(); +} + +#[cargo_test] +fn rustdoc_example() { + full_project() + .cargo("rustdoc -v --example 'ex*1'") + .with_stderr( + "\ +[DOCUMENTING] foo v0.0.1 ([CWD]) +[RUNNING] `rustdoc --crate-type bin --crate-name example1 [..]` +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +", + ) + .run(); +} + +#[cargo_test] +fn rustdoc_bin() { + full_project() + .cargo("rustdoc -v --bin 'bi*1'") + .with_stderr( + "\ +[DOCUMENTING] foo v0.0.1 ([CWD]) +[RUNNING] `rustdoc --crate-type bin --crate-name bin1 [..]` +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +", + ) + .run(); +} + +#[cargo_test] +fn rustdoc_bench() { + full_project() + .cargo("rustdoc -v --bench 'be*1'") + .with_stderr( + "\ +[DOCUMENTING] foo v0.0.1 ([CWD]) +[RUNNING] `rustdoc --crate-type bin --crate-name bench1 [..]` +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +", + ) + .run(); +} + +#[cargo_test] +fn rustdoc_test() { + full_project() + .cargo("rustdoc -v --test 'te*1'") + .with_stderr( + "\ +[DOCUMENTING] foo v0.0.1 ([CWD]) +[RUNNING] `rustdoc --crate-type bin --crate-name test1 [..]` +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +", + ) + .run(); +} + +#[cargo_test] +fn rustc_example() { + full_project() + .cargo("rustc -v --example 'ex*1'") + .with_stderr( + "\ +[COMPILING] foo v0.0.1 ([CWD]) +[RUNNING] `rustc --crate-name example1 [..]` +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +", + ) + .run(); +} + +#[cargo_test] +fn rustc_bin() { + full_project() + .cargo("rustc -v --bin 'bi*1'") + .with_stderr( + "\ +[COMPILING] foo v0.0.1 ([CWD]) +[RUNNING] `rustc --crate-name bin1 [..]` +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +", + ) + .run(); +} + +#[cargo_test] +fn rustc_bench() { + full_project() + .cargo("rustc -v --bench 'be*1'") + .with_stderr_contains("[RUNNING] `rustc --crate-name bench1 [..]`") + .with_stderr_contains("[RUNNING] `rustc --crate-name bin2 [..]`") + .with_stderr_contains("[RUNNING] `rustc --crate-name bin1 [..]`") + .with_stderr_contains("[RUNNING] `rustc --crate-name foo [..]`") + .with_stderr( + "\ +[COMPILING] foo v0.0.1 ([CWD]) +[RUNNING] `rustc --crate-name [..]` +[RUNNING] `rustc --crate-name [..]` +[RUNNING] `rustc --crate-name [..]` +[RUNNING] `rustc --crate-name [..]` +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +", + ) + .run(); +} + +#[cargo_test] +fn rustc_test() { + full_project() + .cargo("rustc -v --test 'te*1'") + .with_stderr_contains("[RUNNING] `rustc --crate-name test1 [..]`") + .with_stderr_contains("[RUNNING] `rustc --crate-name bin2 [..]`") + .with_stderr_contains("[RUNNING] `rustc --crate-name bin1 [..]`") + .with_stderr_contains("[RUNNING] `rustc --crate-name foo [..]`") + .with_stderr( + "\ +[COMPILING] foo v0.0.1 ([CWD]) +[RUNNING] `rustc --crate-name [..]` +[RUNNING] `rustc --crate-name [..]` +[RUNNING] `rustc --crate-name [..]` +[RUNNING] `rustc --crate-name [..]` +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +", + ) + .run(); +} + +fn full_project() -> Project { + project() + .file("examples/example1.rs", "fn main() { }") + .file("examples/example2.rs", "fn main() { }") + .file("benches/bench1.rs", "") + .file("benches/bench2.rs", "") + .file("tests/test1.rs", "") + .file("tests/test2.rs", "") + .file("src/main.rs", "fn main() { }") + .file("src/bin/bin1.rs", "fn main() { }") + .file("src/bin/bin2.rs", "fn main() { }") + .build() +} diff --git a/tests/testsuite/main.rs b/tests/testsuite/main.rs index 3ff15f404ba..2b1767d41e9 100644 --- a/tests/testsuite/main.rs +++ b/tests/testsuite/main.rs @@ -52,6 +52,7 @@ mod generate_lockfile; mod git; mod git_auth; mod git_gc; +mod glob_targets; mod help; mod init; mod install; diff --git a/tests/testsuite/run.rs b/tests/testsuite/run.rs index cf8db2dfc78..9d52afaf7b0 100644 --- a/tests/testsuite/run.rs +++ b/tests/testsuite/run.rs @@ -996,7 +996,16 @@ fn run_multiple_packages() { .arg("-p") .arg("d3") .with_status(101) - .with_stderr_contains("[ERROR] package `d3` is not a member of the workspace") + .with_stderr_contains("[ERROR] package(s) `d3` not found in workspace [..]") + .run(); + + cargo() + .arg("-p") + .arg("d*") + .with_status(101) + .with_stderr_contains( + "[ERROR] `cargo run` does not support glob pattern `d*` on package selection", + ) .run(); } diff --git a/tests/testsuite/rustc.rs b/tests/testsuite/rustc.rs index 6708f4a308f..48f6859f02d 100644 --- a/tests/testsuite/rustc.rs +++ b/tests/testsuite/rustc.rs @@ -325,6 +325,26 @@ error: The argument '--package ' was provided more than once, \ .run(); } +#[cargo_test] +fn fail_with_glob() { + let p = project() + .file( + "Cargo.toml", + r#" + [workspace] + members = ["bar"] + "#, + ) + .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) + .file("bar/src/lib.rs", "pub fn bar() { break_the_build(); }") + .build(); + + p.cargo("rustc -p '*z'") + .with_status(101) + .with_stderr("[ERROR] Glob patterns on package selection are not supported.") + .run(); +} + #[cargo_test] fn rustc_with_other_profile() { let p = project() diff --git a/tests/testsuite/rustdoc.rs b/tests/testsuite/rustdoc.rs index daee90fe581..3d27739ef92 100644 --- a/tests/testsuite/rustdoc.rs +++ b/tests/testsuite/rustdoc.rs @@ -226,3 +226,23 @@ fn rustdoc_target() { )) .run(); } + +#[cargo_test] +fn fail_with_glob() { + let p = project() + .file( + "Cargo.toml", + r#" + [workspace] + members = ["bar"] + "#, + ) + .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) + .file("bar/src/lib.rs", "pub fn bar() { break_the_build(); }") + .build(); + + p.cargo("rustdoc -p '*z'") + .with_status(101) + .with_stderr("[ERROR] Glob patterns on package selection are not supported.") + .run(); +} diff --git a/tests/testsuite/test.rs b/tests/testsuite/test.rs index 6093d7d88db..4ba9a4db833 100644 --- a/tests/testsuite/test.rs +++ b/tests/testsuite/test.rs @@ -2833,6 +2833,103 @@ test bar ... ok", .run(); } +#[cargo_test] +fn test_all_exclude_not_found() { + let p = project() + .file( + "Cargo.toml", + r#" + [project] + name = "foo" + version = "0.1.0" + + [workspace] + members = ["bar"] + "#, + ) + .file("src/main.rs", "fn main() {}") + .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) + .file("bar/src/lib.rs", "#[test] pub fn bar() {}") + .build(); + + p.cargo("test --workspace --exclude baz") + .with_stderr_contains("[WARNING] excluded package(s) `baz` not found in workspace [..]") + .with_stdout_contains( + "running 1 test +test bar ... ok", + ) + .run(); +} + +#[cargo_test] +fn test_all_exclude_glob() { + let p = project() + .file( + "Cargo.toml", + r#" + [project] + name = "foo" + version = "0.1.0" + + [workspace] + members = ["bar", "baz"] + "#, + ) + .file("src/main.rs", "fn main() {}") + .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) + .file("bar/src/lib.rs", "#[test] pub fn bar() {}") + .file("baz/Cargo.toml", &basic_manifest("baz", "0.1.0")) + .file("baz/src/lib.rs", "#[test] pub fn baz() { assert!(false); }") + .build(); + + p.cargo("test --workspace --exclude '*z'") + .with_stdout_contains( + "running 1 test +test bar ... ok", + ) + .run(); +} + +#[cargo_test] +fn test_all_exclude_glob_not_found() { + let p = project() + .file( + "Cargo.toml", + r#" + [project] + name = "foo" + version = "0.1.0" + + [workspace] + members = ["bar"] + "#, + ) + .file("src/main.rs", "fn main() {}") + .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) + .file("bar/src/lib.rs", "#[test] pub fn bar() {}") + .build(); + + p.cargo("test --workspace --exclude '*z'") + .with_stderr_contains( + "[WARNING] excluded package pattern(s) `*z` not found in workspace [..]", + ) + .with_stdout_contains( + "running 1 test +test bar ... ok", + ) + .run(); +} + +#[cargo_test] +fn test_all_exclude_broken_glob() { + let p = project().file("src/main.rs", "fn main() {}").build(); + + p.cargo("test --workspace --exclude '[*z'") + .with_status(101) + .with_stderr_contains("[ERROR] cannot build glob pattern from `[*z`") + .run(); +} + #[cargo_test] fn test_all_virtual_manifest() { let p = project() @@ -2850,8 +2947,8 @@ fn test_all_virtual_manifest() { .build(); p.cargo("test --workspace") - .with_stdout_contains("test a ... ok") - .with_stdout_contains("test b ... ok") + .with_stdout_contains("running 1 test\ntest a ... ok") + .with_stdout_contains("running 1 test\ntest b ... ok") .run(); } @@ -2872,8 +2969,92 @@ fn test_virtual_manifest_all_implied() { .build(); p.cargo("test") - .with_stdout_contains("test a ... ok") - .with_stdout_contains("test b ... ok") + .with_stdout_contains("running 1 test\ntest a ... ok") + .with_stdout_contains("running 1 test\ntest b ... ok") + .run(); +} + +#[cargo_test] +fn test_virtual_manifest_one_project() { + let p = project() + .file( + "Cargo.toml", + r#" + [workspace] + members = ["bar", "baz"] + "#, + ) + .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) + .file("bar/src/lib.rs", "#[test] fn bar() {}") + .file("baz/Cargo.toml", &basic_manifest("baz", "0.1.0")) + .file("baz/src/lib.rs", "#[test] fn baz() { assert!(false); }") + .build(); + + p.cargo("test -p bar") + .with_stdout_contains("running 1 test\ntest bar ... ok") + .with_stdout_does_not_contain("running 1 test\ntest baz ... ok") + .run(); +} + +#[cargo_test] +fn test_virtual_manifest_glob() { + let p = project() + .file( + "Cargo.toml", + r#" + [workspace] + members = ["bar", "baz"] + "#, + ) + .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) + .file("bar/src/lib.rs", "#[test] fn bar() { assert!(false); }") + .file("baz/Cargo.toml", &basic_manifest("baz", "0.1.0")) + .file("baz/src/lib.rs", "#[test] fn baz() {}") + .build(); + + p.cargo("test -p '*z'") + .with_stdout_does_not_contain("running 1 test\ntest bar ... ok") + .with_stdout_contains("running 1 test\ntest baz ... ok") + .run(); +} + +#[cargo_test] +fn test_virtual_manifest_glob_not_found() { + let p = project() + .file( + "Cargo.toml", + r#" + [workspace] + members = ["bar"] + "#, + ) + .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) + .file("bar/src/lib.rs", "#[test] fn bar() {}") + .build(); + + p.cargo("test -p bar -p '*z'") + .with_status(101) + .with_stderr("[ERROR] package pattern(s) `*z` not found in workspace [..]") + .run(); +} + +#[cargo_test] +fn test_virtual_manifest_broken_glob() { + let p = project() + .file( + "Cargo.toml", + r#" + [workspace] + members = ["bar"] + "#, + ) + .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) + .file("bar/src/lib.rs", "#[test] fn bar() {}") + .build(); + + p.cargo("test -p '[*z'") + .with_status(101) + .with_stderr_contains("[ERROR] cannot build glob pattern from `[*z`") .run(); } diff --git a/tests/testsuite/tree.rs b/tests/testsuite/tree.rs index f88194256b1..8a9cab4e0ae 100644 --- a/tests/testsuite/tree.rs +++ b/tests/testsuite/tree.rs @@ -78,16 +78,16 @@ fn virtual_workspace() { "Cargo.toml", r#" [workspace] - members = ["a", "b", "c"] + members = ["a", "baz", "c"] "#, ) .file("a/Cargo.toml", &basic_manifest("a", "1.0.0")) .file("a/src/lib.rs", "") .file( - "b/Cargo.toml", + "baz/Cargo.toml", r#" [package] - name = "b" + name = "baz" version = "0.1.0" [dependencies] @@ -95,7 +95,7 @@ fn virtual_workspace() { somedep = "1.0" "#, ) - .file("b/src/lib.rs", "") + .file("baz/src/lib.rs", "") .file("c/Cargo.toml", &basic_manifest("c", "1.0.0")) .file("c/src/lib.rs", "") .build(); @@ -105,7 +105,7 @@ fn virtual_workspace() { "\ a v1.0.0 ([..]/foo/a) -b v0.1.0 ([..]/foo/b) +baz v0.1.0 ([..]/foo/baz) ├── c v1.0.0 ([..]/foo/c) └── somedep v1.0.0 @@ -117,10 +117,43 @@ c v1.0.0 ([..]/foo/c) p.cargo("tree -p a").with_stdout("a v1.0.0 [..]").run(); p.cargo("tree") - .cwd("b") + .cwd("baz") .with_stdout( "\ -b v0.1.0 ([..]/foo/b) +baz v0.1.0 ([..]/foo/baz) +├── c v1.0.0 ([..]/foo/c) +└── somedep v1.0.0 +", + ) + .run(); + + // exclude baz + p.cargo("tree --workspace --exclude baz") + .with_stdout( + "\ +a v1.0.0 ([..]/foo/a) + +c v1.0.0 ([..]/foo/c) +", + ) + .run(); + + // exclude glob '*z' + p.cargo("tree --workspace --exclude '*z'") + .with_stdout( + "\ +a v1.0.0 ([..]/foo/a) + +c v1.0.0 ([..]/foo/c) +", + ) + .run(); + + // include glob '*z' + p.cargo("tree -p '*z'") + .with_stdout( + "\ +baz v0.1.0 ([..]/foo/baz) ├── c v1.0.0 ([..]/foo/c) └── somedep v1.0.0 ",