Skip to content

Commit

Permalink
Merge pull request #88 from steveklabnik/master
Browse files Browse the repository at this point in the history
Fix tests on Windows
  • Loading branch information
KodrAus committed Sep 23, 2019
2 parents a72cc56 + 3548a62 commit f54e935
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/lib.rs
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

0 comments on commit f54e935

Please sign in to comment.