auto merge of #13383 : ben0x539/rust/glob-dots, r=brson

Fixes #12930.
This commit is contained in:
bors 2014-04-09 14:11:56 -07:00
commit e2c84a78b4
2 changed files with 111 additions and 17 deletions

View file

@ -10,13 +10,12 @@
// ignore-win32 TempDir may cause IoError on windows: #10462
#[feature(macro_rules)];
#![feature(macro_rules)]
extern crate glob;
use glob::glob;
use std::unstable::finally::Finally;
use std::{os, unstable};
use std::os;
use std::io;
use std::io::TempDir;
@ -29,9 +28,9 @@ macro_rules! assert_eq ( ($e1:expr, $e2:expr) => (
pub fn main() {
fn mk_file(path: &str, directory: bool) {
if directory {
io::fs::mkdir(&Path::new(path), io::UserRWX);
io::fs::mkdir(&Path::new(path), io::UserRWX).unwrap();
} else {
io::File::create(&Path::new(path));
io::File::create(&Path::new(path)).unwrap();
}
}
@ -72,8 +71,8 @@ pub fn main() {
mk_file("xyz/z", false);
assert_eq!(glob_vec(""), Vec::new());
assert_eq!(glob_vec("."), Vec::new());
assert_eq!(glob_vec(".."), Vec::new());
assert_eq!(glob_vec("."), vec!(os::getcwd()));
assert_eq!(glob_vec(".."), vec!(os::getcwd().join("..")));
assert_eq!(glob_vec("aaa"), vec!(abs_path("aaa")));
assert_eq!(glob_vec("aaa/"), vec!(abs_path("aaa")));
@ -131,6 +130,15 @@ pub fn main() {
abs_path("aaa/tomato/tomato.txt"),
abs_path("aaa/tomato/tomoto.txt")));
assert_eq!(glob_vec("./aaa"), vec!(abs_path("aaa")));
assert_eq!(glob_vec("./*"), glob_vec("*"));
assert_eq!(glob_vec("*/..").pop().unwrap(), abs_path("."));
assert_eq!(glob_vec("aaa/../bbb"), vec!(abs_path("bbb")));
assert_eq!(glob_vec("nonexistent/../bbb"), Vec::new());
assert_eq!(glob_vec("aaa/tomato/tomato.txt/.."), Vec::new());
assert_eq!(glob_vec("aaa/tomato/tomato.txt/"), Vec::new());
assert_eq!(glob_vec("aa[a]"), vec!(abs_path("aaa")));
assert_eq!(glob_vec("aa[abc]"), vec!(abs_path("aaa")));
assert_eq!(glob_vec("a[bca]a"), vec!(abs_path("aaa")));