-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #8511 - eonil:check-member-path-existence, r=ehuss
Check workspace member existence as dir. Cargo command fails if workspace members are set to something like `crates/*` and if there's any non project file in `crates` directory. This PR makes member discovery logic to exclude non-directory paths. In my case, `.DS_Store` (which is made automatically by Finder on macOS) file triggered this issue.
- Loading branch information
Showing
3 changed files
with
55 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
//! Tests for workspace member discovery. | ||
use cargo::core::{Shell, Workspace}; | ||
use cargo::util::config::Config; | ||
|
||
use cargo_test_support::install::cargo_home; | ||
use cargo_test_support::project; | ||
use cargo_test_support::registry; | ||
|
||
/// Tests exclusion of non-directory files from workspace member discovery using glob `*`. | ||
#[cargo_test] | ||
fn bad_file_member_exclusion() { | ||
let p = project() | ||
.file( | ||
"Cargo.toml", | ||
r#" | ||
[workspace] | ||
members = [ "crates/*" ] | ||
"#, | ||
) | ||
.file("crates/.DS_Store", "PLACEHOLDER") | ||
.file( | ||
"crates/bar/Cargo.toml", | ||
r#" | ||
[project] | ||
name = "bar" | ||
version = "0.1.0" | ||
authors = [] | ||
"#, | ||
) | ||
.file("crates/bar/src/main.rs", "fn main() {}") | ||
.build(); | ||
|
||
// Prevent this test from accessing the network by setting up .cargo/config. | ||
registry::init(); | ||
let config = Config::new( | ||
Shell::from_write(Box::new(Vec::new())), | ||
cargo_home(), | ||
cargo_home(), | ||
); | ||
let ws = Workspace::new(&p.root().join("Cargo.toml"), &config).unwrap(); | ||
assert_eq!(ws.members().count(), 1); | ||
assert_eq!(ws.members().next().unwrap().name(), "bar"); | ||
} |