Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tests on Windows #88

Merged
merged 1 commit into from
Sep 23, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
html_root_url = "https://docs.rs/glob/0.3.0"
)]
#![deny(missing_docs)]
#![cfg_attr(all(test, windows), feature(std_misc))]

#[cfg(test)]
#[macro_use]
Expand Down Expand Up @@ -177,7 +176,6 @@ pub fn glob(pattern: &str) -> Result<Paths, PatternError> {
pub fn glob_with(pattern: &str, options: MatchOptions) -> Result<Paths, PatternError> {
#[cfg(windows)]
fn check_windows_verbatim(p: &Path) -> bool {
use std::path::Prefix;
match p.components().next() {
Some(Component::Prefix(ref p)) => p.kind().is_verbatim(),
_ => false,
Expand Down Expand Up @@ -1086,12 +1084,21 @@ mod test {
#[cfg(windows)]
fn win() {
use std::env::current_dir;
use std::ffi::AsOsStr;
use std::path::Component;

// check windows absolute paths with host/device components
let root_with_device = current_dir()
.ok()
.and_then(|p| p.prefix().map(|p| p.join("*")))
.and_then(|p| {
match p.components().next().unwrap() {
Component::Prefix(prefix_component) => {
let path = Path::new(prefix_component.as_os_str());
path.join("*");
Some(path.to_path_buf())
}
_ => panic!("no prefix in this path"),
}
})
.unwrap();
// FIXME (#9639): This needs to handle non-utf8 paths
assert!(glob(root_with_device.as_os_str().to_str().unwrap())
Expand Down