File tree Expand file tree Collapse file tree 3 files changed +55
-1
lines changed Expand file tree Collapse file tree 3 files changed +55
-1
lines changed Original file line number Diff line number Diff line change @@ -1194,7 +1194,16 @@ impl WorkspaceRootConfig {
1194
1194
if expanded_paths. is_empty ( ) {
1195
1195
expanded_list. push ( pathbuf) ;
1196
1196
} else {
1197
- expanded_list. extend ( expanded_paths) ;
1197
+ // Some OS can create system support files anywhere.
1198
+ // (e.g. macOS creates `.DS_Store` file if you visit a directory using Finder.)
1199
+ // Such files can be reported as a member path unexpectedly.
1200
+ // Check and filter out non-directory paths to prevent pushing such accidental unwanted path
1201
+ // as a member.
1202
+ for expanded_path in expanded_paths {
1203
+ if expanded_path. is_dir ( ) {
1204
+ expanded_list. push ( expanded_path) ;
1205
+ }
1206
+ }
1198
1207
}
1199
1208
}
1200
1209
Original file line number Diff line number Diff line change @@ -62,6 +62,7 @@ mod locate_project;
62
62
mod lockfile_compat;
63
63
mod login;
64
64
mod lto;
65
+ mod member_discovery;
65
66
mod member_errors;
66
67
mod message_format;
67
68
mod metabuild;
Original file line number Diff line number Diff line change
1
+ //! Tests for workspace member discovery.
2
+
3
+ use cargo:: core:: { Shell , Workspace } ;
4
+ use cargo:: util:: config:: Config ;
5
+
6
+ use cargo_test_support:: install:: cargo_home;
7
+ use cargo_test_support:: project;
8
+ use cargo_test_support:: registry;
9
+
10
+ /// Tests exclusion of non-directory files from workspace member discovery using glob `*`.
11
+ #[ cargo_test]
12
+ fn bad_file_member_exclusion ( ) {
13
+ let p = project ( )
14
+ . file (
15
+ "Cargo.toml" ,
16
+ r#"
17
+ [workspace]
18
+ members = [ "crates/*" ]
19
+ "# ,
20
+ )
21
+ . file ( "crates/.DS_Store" , "PLACEHOLDER" )
22
+ . file (
23
+ "crates/bar/Cargo.toml" ,
24
+ r#"
25
+ [project]
26
+ name = "bar"
27
+ version = "0.1.0"
28
+ authors = []
29
+ "# ,
30
+ )
31
+ . file ( "crates/bar/src/main.rs" , "fn main() {}" )
32
+ . build ( ) ;
33
+
34
+ // Prevent this test from accessing the network by setting up .cargo/config.
35
+ registry:: init ( ) ;
36
+ let config = Config :: new (
37
+ Shell :: from_write ( Box :: new ( Vec :: new ( ) ) ) ,
38
+ cargo_home ( ) ,
39
+ cargo_home ( ) ,
40
+ ) ;
41
+ let ws = Workspace :: new ( & p. root ( ) . join ( "Cargo.toml" ) , & config) . unwrap ( ) ;
42
+ assert_eq ! ( ws. members( ) . count( ) , 1 ) ;
43
+ assert_eq ! ( ws. members( ) . next( ) . unwrap( ) . name( ) , "bar" ) ;
44
+ }
You can’t perform that action at this time.
0 commit comments