From 69b219e36e49ad356bc07ac9b93a11a7c816e1e5 Mon Sep 17 00:00:00 2001 From: kohsuke Date: Mon, 29 Mar 2010 18:39:56 +0000 Subject: [PATCH] boy we weren't cleaning up the garbage in /tmp! git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@29419 71c3de6d-444a-0410-be80-ed276b4c234a --- .../jvnet/hudson/test/TemporaryDirectoryAllocator.java | 8 +++++++- .../main/java/org/jvnet/hudson/test/TestEnvironment.java | 5 ++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/test/src/main/java/org/jvnet/hudson/test/TemporaryDirectoryAllocator.java b/test/src/main/java/org/jvnet/hudson/test/TemporaryDirectoryAllocator.java index 9a3f2dce42..d28442e984 100644 --- a/test/src/main/java/org/jvnet/hudson/test/TemporaryDirectoryAllocator.java +++ b/test/src/main/java/org/jvnet/hudson/test/TemporaryDirectoryAllocator.java @@ -76,9 +76,15 @@ public class TemporaryDirectoryAllocator { * Deletes all allocated temporary directories. */ public synchronized void dispose() throws IOException, InterruptedException { + IOException x = null; for (File dir : tmpDirectories) - new FilePath(dir).deleteRecursive(); + try { + new FilePath(dir).deleteRecursive(); + } catch (IOException e) { + x = e; + } tmpDirectories.clear(); + if (x!=null) throw new IOException2("Failed to clean up temp dirs",x); } /** diff --git a/test/src/main/java/org/jvnet/hudson/test/TestEnvironment.java b/test/src/main/java/org/jvnet/hudson/test/TestEnvironment.java index 352ff0aaf8..2ca620f405 100644 --- a/test/src/main/java/org/jvnet/hudson/test/TestEnvironment.java +++ b/test/src/main/java/org/jvnet/hudson/test/TestEnvironment.java @@ -26,6 +26,8 @@ package org.jvnet.hudson.test; import hudson.model.Computer; import hudson.model.Hudson; +import java.io.IOException; + /** * TODO: deprecate this, and just consolidate this to {@link HudsonTestCase}. * We can then pin down the current HudsonTestCase to the thread for easier access. @@ -48,7 +50,8 @@ public class TestEnvironment { CURRENT = this; } - public void dispose() { + public void dispose() throws IOException, InterruptedException { + temporaryDirectoryAllocator.dispose(); CURRENT = null; }