Warn when excluding non-existing packages

This commit is contained in:
Dale Wijnand 2019-02-18 18:26:39 +00:00
parent d347908d32
commit 45ce445c58
No known key found for this signature in database
GPG Key ID: 4F256E3D151DF5EF
2 changed files with 33 additions and 7 deletions

View File

@ -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())]
}

View File

@ -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()