mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00
Warn when excluding non-existing packages
This commit is contained in:
parent
d347908d32
commit
45ce445c58
@ -22,7 +22,8 @@
|
||||
//! previously compiled dependency
|
||||
//!
|
||||
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::collections::{BTreeSet, HashMap, HashSet};
|
||||
use std::iter::FromIterator;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
|
||||
@ -116,12 +117,23 @@ impl Packages {
|
||||
.map(Package::package_id)
|
||||
.map(PackageIdSpec::from_package_id)
|
||||
.collect(),
|
||||
Packages::OptOut(opt_out) => ws
|
||||
.members()
|
||||
.filter(|pkg| !opt_out.iter().any(|name| pkg.name().as_str() == name))
|
||||
.map(Package::package_id)
|
||||
.map(PackageIdSpec::from_package_id)
|
||||
.collect(),
|
||||
Packages::OptOut(opt_out) => {
|
||||
let mut opt_out = BTreeSet::from_iter(opt_out.iter().cloned());
|
||||
let packages = ws
|
||||
.members()
|
||||
.filter(|pkg| !opt_out.remove(pkg.name().as_str()))
|
||||
.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::<Vec<_>>().join(", "),
|
||||
ws.root().display(),
|
||||
))?;
|
||||
}
|
||||
packages
|
||||
},
|
||||
Packages::Packages(packages) if packages.is_empty() => {
|
||||
vec![PackageIdSpec::from_package_id(ws.current()?.package_id())]
|
||||
}
|
||||
|
@ -427,6 +427,20 @@ fn check_virtual_all_implied() {
|
||||
.run();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn exclude_warns_on_non_existing_package() {
|
||||
let p = project().file("src/lib.rs", "").build();
|
||||
p.cargo("check --all --exclude bar")
|
||||
.with_stdout("")
|
||||
.with_stderr(
|
||||
r#"[WARNING] excluded package(s) bar not found in workspace `[CWD]`
|
||||
[CHECKING] foo v0.0.1 ([CWD])
|
||||
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
||||
"#,
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn targets_selected_default() {
|
||||
let foo = project()
|
||||
|
Loading…
x
Reference in New Issue
Block a user