diff --git a/mk/clean.mk b/mk/clean.mk index f38396cafff..cb8861f6597 100644 --- a/mk/clean.mk +++ b/mk/clean.mk @@ -50,7 +50,7 @@ clean-misc: $(Q)rm -f $(RUSTLLVM_LIB_OBJS) $(RUSTLLVM_OBJS_OBJS) $(RUSTLLVM_DEF) $(Q)rm -Rf $(DOCS) $(Q)rm -Rf $(GENERATED) - $(Q)rm -f tmp/* + $(Q)rm -Rf tmp/* $(Q)rm -Rf rust-stage0-*.tar.bz2 $(PKG_NAME)-*.tar.gz dist $(Q)rm -Rf $(foreach ext, \ html aux cp fn ky log pdf pg toc tp vr cps, \ diff --git a/src/libextra/glob.rs b/src/libextra/glob.rs index 75980497374..6f58102e00a 100644 --- a/src/libextra/glob.rs +++ b/src/libextra/glob.rs @@ -448,11 +448,21 @@ impl MatchOptions { #[cfg(test)] mod test { use std::{io, os, unstable}; + use std::unstable::finally::Finally; use super::*; + use tempfile; #[test] fn test_relative_pattern() { + fn change_then_remove(p: &Path, f: &fn()) { + do (|| { + unstable::change_dir_locked(p, || f()); + }).finally { + os::remove_dir_recursive(p); + } + } + fn mk_file(path: &str, directory: bool) { if directory { os::make_dir(&Path(path), 0xFFFF); @@ -469,10 +479,10 @@ mod test { glob(pattern).collect() } - mk_file("tmp", true); - mk_file("tmp/glob-tests", true); + let root = tempfile::mkdtemp(&os::tmpdir(), "glob-tests"); + let root = root.expect("Should have created a temp directory"); - do unstable::change_dir_locked(&Path("tmp/glob-tests")) { + do change_then_remove(&root) { mk_file("aaa", true); mk_file("aaa/apple", true);