diff --git a/src/libextra/glob.rs b/src/libextra/glob.rs index fb760685254a5..19dbaa5e8dd07 100644 --- a/src/libextra/glob.rs +++ b/src/libextra/glob.rs @@ -537,6 +537,10 @@ impl MatchOptions { #[cfg(test)] mod test { use std::os; + use std::io::fs; + use std::libc::S_IRWXU; + + use tempfile; use super::*; #[test] @@ -572,6 +576,17 @@ mod test { glob("/*/*/*/*").skip(10000).next(); } + #[test] + #[cfg(not(windows))] + fn test_non_utf8_glob() { + let dir = tempfile::TempDir::new("").unwrap(); + let p = dir.path().join(&[0xFFu8]); + fs::mkdir(&p, S_IRWXU as u32); + + let pat = p.with_filename("*"); + assert_eq!(glob(pat.as_str().expect("tmpdir is not utf-8")).collect::<~[Path]>(), ~[p]) + } + #[test] fn test_range_pattern() { diff --git a/src/libstd/io/fs.rs b/src/libstd/io/fs.rs index cb98ff21105bb..6e7aa3329c5ff 100644 --- a/src/libstd/io/fs.rs +++ b/src/libstd/io/fs.rs @@ -1252,4 +1252,14 @@ mod test { Err(..) => {} } } + + #[test] + #[cfg(not(windows))] + fn test_non_utf8_path_exists() { + let p = tmpdir(); + // We don't care if it exists or not + // lets just make sure it doesn't break + // with non-UTF-8 paths. + &p.path().join(&[0xFFu8]).exists(); + } } diff --git a/src/libstd/path/mod.rs b/src/libstd/path/mod.rs index 6464d6021ee53..b706862c375cf 100644 --- a/src/libstd/path/mod.rs +++ b/src/libstd/path/mod.rs @@ -682,6 +682,7 @@ fn from_utf8_with_replacement(mut v: &[u8]) -> ~str { mod tests { use prelude::*; use super::{GenericPath, PosixPath, WindowsPath}; + use os; use c_str::ToCStr; #[test]