Skip to content

Commit f54e935

Browse files
authored
Merge pull request #88 from steveklabnik/master
Fix tests on Windows
2 parents a72cc56 + 3548a62 commit f54e935

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/lib.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@
6161
html_root_url = "https://docs.rs/glob/0.3.0"
6262
)]
6363
#![deny(missing_docs)]
64-
#![cfg_attr(all(test, windows), feature(std_misc))]
6564

6665
#[cfg(test)]
6766
#[macro_use]
@@ -177,7 +176,6 @@ pub fn glob(pattern: &str) -> Result<Paths, PatternError> {
177176
pub fn glob_with(pattern: &str, options: MatchOptions) -> Result<Paths, PatternError> {
178177
#[cfg(windows)]
179178
fn check_windows_verbatim(p: &Path) -> bool {
180-
use std::path::Prefix;
181179
match p.components().next() {
182180
Some(Component::Prefix(ref p)) => p.kind().is_verbatim(),
183181
_ => false,
@@ -1086,12 +1084,21 @@ mod test {
10861084
#[cfg(windows)]
10871085
fn win() {
10881086
use std::env::current_dir;
1089-
use std::ffi::AsOsStr;
1087+
use std::path::Component;
10901088

10911089
// check windows absolute paths with host/device components
10921090
let root_with_device = current_dir()
10931091
.ok()
1094-
.and_then(|p| p.prefix().map(|p| p.join("*")))
1092+
.and_then(|p| {
1093+
match p.components().next().unwrap() {
1094+
Component::Prefix(prefix_component) => {
1095+
let path = Path::new(prefix_component.as_os_str());
1096+
path.join("*");
1097+
Some(path.to_path_buf())
1098+
}
1099+
_ => panic!("no prefix in this path"),
1100+
}
1101+
})
10951102
.unwrap();
10961103
// FIXME (#9639): This needs to handle non-utf8 paths
10971104
assert!(glob(root_with_device.as_os_str().to_str().unwrap())

0 commit comments

Comments
 (0)