From 507414daf9ed9a91ba04e3715f02353e31411a0c Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 6 Sep 2013 00:17:14 -0700 Subject: [PATCH] Un-hork the bots by removing intermediate files The new glob tests created tmp/glob-tests as a directory, but the never removed it. The `make clean` target then attempted to `rm -f` on this, but it couldn't remove the directory. This both changes the clean target to `rm -rf` tmp files, and also alters the tests to delete the directory that all the files are added into. --- mk/clean.mk | 2 +- src/libextra/glob.rs | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/mk/clean.mk b/mk/clean.mk index f38396cafff1..cb8861f65976 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 759804973745..6f58102e00a4 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);