From be31989a43ecee8904a8ff1448580695b13d1645 Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Sun, 4 Oct 2020 22:55:50 +0800 Subject: [PATCH 01/21] test: minimal shell quote supoort for cargo-test-support --- crates/cargo-test-support/src/lib.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/crates/cargo-test-support/src/lib.rs b/crates/cargo-test-support/src/lib.rs index d53ecbc24f4..28265e1de5b 100644 --- a/crates/cargo-test-support/src/lib.rs +++ b/crates/cargo-test-support/src/lib.rs @@ -1637,8 +1637,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); From 42696ae234dfb7b23c9638ad118373826c784c60 Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Sun, 4 Oct 2020 23:22:54 +0800 Subject: [PATCH 02/21] feat: glob support for target selection --- src/cargo/ops/cargo_compile.rs | 48 ++++++++++++++++++++++++++++-- src/cargo/ops/cargo_run.rs | 4 +++ src/cargo/util/restricted_names.rs | 7 ++++- 3 files changed, 55 insertions(+), 4 deletions(-) diff --git a/src/cargo/ops/cargo_compile.rs b/src/cargo/ops/cargo_compile.rs index 8056c708918..022f0810040 100644 --- a/src/cargo/ops/cargo_compile.rs +++ b/src/cargo/ops/cargo_compile.rs @@ -41,8 +41,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`: @@ -577,6 +580,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 +716,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 +1191,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 +1209,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 +1328,8 @@ fn traverse_and_share( new_graph.entry(new_unit.clone()).or_insert(new_deps); new_unit } + +/// TODO: @weihanglo +fn build_glob(pat: &str) -> CargoResult { + glob::Pattern::new(pat).with_context(|| format!("Cannot build glob pattern from `{}`", pat)) +} 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/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(&['*', '?', '[', ']'][..]) +} From 633e5f004889f46055b563a1f45854410222c8c2 Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Sun, 4 Oct 2020 23:25:53 +0800 Subject: [PATCH 03/21] test: glob support for target selection --- tests/testsuite/build.rs | 10 + tests/testsuite/glob_targets.rs | 535 ++++++++++++++++++++++++++++++++ tests/testsuite/main.rs | 1 + 3 files changed, 546 insertions(+) create mode 100644 tests/testsuite/glob_targets.rs diff --git a/tests/testsuite/build.rs b/tests/testsuite/build.rs index ac556520ab8..bf2429925d0 100644 --- a/tests/testsuite/build.rs +++ b/tests/testsuite/build.rs @@ -4579,6 +4579,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/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; From 2361fb0f6a8759bab9a6b241e2ef7f75ef98688a Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Sun, 4 Oct 2020 23:27:01 +0800 Subject: [PATCH 04/21] feat: glob support for package selection --- src/bin/cargo/commands/run.rs | 17 ++- src/cargo/ops/cargo_compile.rs | 174 +++++++++++++++++++++++------- src/cargo/util/command_prelude.rs | 7 +- 3 files changed, 158 insertions(+), 40 deletions(-) diff --git a/src/bin/cargo/commands/run.rs b/src/bin/cargo/commands/run.rs index d16bfd31f3c..71e55e33777 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,20 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult { ProfileChecking::Checked, )?; + // Disallow `spec` to be an glob pattern + match &compile_opts.spec { + Packages::Packages(opt_in) => { + 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 022f0810040..a2c37daf843 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; @@ -119,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 @@ -127,33 +127,41 @@ 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) + .or_else(|e| ws.config().shell().warn(e))?; + specs + } Packages::Default => ws .default_members() .map(Package::package_id) @@ -173,27 +181,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) } @@ -1329,7 +1345,89 @@ fn traverse_and_share( new_unit } -/// TODO: @weihanglo +/// 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 + .iter() + .map(|x| x.as_ref()) + .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/util/command_prelude.rs b/src/cargo/util/command_prelude.rs index 26c5ddada4d..a4437d8a727 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, @@ -509,7 +510,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) } From ab88c48480e41794b4ee3b6ec465aba4eff5991f Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Sun, 4 Oct 2020 23:27:45 +0800 Subject: [PATCH 05/21] test(tree): glob support for package selection --- tests/testsuite/tree.rs | 47 +++++++++++++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 7 deletions(-) diff --git a/tests/testsuite/tree.rs b/tests/testsuite/tree.rs index 9d3ded9888c..e1ada1e205c 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 ", From db313e54a2d7e719b609826ff2b090e761453c9d Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Sun, 4 Oct 2020 23:28:01 +0800 Subject: [PATCH 06/21] test(rustc): glob support for package selection --- tests/testsuite/rustc.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/testsuite/rustc.rs b/tests/testsuite/rustc.rs index 6708f4a308f..a1c00a096e2 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() From 570aea75ead37d58908d906cb5afa21e186944db Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Sun, 4 Oct 2020 23:28:22 +0800 Subject: [PATCH 07/21] test(rustdoc): glob support for package selection --- tests/testsuite/rustdoc.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/testsuite/rustdoc.rs b/tests/testsuite/rustdoc.rs index daee90fe581..a920d855aed 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(); +} From f1de239450f1829dbf86eb9e9f71c5dc0cbeb3ce Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Sun, 4 Oct 2020 23:28:48 +0800 Subject: [PATCH 08/21] test(doc): glob support for package selection --- tests/testsuite/doc.rs | 108 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) diff --git a/tests/testsuite/doc.rs b/tests/testsuite/doc.rs index df8f1967b8e..0d05da78eef 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() From a06ec889f4ce2d12bbb52d50a13653afa5f35ab2 Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Sun, 4 Oct 2020 23:29:11 +0800 Subject: [PATCH 09/21] test(bench): glob support for package selection --- tests/testsuite/bench.rs | 102 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) diff --git a/tests/testsuite/bench.rs b/tests/testsuite/bench.rs index 30661521782..ae5a471acaa 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() { From 33d883c425644392c8d3214311558a1d71714dbb Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Sun, 4 Oct 2020 23:30:33 +0800 Subject: [PATCH 10/21] test(run): glob support for package selection --- tests/testsuite/run.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/testsuite/run.rs b/tests/testsuite/run.rs index cf8db2dfc78..9ba0127c0f2 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(); } From 667a5aedfba3e7eca76cc70cc04b3c446e218f90 Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Sun, 4 Oct 2020 23:30:44 +0800 Subject: [PATCH 11/21] test(build): glob support for package selection --- tests/testsuite/build.rs | 213 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 203 insertions(+), 10 deletions(-) diff --git a/tests/testsuite/build.rs b/tests/testsuite/build.rs index bf2429925d0..8985bedbe8c 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,127 @@ 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_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( + "\ +[COMPILING] [..] v0.1.0 ([..]) +[COMPILING] [..] 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_contains("[COMPILING] foo v0.1.0 [..]") + .with_stderr_contains("[COMPILING] bar v0.1.0 [..]") + .with_stderr( + "\ +[WARNING] excluded package(s) baz 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_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_contains("[COMPILING] foo v0.1.0 [..]") + .with_stderr_contains("[COMPILING] bar v0.1.0 [..]") + .with_stderr( + "\ +[COMPILING] [..] v0.1.0 ([..]) +[COMPILING] [..] 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(); } @@ -3600,16 +3720,89 @@ 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_stderr( + "\ +[WARNING] package pattern(s) *z not found in workspace [..] +[COMPILING] bar v0.1.0 ([..]) +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +", + ) + .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(); } From 8d5e11a52078b62306cca7dd608e484d0a679d7d Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Sun, 4 Oct 2020 23:31:09 +0800 Subject: [PATCH 12/21] test(check): glob support for package selection --- tests/testsuite/check.rs | 108 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) diff --git a/tests/testsuite/check.rs b/tests/testsuite/check.rs index 1c10aa5d8bd..b385e3b0663 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(); From 6fb6b94a33a0152d3b77d6033ac3b666dff272dd Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Sun, 4 Oct 2020 23:31:22 +0800 Subject: [PATCH 13/21] test(test): glob support for package selection --- tests/testsuite/test.rs | 190 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 186 insertions(+), 4 deletions(-) diff --git a/tests/testsuite/test.rs b/tests/testsuite/test.rs index 6093d7d88db..f151f32f357 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,93 @@ 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_stderr_contains("[WARNING] package pattern(s) *z not found in workspace [..]") + .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_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(); } From b3441f9b9154d6beb101349ff4faafc479a1b10a Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Sun, 4 Oct 2020 23:38:00 +0800 Subject: [PATCH 14/21] doc: glob pattern support for package/target selection --- src/doc/man/includes/options-targets-lib-bin.md | 3 ++- src/doc/man/includes/options-targets.md | 15 +++++++++++---- src/doc/man/includes/section-package-selection.md | 10 ++++++++-- 3 files changed, 21 insertions(+), 7 deletions(-) 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}} From 4a61d8a41266f3a6366c666d86d09ebfcc789770 Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Sun, 4 Oct 2020 23:38:47 +0800 Subject: [PATCH 15/21] doc: build-man.sh for glob pattern support --- src/doc/man/generated_txt/cargo-bench.txt | 25 +++++++++++++----- src/doc/man/generated_txt/cargo-build.txt | 25 +++++++++++++----- src/doc/man/generated_txt/cargo-check.txt | 25 +++++++++++++----- src/doc/man/generated_txt/cargo-doc.txt | 14 ++++++++--- src/doc/man/generated_txt/cargo-fix.txt | 28 +++++++++++++++------ src/doc/man/generated_txt/cargo-rustc.txt | 13 +++++++--- src/doc/man/generated_txt/cargo-rustdoc.txt | 13 +++++++--- src/doc/man/generated_txt/cargo-test.txt | 27 ++++++++++++++------ src/doc/man/generated_txt/cargo-tree.txt | 12 +++++++-- src/doc/src/commands/cargo-bench.md | 28 +++++++++++++++------ src/doc/src/commands/cargo-build.md | 28 +++++++++++++++------ src/doc/src/commands/cargo-check.md | 28 +++++++++++++++------ src/doc/src/commands/cargo-doc.md | 13 +++++++--- src/doc/src/commands/cargo-fix.md | 28 +++++++++++++++------ src/doc/src/commands/cargo-rustc.md | 18 +++++++++---- src/doc/src/commands/cargo-rustdoc.md | 18 +++++++++---- src/doc/src/commands/cargo-test.md | 28 +++++++++++++++------ src/doc/src/commands/cargo-tree.md | 10 ++++++-- src/etc/man/cargo-bench.1 | 28 +++++++++++++++------ src/etc/man/cargo-build.1 | 28 +++++++++++++++------ src/etc/man/cargo-check.1 | 28 +++++++++++++++------ src/etc/man/cargo-doc.1 | 13 +++++++--- src/etc/man/cargo-fix.1 | 28 +++++++++++++++------ src/etc/man/cargo-metadata.1 | 12 ++++----- src/etc/man/cargo-rustc.1 | 18 +++++++++---- src/etc/man/cargo-rustdoc.1 | 18 +++++++++---- src/etc/man/cargo-test.1 | 28 +++++++++++++++------ src/etc/man/cargo-tree.1 | 10 ++++++-- 28 files changed, 441 insertions(+), 151 deletions(-) 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/src/commands/cargo-bench.md b/src/doc/src/commands/cargo-bench.md index c4f7daabbbf..6c6bb134fed 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 0d945ee93e8..cda1109ce12 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 a75679ce4dd..1f36f9fb272 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 5c9e390965b..4b572a0c696 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 37a08cf7457..fa9fb673b2e 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 445824dc539..298fed3670d 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 878fac81379..44c5dfde249 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 739c7b6be29..f42d8c519f2 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 af13f9fbdbd..b5ef1de03e8 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-metadata.1 b/src/etc/man/cargo-metadata.1 index 9ff85e8160e..732236bc56c 100644 --- a/src/etc/man/cargo-metadata.1 +++ b/src/etc/man/cargo-metadata.1 @@ -180,9 +180,9 @@ The output has the following format: /* The repository value from the manifest or null if not specified. */ "repository": "https://github.com/rust\-lang/cargo", /* The homepage value from the manifest or null if not specified. */ - "homepage": "https://rust-lang.org", + "homepage": "https://rust\-lang.org", /* The documentation value from the manifest or null if not specified. */ - "documentation": "https://doc.rust-lang.org/stable/std", + "documentation": "https://doc.rust\-lang.org/stable/std", /* The default edition of the package. Note that individual targets may have different editions. */ @@ -333,7 +333,7 @@ Do not activate the \fBdefault\fR feature of the current directory's package. .RE .SS "Display Options" .sp -\fB\-v\fR, +\fB\-v\fR, \fB\-\-verbose\fR .RS 4 Use verbose output. May be specified twice for "very verbose" output which @@ -342,7 +342,7 @@ May also be specified with the \fBterm.verbose\fR \fIconfig value\fR \&. .RE .sp -\fB\-q\fR, +\fB\-q\fR, \fB\-\-quiet\fR .RS 4 No output printed to stdout. @@ -376,7 +376,7 @@ Path to the \fBCargo.toml\fR file. By default, Cargo searches for the \fBCargo.toml\fR file in the current directory or any parent directory. .RE .sp -\fB\-\-frozen\fR, +\fB\-\-frozen\fR, \fB\-\-locked\fR .RS 4 Either of these flags requires that the \fBCargo.lock\fR file is @@ -415,7 +415,7 @@ See the \fIrustup documentation\fR Date: Sat, 10 Oct 2020 06:58:06 +0800 Subject: [PATCH 16/21] test: be consistent on error message styles --- src/cargo/ops/cargo_compile.rs | 9 ++++----- tests/testsuite/build.rs | 10 +++++----- tests/testsuite/check.rs | 2 +- tests/testsuite/run.rs | 2 +- tests/testsuite/test.rs | 10 +++++----- 5 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/cargo/ops/cargo_compile.rs b/src/cargo/ops/cargo_compile.rs index a2c37daf843..7470caaf36f 100644 --- a/src/cargo/ops/cargo_compile.rs +++ b/src/cargo/ops/cargo_compile.rs @@ -1347,7 +1347,7 @@ fn traverse_and_share( /// 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)) + glob::Pattern::new(pat).with_context(|| format!("cannot build glob pattern from `{}`", pat)) } /// Emits "package not found" error. @@ -1361,11 +1361,10 @@ fn emit_package_not_found( ) -> CargoResult<()> { if !opt_names.is_empty() { anyhow::bail!( - "{}package(s) {} not found in workspace `{}`", + "{}package(s) `{}` not found in workspace `{}`", if opt_out { "excluded " } else { "" }, opt_names - .iter() - .map(|x| x.as_ref()) + .into_iter() .collect::>() .join(", "), ws.root().display(), @@ -1390,7 +1389,7 @@ fn emit_pattern_not_found( .collect::>(); if !not_matched.is_empty() { anyhow::bail!( - "{}package pattern(s) {} not found in workspace `{}`", + "{}package pattern(s) `{}` not found in workspace `{}`", if opt_out { "excluded " } else { "" }, not_matched.join(", "), ws.root().display(), diff --git a/tests/testsuite/build.rs b/tests/testsuite/build.rs index 8985bedbe8c..e31d13fc417 100644 --- a/tests/testsuite/build.rs +++ b/tests/testsuite/build.rs @@ -3519,7 +3519,7 @@ fn build_all_exclude_not_found() { .with_stderr_contains("[COMPILING] bar v0.1.0 [..]") .with_stderr( "\ -[WARNING] excluded package(s) baz not found in workspace [..] +[WARNING] excluded package(s) `baz` not found in workspace [..] [COMPILING] [..] v0.1.0 ([..]) [COMPILING] [..] v0.1.0 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] @@ -3586,7 +3586,7 @@ fn build_all_exclude_glob_not_found() { .with_stderr_does_not_contain("[COMPILING] baz v0.1.0 [..]") .with_stderr( "\ -[WARNING] excluded package pattern(s) *z not found in workspace [..] +[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 [..] @@ -3601,7 +3601,7 @@ fn build_all_exclude_broken_glob() { p.cargo("build --workspace --exclude '[*z'") .with_status(101) - .with_stderr_contains("[ERROR] Cannot build glob pattern from `[*z`") + .with_stderr_contains("[ERROR] cannot build glob pattern from `[*z`") .run(); } @@ -3778,7 +3778,7 @@ fn build_virtual_manifest_glob_not_found() { p.cargo("build -p bar -p '*z'") .with_stderr( "\ -[WARNING] package pattern(s) *z not found in workspace [..] +[WARNING] package pattern(s) `*z` not found in workspace [..] [COMPILING] bar v0.1.0 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", @@ -3802,7 +3802,7 @@ fn build_virtual_manifest_broken_glob() { p.cargo("build -p '[*z'") .with_status(101) - .with_stderr_contains("[ERROR] Cannot build glob pattern from `[*z`") + .with_stderr_contains("[ERROR] cannot build glob pattern from `[*z`") .run(); } diff --git a/tests/testsuite/check.rs b/tests/testsuite/check.rs index b385e3b0663..0f91461a11f 100644 --- a/tests/testsuite/check.rs +++ b/tests/testsuite/check.rs @@ -551,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/run.rs b/tests/testsuite/run.rs index 9ba0127c0f2..9d52afaf7b0 100644 --- a/tests/testsuite/run.rs +++ b/tests/testsuite/run.rs @@ -996,7 +996,7 @@ fn run_multiple_packages() { .arg("-p") .arg("d3") .with_status(101) - .with_stderr_contains("[ERROR] package(s) d3 not found in workspace [..]") + .with_stderr_contains("[ERROR] package(s) `d3` not found in workspace [..]") .run(); cargo() diff --git a/tests/testsuite/test.rs b/tests/testsuite/test.rs index f151f32f357..1e3ede7f755 100644 --- a/tests/testsuite/test.rs +++ b/tests/testsuite/test.rs @@ -2853,7 +2853,7 @@ fn test_all_exclude_not_found() { .build(); p.cargo("test --workspace --exclude baz") - .with_stderr_contains("[WARNING] excluded package(s) baz not found in workspace [..]") + .with_stderr_contains("[WARNING] excluded package(s) `baz` not found in workspace [..]") .with_stdout_contains( "running 1 test test bar ... ok", @@ -2911,7 +2911,7 @@ fn test_all_exclude_glob_not_found() { p.cargo("test --workspace --exclude '*z'") .with_stderr_contains( - "[WARNING] excluded package pattern(s) *z not found in workspace [..]", + "[WARNING] excluded package pattern(s) `*z` not found in workspace [..]", ) .with_stdout_contains( "running 1 test @@ -2926,7 +2926,7 @@ fn test_all_exclude_broken_glob() { p.cargo("test --workspace --exclude '[*z'") .with_status(101) - .with_stderr_contains("[ERROR] Cannot build glob pattern from `[*z`") + .with_stderr_contains("[ERROR] cannot build glob pattern from `[*z`") .run(); } @@ -3033,7 +3033,7 @@ fn test_virtual_manifest_glob_not_found() { .build(); p.cargo("test -p bar -p '*z'") - .with_stderr_contains("[WARNING] package pattern(s) *z not found in workspace [..]") + .with_stderr_contains("[WARNING] package pattern(s) `*z` not found in workspace [..]") .with_stdout_contains("running 1 test\ntest bar ... ok") .with_stdout_does_not_contain("running 1 test\ntest baz ... ok") .run(); @@ -3055,7 +3055,7 @@ fn test_virtual_manifest_broken_glob() { p.cargo("test -p '[*z'") .with_status(101) - .with_stderr_contains("[ERROR] Cannot build glob pattern from `[*z`") + .with_stderr_contains("[ERROR] cannot build glob pattern from `[*z`") .run(); } From 0f1534ce8fb0941a7f63f451d27e4ee6101c5e4c Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Sat, 10 Oct 2020 07:17:18 +0800 Subject: [PATCH 17/21] refactor: simplify match -> if let --- src/bin/cargo/commands/run.rs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/bin/cargo/commands/run.rs b/src/bin/cargo/commands/run.rs index 71e55e33777..344d5f19b6c 100644 --- a/src/bin/cargo/commands/run.rs +++ b/src/bin/cargo/commands/run.rs @@ -40,17 +40,14 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult { )?; // Disallow `spec` to be an glob pattern - match &compile_opts.spec { - Packages::Packages(opt_in) => { - 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 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") { From 8f0664f02a631c714447189d9cf3556875c58d0d Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Sat, 10 Oct 2020 07:44:57 +0800 Subject: [PATCH 18/21] test: normalize raw string indentation. --- tests/testsuite/bench.rs | 58 ++++++++++++++++++------------------ tests/testsuite/build.rs | 54 +++++++++++++++++----------------- tests/testsuite/check.rs | 24 +++++++-------- tests/testsuite/doc.rs | 24 +++++++-------- tests/testsuite/rustc.rs | 6 ++-- tests/testsuite/rustdoc.rs | 6 ++-- tests/testsuite/test.rs | 60 +++++++++++++++++++------------------- 7 files changed, 116 insertions(+), 116 deletions(-) diff --git a/tests/testsuite/bench.rs b/tests/testsuite/bench.rs index ae5a471acaa..6f2c39901c6 100644 --- a/tests/testsuite/bench.rs +++ b/tests/testsuite/bench.rs @@ -1468,28 +1468,28 @@ fn bench_all_exclude_glob() { .file( "Cargo.toml", r#" - [project] - name = "foo" - version = "0.1.0" + [project] + name = "foo" + version = "0.1.0" - [workspace] - members = ["bar", "baz"] - "#, + [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; + #![feature(test)] + #[cfg(test)] + extern crate test; - #[bench] - pub fn bar(b: &mut test::Bencher) { - b.iter(|| {}); - } - "#, + #[bench] + pub fn bar(b: &mut test::Bencher) { + b.iter(|| {}); + } + "#, ) .file("baz/Cargo.toml", &basic_manifest("baz", "0.1.0")) .file( @@ -1570,37 +1570,37 @@ fn bench_virtual_manifest_glob() { .file( "Cargo.toml", r#" - [workspace] - members = ["bar", "baz"] - "#, + [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; + #![feature(test)] + extern crate test; - use test::Bencher; + use test::Bencher; - #[bench] - fn bench_bar(_: &mut Bencher) -> () { break_the_build(); } - "#, + #[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; + #![feature(test)] + extern crate test; - use test::Bencher; + use test::Bencher; - #[bench] - fn bench_baz(_: &mut Bencher) -> () { () } - "#, + #[bench] + fn bench_baz(_: &mut Bencher) -> () { () } + "#, ) .build(); diff --git a/tests/testsuite/build.rs b/tests/testsuite/build.rs index e31d13fc417..1908778f019 100644 --- a/tests/testsuite/build.rs +++ b/tests/testsuite/build.rs @@ -3500,13 +3500,13 @@ fn build_all_exclude_not_found() { .file( "Cargo.toml", r#" - [project] - name = "foo" - version = "0.1.0" + [project] + name = "foo" + version = "0.1.0" - [workspace] - members = ["bar"] - "#, + [workspace] + members = ["bar"] + "#, ) .file("src/main.rs", "fn main() {}") .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) @@ -3534,13 +3534,13 @@ fn build_all_exclude_glob() { .file( "Cargo.toml", r#" - [project] - name = "foo" - version = "0.1.0" + [project] + name = "foo" + version = "0.1.0" - [workspace] - members = ["bar", "baz"] - "#, + [workspace] + members = ["bar", "baz"] + "#, ) .file("src/main.rs", "fn main() {}") .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) @@ -3569,13 +3569,13 @@ fn build_all_exclude_glob_not_found() { .file( "Cargo.toml", r#" - [project] - name = "foo" - version = "0.1.0" + [project] + name = "foo" + version = "0.1.0" - [workspace] - members = ["bar"] - "#, + [workspace] + members = ["bar"] + "#, ) .file("src/main.rs", "fn main() {}") .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) @@ -3740,9 +3740,9 @@ fn build_virtual_manifest_glob() { .file( "Cargo.toml", r#" - [workspace] - members = ["bar", "baz"] - "#, + [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(); }") @@ -3767,9 +3767,9 @@ fn build_virtual_manifest_glob_not_found() { .file( "Cargo.toml", r#" - [workspace] - members = ["bar"] - "#, + [workspace] + members = ["bar"] + "#, ) .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("bar/src/lib.rs", "pub fn bar() {}") @@ -3792,9 +3792,9 @@ fn build_virtual_manifest_broken_glob() { .file( "Cargo.toml", r#" - [workspace] - members = ["bar"] - "#, + [workspace] + members = ["bar"] + "#, ) .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("bar/src/lib.rs", "pub fn bar() {}") diff --git a/tests/testsuite/check.rs b/tests/testsuite/check.rs index 0f91461a11f..259c6bfdf15 100644 --- a/tests/testsuite/check.rs +++ b/tests/testsuite/check.rs @@ -420,9 +420,9 @@ fn check_all_exclude() { .file( "Cargo.toml", r#" - [workspace] - members = ["bar", "baz"] - "#, + [workspace] + members = ["bar", "baz"] + "#, ) .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("bar/src/lib.rs", "pub fn bar() {}") @@ -447,9 +447,9 @@ fn check_all_exclude_glob() { .file( "Cargo.toml", r#" - [workspace] - members = ["bar", "baz"] - "#, + [workspace] + members = ["bar", "baz"] + "#, ) .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("bar/src/lib.rs", "pub fn bar() {}") @@ -496,9 +496,9 @@ fn check_virtual_manifest_one_project() { .file( "Cargo.toml", r#" - [workspace] - members = ["bar", "baz"] - "#, + [workspace] + members = ["bar", "baz"] + "#, ) .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("bar/src/lib.rs", "pub fn bar() {}") @@ -523,9 +523,9 @@ fn check_virtual_manifest_glob() { .file( "Cargo.toml", r#" - [workspace] - members = ["bar", "baz"] - "#, + [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(); }") diff --git a/tests/testsuite/doc.rs b/tests/testsuite/doc.rs index 0d05da78eef..8b1749f5e81 100644 --- a/tests/testsuite/doc.rs +++ b/tests/testsuite/doc.rs @@ -546,9 +546,9 @@ fn doc_all_exclude() { .file( "Cargo.toml", r#" - [workspace] - members = ["bar", "baz"] - "#, + [workspace] + members = ["bar", "baz"] + "#, ) .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("bar/src/lib.rs", "pub fn bar() {}") @@ -573,9 +573,9 @@ fn doc_all_exclude_glob() { .file( "Cargo.toml", r#" - [workspace] - members = ["bar", "baz"] - "#, + [workspace] + members = ["bar", "baz"] + "#, ) .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("bar/src/lib.rs", "pub fn bar() {}") @@ -1015,9 +1015,9 @@ fn doc_virtual_manifest_one_project() { .file( "Cargo.toml", r#" - [workspace] - members = ["bar", "baz"] - "#, + [workspace] + members = ["bar", "baz"] + "#, ) .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("bar/src/lib.rs", "pub fn bar() {}") @@ -1042,9 +1042,9 @@ fn doc_virtual_manifest_glob() { .file( "Cargo.toml", r#" - [workspace] - members = ["bar", "baz"] - "#, + [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(); }") diff --git a/tests/testsuite/rustc.rs b/tests/testsuite/rustc.rs index a1c00a096e2..48f6859f02d 100644 --- a/tests/testsuite/rustc.rs +++ b/tests/testsuite/rustc.rs @@ -331,9 +331,9 @@ fn fail_with_glob() { .file( "Cargo.toml", r#" - [workspace] - members = ["bar"] - "#, + [workspace] + members = ["bar"] + "#, ) .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("bar/src/lib.rs", "pub fn bar() { break_the_build(); }") diff --git a/tests/testsuite/rustdoc.rs b/tests/testsuite/rustdoc.rs index a920d855aed..3d27739ef92 100644 --- a/tests/testsuite/rustdoc.rs +++ b/tests/testsuite/rustdoc.rs @@ -233,9 +233,9 @@ fn fail_with_glob() { .file( "Cargo.toml", r#" - [workspace] - members = ["bar"] - "#, + [workspace] + members = ["bar"] + "#, ) .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("bar/src/lib.rs", "pub fn bar() { break_the_build(); }") diff --git a/tests/testsuite/test.rs b/tests/testsuite/test.rs index 1e3ede7f755..9bc3b306267 100644 --- a/tests/testsuite/test.rs +++ b/tests/testsuite/test.rs @@ -2839,13 +2839,13 @@ fn test_all_exclude_not_found() { .file( "Cargo.toml", r#" - [project] - name = "foo" - version = "0.1.0" + [project] + name = "foo" + version = "0.1.0" - [workspace] - members = ["bar"] - "#, + [workspace] + members = ["bar"] + "#, ) .file("src/main.rs", "fn main() {}") .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) @@ -2867,13 +2867,13 @@ fn test_all_exclude_glob() { .file( "Cargo.toml", r#" - [project] - name = "foo" - version = "0.1.0" + [project] + name = "foo" + version = "0.1.0" - [workspace] - members = ["bar", "baz"] - "#, + [workspace] + members = ["bar", "baz"] + "#, ) .file("src/main.rs", "fn main() {}") .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) @@ -2896,13 +2896,13 @@ fn test_all_exclude_glob_not_found() { .file( "Cargo.toml", r#" - [project] - name = "foo" - version = "0.1.0" + [project] + name = "foo" + version = "0.1.0" - [workspace] - members = ["bar"] - "#, + [workspace] + members = ["bar"] + "#, ) .file("src/main.rs", "fn main() {}") .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) @@ -2980,9 +2980,9 @@ fn test_virtual_manifest_one_project() { .file( "Cargo.toml", r#" - [workspace] - members = ["bar", "baz"] - "#, + [workspace] + members = ["bar", "baz"] + "#, ) .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("bar/src/lib.rs", "#[test] fn bar() {}") @@ -3002,9 +3002,9 @@ fn test_virtual_manifest_glob() { .file( "Cargo.toml", r#" - [workspace] - members = ["bar", "baz"] - "#, + [workspace] + members = ["bar", "baz"] + "#, ) .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("bar/src/lib.rs", "#[test] fn bar() { assert!(false); }") @@ -3024,9 +3024,9 @@ fn test_virtual_manifest_glob_not_found() { .file( "Cargo.toml", r#" - [workspace] - members = ["bar"] - "#, + [workspace] + members = ["bar"] + "#, ) .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("bar/src/lib.rs", "#[test] fn bar() {}") @@ -3045,9 +3045,9 @@ fn test_virtual_manifest_broken_glob() { .file( "Cargo.toml", r#" - [workspace] - members = ["bar"] - "#, + [workspace] + members = ["bar"] + "#, ) .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("bar/src/lib.rs", "#[test] fn bar() {}") From e5007de6e9fa429b751dd0ff804fa95236c11776 Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Sat, 10 Oct 2020 08:05:24 +0800 Subject: [PATCH 19/21] test: use `with_stderr_unordered` --- tests/testsuite/build.rs | 60 ++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 33 deletions(-) diff --git a/tests/testsuite/build.rs b/tests/testsuite/build.rs index 1908778f019..9958f1f839d 100644 --- a/tests/testsuite/build.rs +++ b/tests/testsuite/build.rs @@ -3481,13 +3481,11 @@ 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( + .with_stderr_unordered( "\ -[COMPILING] [..] v0.1.0 ([..]) -[COMPILING] [..] v0.1.0 ([..]) +[COMPILING] foo v0.1.0 ([..]) +[COMPILING] bar v0.1.0 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", ) @@ -3515,13 +3513,11 @@ fn build_all_exclude_not_found() { p.cargo("build --workspace --exclude baz") .with_stderr_does_not_contain("[COMPILING] baz v0.1.0 [..]") - .with_stderr_contains("[COMPILING] foo v0.1.0 [..]") - .with_stderr_contains("[COMPILING] bar v0.1.0 [..]") - .with_stderr( + .with_stderr_unordered( "\ [WARNING] excluded package(s) `baz` not found in workspace [..] -[COMPILING] [..] v0.1.0 ([..]) -[COMPILING] [..] v0.1.0 ([..]) +[COMPILING] foo v0.1.0 ([..]) +[COMPILING] bar v0.1.0 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", ) @@ -3551,12 +3547,10 @@ fn build_all_exclude_glob() { p.cargo("build --workspace --exclude '*z'") .with_stderr_does_not_contain("[COMPILING] baz v0.1.0 [..]") - .with_stderr_contains("[COMPILING] foo v0.1.0 [..]") - .with_stderr_contains("[COMPILING] bar v0.1.0 [..]") - .with_stderr( + .with_stderr_unordered( "\ -[COMPILING] [..] v0.1.0 ([..]) -[COMPILING] [..] v0.1.0 ([..]) +[COMPILING] foo v0.1.0 ([..]) +[COMPILING] bar v0.1.0 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", ) @@ -3669,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(); } @@ -3697,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(); } @@ -3832,12 +3826,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()); From e4a1794b417a2268ef95061f1c3812164ff4a2ae Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Sat, 10 Oct 2020 09:50:36 +0800 Subject: [PATCH 20/21] fix: emit errors instead of warnings when glob patterns not found --- src/cargo/ops/cargo_compile.rs | 3 +-- tests/testsuite/build.rs | 9 ++------- tests/testsuite/test.rs | 5 ++--- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/cargo/ops/cargo_compile.rs b/src/cargo/ops/cargo_compile.rs index 7470caaf36f..bc684e05115 100644 --- a/src/cargo/ops/cargo_compile.rs +++ b/src/cargo/ops/cargo_compile.rs @@ -158,8 +158,7 @@ impl Packages { .map(PackageIdSpec::from_package_id); specs.extend(matched_pkgs); } - emit_pattern_not_found(ws, patterns, false) - .or_else(|e| ws.config().shell().warn(e))?; + emit_pattern_not_found(ws, patterns, false)?; specs } Packages::Default => ws diff --git a/tests/testsuite/build.rs b/tests/testsuite/build.rs index 9958f1f839d..ba9a8900419 100644 --- a/tests/testsuite/build.rs +++ b/tests/testsuite/build.rs @@ -3770,13 +3770,8 @@ fn build_virtual_manifest_glob_not_found() { .build(); p.cargo("build -p bar -p '*z'") - .with_stderr( - "\ -[WARNING] package pattern(s) `*z` not found in workspace [..] -[COMPILING] bar v0.1.0 ([..]) -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] -", - ) + .with_status(101) + .with_stderr("[ERROR] package pattern(s) `*z` not found in workspace [..]") .run(); } diff --git a/tests/testsuite/test.rs b/tests/testsuite/test.rs index 9bc3b306267..4ba9a4db833 100644 --- a/tests/testsuite/test.rs +++ b/tests/testsuite/test.rs @@ -3033,9 +3033,8 @@ fn test_virtual_manifest_glob_not_found() { .build(); p.cargo("test -p bar -p '*z'") - .with_stderr_contains("[WARNING] package pattern(s) `*z` not found in workspace [..]") - .with_stdout_contains("running 1 test\ntest bar ... ok") - .with_stdout_does_not_contain("running 1 test\ntest baz ... ok") + .with_status(101) + .with_stderr("[ERROR] package pattern(s) `*z` not found in workspace [..]") .run(); } From 3d042688a851d985013ee8ff64a9caef47b7b495 Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Sat, 10 Oct 2020 10:08:10 +0800 Subject: [PATCH 21/21] style: cargo fmt --- src/cargo/ops/cargo_compile.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/cargo/ops/cargo_compile.rs b/src/cargo/ops/cargo_compile.rs index bc684e05115..f1464b7337c 100644 --- a/src/cargo/ops/cargo_compile.rs +++ b/src/cargo/ops/cargo_compile.rs @@ -1362,10 +1362,7 @@ fn emit_package_not_found( anyhow::bail!( "{}package(s) `{}` not found in workspace `{}`", if opt_out { "excluded " } else { "" }, - opt_names - .into_iter() - .collect::>() - .join(", "), + opt_names.into_iter().collect::>().join(", "), ws.root().display(), ) }