File tree Expand file tree Collapse file tree 2 files changed +33
-7
lines changed Expand file tree Collapse file tree 2 files changed +33
-7
lines changed Original file line number Diff line number Diff line change 22
22
//! previously compiled dependency
23
23
//!
24
24
25
- use std:: collections:: { HashMap , HashSet } ;
25
+ use std:: collections:: { BTreeSet , HashMap , HashSet } ;
26
+ use std:: iter:: FromIterator ;
26
27
use std:: path:: PathBuf ;
27
28
use std:: sync:: Arc ;
28
29
@@ -116,12 +117,23 @@ impl Packages {
116
117
. map ( Package :: package_id)
117
118
. map ( PackageIdSpec :: from_package_id)
118
119
. collect ( ) ,
119
- Packages :: OptOut ( opt_out) => ws
120
- . members ( )
121
- . filter ( |pkg| !opt_out. iter ( ) . any ( |name| pkg. name ( ) . as_str ( ) == name) )
122
- . map ( Package :: package_id)
123
- . map ( PackageIdSpec :: from_package_id)
124
- . collect ( ) ,
120
+ Packages :: OptOut ( opt_out) => {
121
+ let mut opt_out = BTreeSet :: from_iter ( opt_out. iter ( ) . cloned ( ) ) ;
122
+ let packages = ws
123
+ . members ( )
124
+ . filter ( |pkg| !opt_out. remove ( pkg. name ( ) . as_str ( ) ) )
125
+ . map ( Package :: package_id)
126
+ . map ( PackageIdSpec :: from_package_id)
127
+ . collect ( ) ;
128
+ if !opt_out. is_empty ( ) {
129
+ ws. config ( ) . shell ( ) . warn ( format ! (
130
+ "excluded package(s) {} not found in workspace `{}`" ,
131
+ opt_out. iter( ) . map( |x| x. as_ref( ) ) . collect:: <Vec <_>>( ) . join( ", " ) ,
132
+ ws. root( ) . display( ) ,
133
+ ) ) ?;
134
+ }
135
+ packages
136
+ } ,
125
137
Packages :: Packages ( packages) if packages. is_empty ( ) => {
126
138
vec ! [ PackageIdSpec :: from_package_id( ws. current( ) ?. package_id( ) ) ]
127
139
}
Original file line number Diff line number Diff line change @@ -427,6 +427,20 @@ fn check_virtual_all_implied() {
427
427
. run ( ) ;
428
428
}
429
429
430
+ #[ test]
431
+ fn exclude_warns_on_non_existing_package ( ) {
432
+ let p = project ( ) . file ( "src/lib.rs" , "" ) . build ( ) ;
433
+ p. cargo ( "check --all --exclude bar" )
434
+ . with_stdout ( "" )
435
+ . with_stderr (
436
+ r#"[WARNING] excluded package(s) bar not found in workspace `[CWD]`
437
+ [CHECKING] foo v0.0.1 ([CWD])
438
+ [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
439
+ "# ,
440
+ )
441
+ . run ( ) ;
442
+ }
443
+
430
444
#[ test]
431
445
fn targets_selected_default ( ) {
432
446
let foo = project ( )
You can’t perform that action at this time.
0 commit comments