Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 62679 Details for
Bug 166977
[vista] Unexpected errors while running JDT/Core tests
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed patch for 3.1.2
v00.txt (text/plain), 47.93 KB, created by
Frederic Fusier
on 2007-04-02 12:39:35 EDT
(
hide
)
Description:
Proposed patch for 3.1.2
Filename:
MIME Type:
Creator:
Frederic Fusier
Created:
2007-04-02 12:39:35 EDT
Size:
47.93 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core.tests.compiler >Index: src/org/eclipse/jdt/core/tests/compiler/regression/ClassFileComparatorTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ClassFileComparatorTest.java,v >retrieving revision 1.8 >diff -u -r1.8 ClassFileComparatorTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/ClassFileComparatorTest.java 23 Feb 2005 02:52:37 -0000 1.8 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/ClassFileComparatorTest.java 2 Apr 2007 15:43:18 -0000 >@@ -39,7 +39,7 @@ > if (fileNames != null) { > for (int i = 0, max = fileNames.length; i < max; i++) { > if (fileNames[i].indexOf(className) != -1) { >- new File(SOURCE_DIRECTORY + File.separator + fileNames[i]).delete(); >+ Util.delete(SOURCE_DIRECTORY + File.separator + fileNames[i]); > } > } > } >@@ -49,7 +49,7 @@ > if (fileNames != null) { > for (int i = 0, max = fileNames.length; i < max; i++) { > if (fileNames[i].indexOf(className) != -1) { >- new File(EVAL_DIRECTORY + File.separator + fileNames[i]).delete(); >+ Util.delete(EVAL_DIRECTORY + File.separator + fileNames[i]); > } > } > } >Index: src/org/eclipse/jdt/core/tests/compiler/regression/ClassFileReaderTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Attic/ClassFileReaderTest.java,v >retrieving revision 1.36 >diff -u -r1.36 ClassFileReaderTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/ClassFileReaderTest.java 31 May 2005 15:34:03 -0000 1.36 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/ClassFileReaderTest.java 2 Apr 2007 15:43:18 -0000 >@@ -122,7 +122,7 @@ > if (fileNames != null) { > for (int i = 0, max = fileNames.length; i < max; i++) { > if (fileNames[i].indexOf(className) != -1) { >- new File(SOURCE_DIRECTORY + File.separator + fileNames[i]).delete(); >+ Util.delete(SOURCE_DIRECTORY + File.separator + fileNames[i]); > } > } > } >@@ -132,7 +132,7 @@ > if (fileNames != null) { > for (int i = 0, max = fileNames.length; i < max; i++) { > if (fileNames[i].indexOf(className) != -1) { >- new File(EVAL_DIRECTORY + File.separator + fileNames[i]).delete(); >+ Util.delete(EVAL_DIRECTORY + File.separator + fileNames[i]); > } > } > } >Index: src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java,v >retrieving revision 1.50 >diff -u -r1.50 AbstractRegressionTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java 10 Jun 2005 13:33:18 -0000 1.50 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java 2 Apr 2007 15:43:17 -0000 >@@ -444,7 +444,6 @@ > File outputDir = new File(OUTPUT_DIR); > if (outputDir.exists()) { > Util.flushDirectoryContent(outputDir); >- outputDir.delete(); > } > super.tearDown(); > } >Index: src/org/eclipse/jdt/core/tests/compiler/regression/AbstractComparableTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractComparableTest.java,v >retrieving revision 1.7 >diff -u -r1.7 AbstractComparableTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/AbstractComparableTest.java 18 Mar 2005 15:06:13 -0000 1.7 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/AbstractComparableTest.java 2 Apr 2007 15:43:17 -0000 >@@ -133,29 +133,6 @@ > * Specific method to let tests Sun javac compilation available... > #######################################*/ > /* >- * Cleans up the given directory by removing all the files it contains as well >- * but leaving the directory. >- * @throws TargetException if the target path could not be cleaned up >- */ >- protected void cleanupDirectory(File directory) { >- if (!directory.exists()) { >- return; >- } >- String[] fileNames = directory.list(); >- for (int i = 0; i < fileNames.length; i++) { >- File file = new File(directory, fileNames[i]); >- if (file.isDirectory()) { >- cleanupDirectory(file); >- } else { >- if (!file.delete()) >- System.out.println("Could not delete file " + file.getPath()); >- } >- } >- if (!directory.delete()) >- System.out.println("Could not delete directory " + directory.getPath()); >- } >- >- /* > * Write given source test files in current output sub-directory. > * Use test name for this sub-directory name (ie. test001, test002, etc...) > */ >@@ -200,7 +177,7 @@ > protected void runJavac(String[] testFiles, final String expectedProblemLog, final String expectedSuccessOutputString, boolean shouldFlushOutputDirectory) { > try { > if (shouldFlushOutputDirectory) >- cleanupDirectory(new File(JAVAC_OUTPUT_DIR)); >+ Util.delete(JAVAC_OUTPUT_DIR); > > // Write files in dir > IPath dirFilePath = writeFiles(testFiles); >@@ -333,7 +310,7 @@ > } finally { > // Clean up written file(s) > IPath testDir = new Path(Util.getOutputDirectory()).append(testName()); >- cleanupDirectory(testDir.toFile()); >+ Util.delete(testDir.toFile()); > } > } > >Index: src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java,v >retrieving revision 1.20.2.2 >diff -u -r1.20.2.2 BatchCompilerTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java 26 Sep 2005 17:27:39 -0000 1.20.2.2 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java 2 Apr 2007 15:43:18 -0000 >@@ -155,24 +155,33 @@ > String outFileName = printerWritersNameRoot + "out.txt", > errFileName = printerWritersNameRoot + "err.txt"; > Main batchCompiler; >- try { >- batchCompiler = new Main(new PrintWriter(new FileOutputStream( >- outFileName)), new PrintWriter(new FileOutputStream( >- errFileName)), false); >- } catch (FileNotFoundException e) { >- System.out.println(getClass().getName() + '#' + getName()); >- e.printStackTrace(); >- throw new RuntimeException(e); >- } >+ PrintWriter out = null; >+ PrintWriter err = null; > boolean compileOK; > try { >- final String[] tokenizeCommandLine = Main.tokenize(commandLine); >- compileOK = batchCompiler.compile(tokenizeCommandLine); >- } catch (RuntimeException e) { >- compileOK = false; >- System.out.println(getClass().getName() + '#' + getName()); >- e.printStackTrace(); >- throw e; >+ try { >+ out = new PrintWriter(new FileOutputStream(outFileName)); >+ err = new PrintWriter(new FileOutputStream(errFileName)); >+ batchCompiler = new Main(out, err, false); >+ } catch (FileNotFoundException e) { >+ System.out.println(getClass().getName() + '#' + getName()); >+ e.printStackTrace(); >+ throw new RuntimeException(e); >+ } >+ try { >+ final String[] tokenizeCommandLine = Main.tokenize(commandLine); >+ compileOK = batchCompiler.compile(tokenizeCommandLine); >+ } catch (RuntimeException e) { >+ compileOK = false; >+ System.out.println(getClass().getName() + '#' + getName()); >+ e.printStackTrace(); >+ throw e; >+ } >+ } finally { >+ if (out != null) >+ out.close(); >+ if (err != null) >+ err.close(); > } > String outOutputString = Util.fileContent(outFileName), > errOutputString = Util.fileContent(errFileName); >Index: src/org/eclipse/jdt/core/tests/compiler/regression/LookupTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LookupTest.java,v >retrieving revision 1.33.2.3 >diff -u -r1.33.2.3 LookupTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/LookupTest.java 14 Nov 2005 22:26:45 -0000 1.33.2.3 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/LookupTest.java 2 Apr 2007 15:43:18 -0000 >@@ -1514,7 +1514,7 @@ > }, > "SUCCESS"); > // delete binary file Dumbo$Clyde (i.e. simulate removing it from classpath for subsequent compile) >- new File(OUTPUT_DIR, "p" + File.separator + "Dumbo$Clyde.class").delete(); >+ Util.delete(new File(OUTPUT_DIR, "p" + File.separator + "Dumbo$Clyde.class")); > > this.runConformTest( > new String[] { >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/Attic/plugin.xml,v >retrieving revision 1.12.4.2 >diff -u -r1.12.4.2 plugin.xml >--- plugin.xml 16 Nov 2005 11:24:40 -0000 1.12.4.2 >+++ plugin.xml 2 Apr 2007 15:43:17 -0000 >@@ -17,7 +17,8 @@ > <import plugin="org.eclipse.jdt.debug"/> > <import plugin="org.eclipse.jdt.core"/> > <import plugin="org.eclipse.core.runtime.compatibility"/> >- <import plugin="org.eclipse.test.performance"/> >+ <import plugin="org.eclipse.test.performance"/> >+ <import plugin="org.eclipse.core.resources"/> > </requires> > > >Index: src/org/eclipse/jdt/core/tests/eval/DebugEvaluationTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/DebugEvaluationTest.java,v >retrieving revision 1.24.2.1 >diff -u -r1.24.2.1 DebugEvaluationTest.java >--- src/org/eclipse/jdt/core/tests/eval/DebugEvaluationTest.java 6 Jul 2005 21:21:33 -0000 1.24.2.1 >+++ src/org/eclipse/jdt/core/tests/eval/DebugEvaluationTest.java 2 Apr 2007 15:43:19 -0000 >@@ -155,12 +155,8 @@ > } > public void removeTempClass(String className) { > resetEnv(); // needed to reinitialize the caches >- File sourceFile = new File(SOURCE_DIRECTORY + File.separator + className + ".java"); >- sourceFile.delete(); >- >- File binaryFile = new File(EvaluationSetup.EVAL_DIRECTORY + File.separator + LocalVMLauncher.REGULAR_CLASSPATH_DIRECTORY + File.separator + className + ".class"); >- >- binaryFile.delete(); >+ Util.delete(SOURCE_DIRECTORY + File.separator + className + ".java"); >+ Util.delete(EvaluationSetup.EVAL_DIRECTORY + File.separator + LocalVMLauncher.REGULAR_CLASSPATH_DIRECTORY + File.separator + className + ".class"); > } > /*public static Test suite(Class evaluationTestClass) { > junit.framework.TestSuite suite = new junit.framework.TestSuite(); >Index: src/org/eclipse/jdt/core/tests/util/Util.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/Util.java,v >retrieving revision 1.36 >diff -u -r1.36 Util.java >--- src/org/eclipse/jdt/core/tests/util/Util.java 6 Jun 2005 08:55:37 -0000 1.36 >+++ src/org/eclipse/jdt/core/tests/util/Util.java 2 Apr 2007 15:43:19 -0000 >@@ -19,6 +19,9 @@ > import java.util.zip.ZipInputStream; > import java.util.zip.ZipOutputStream; > >+import org.eclipse.core.resources.IContainer; >+import org.eclipse.core.resources.IResource; >+import org.eclipse.core.runtime.CoreException; > import org.eclipse.jdt.core.compiler.IProblem; > import org.eclipse.jdt.core.tests.compiler.regression.Requestor; > import org.eclipse.jdt.internal.compiler.Compiler; >@@ -31,7 +34,99 @@ > import org.eclipse.jdt.internal.compiler.problem.DefaultProblem; > import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory; > public class Util { >- public static String OUTPUT_DIRECTORY = "comptest"; >+// Trace for delete operation >+/* >+ * Maximum time wasted repeating delete operations while running JDT/Core tests. >+ */ >+private static int DELETE_MAX_TIME = 0; >+/** >+ * Trace deletion operations while running JDT/Core tests. >+ */ >+public static boolean DELETE_DEBUG = false; >+/** >+ * Maximum of time in ms to wait in deletion operation while running JDT/Core tests. >+ * Default is 10 seconds. This number cannot exceed 1 minute (ie. 60000). >+ * <br> >+ * To avoid too many loops while waiting, the ten first ones are done waiting >+ * 10ms before repeating, the ten loops after are done waiting 100ms and >+ * the other loops are done waiting 1s... >+ */ >+public static int DELETE_MAX_WAIT = 10000; >+ >+// Output directory initialization >+/** >+ * Initially, output directory was located in System.getProperty("user.home")+"\comptest". >+ * To allow user to run several compiler tests at the same time, main output directory >+ * is now located in a sub-directory of "comptest" which name is "run."+<code>System.currentMilliseconds</code>. >+ * >+ * @see #DELAY_BEFORE_CLEAN_PREVIOUS >+ */ >+private final static String OUTPUT_DIRECTORY; >+/** >+ * Let user specify the delay in hours before output directories are removed from file system >+ * while starting a new test run. Default value is 2 hours. >+ * <p> >+ * Note that this value may be a float and so have time less than one hour. >+ * If value is 0 or negative, then all previous run directories will be removed... >+ * >+ * @see #OUTPUT_DIRECTORY >+ */ >+private final static String DELAY_BEFORE_CLEAN_PREVIOUS = System.getProperty("delay"); >+/* >+ * Static initializer to clean directories created while running previous test suites. >+ */ >+static { >+ // Get delay for cleaning sub-directories >+ long millisecondsPerHour = 1000L * 3600L; >+ long delay = millisecondsPerHour * 2; // default is to keep previous run directories for 2 hours >+ try { >+ if (DELAY_BEFORE_CLEAN_PREVIOUS != null) { >+ float hours = Float.parseFloat(DELAY_BEFORE_CLEAN_PREVIOUS); >+ delay = (int) (millisecondsPerHour * hours); >+ } >+ } >+ catch (NumberFormatException nfe) { >+ // use default >+ } >+ >+ // Get output directory root from system properties >+ String container = System.getProperty("jdt.test.output_directory"); >+ if (container == null){ >+ container = System.getProperty("user.home"); >+ } >+ if (container == null) { >+ container = "."; // use current directory >+ } >+ >+ // Get file for root directory >+ if (Character.isLowerCase(container.charAt(0)) && container.charAt(1) == ':') { >+ container = Character.toUpperCase(container.charAt(0)) + container.substring(1); >+ } >+ File dir = new File(new File(container), "comptest"); >+ >+ // If root directory already exists, clean it >+ if (dir.exists()) { >+ long now = System.currentTimeMillis(); >+ if ((now - dir.lastModified()) > delay) { >+ // remove all directory content >+ flushDirectoryContent(dir); >+ } else { >+ // remove only old sub-dirs >+ File[] testDirs = dir.listFiles(); >+ for (int i=0,l=testDirs.length; i<l; i++) { >+ if (testDirs[i].isDirectory()) { >+ if ((now - testDirs[i].lastModified()) > delay) { >+ delete(testDirs[i]); >+ } >+ } >+ } >+ } >+ } >+ >+ // Computed test run directory name based on current time >+ File dateDir = new File(dir, "run."+System.currentTimeMillis()); >+ OUTPUT_DIRECTORY = dateDir.getPath(); >+} > > public static void appendProblem(StringBuffer problems, IProblem problem, char[] source, int problemCount) { > problems.append(problemCount + (problem.isError() ? ". ERROR" : ". WARNING")); >@@ -146,8 +241,10 @@ > try { > in = new FileInputStream(source); > File destFile = new File(dest, source.getName()); >- if (destFile.exists() && !destFile.delete()) { >- throw new IOException(destFile + " is in use"); >+ if (destFile.exists()) { >+ if (!delete(destFile)) { >+ throw new IOException(destFile + " is in use"); >+ } > } > out = new FileOutputStream(destFile); > int bufferLength = 1024; >@@ -218,6 +315,54 @@ > zip(sourcesDir, zipPath); > } > /** >+ * Delete a file or directory and insure that the file is no longer present >+ * on file system. In case of directory, delete all the hierarchy underneath. >+ * >+ * @param file The file or directory to delete >+ * @return true iff the file was really delete, false otherwise >+ */ >+public static boolean delete(File file) { >+ // flush all directory content >+ if (file.isDirectory()) { >+ flushDirectoryContent(file); >+ } >+ // remove file >+ file.delete(); >+ if (isFileDeleted(file)) { >+ return true; >+ } >+ return waitUntilFileDeleted(file); >+} >+/** >+ * Delete a file or directory and insure that the file is no longer present >+ * on file system. In case of directory, delete all the hierarchy underneath. >+ * >+ * @param resource The resource to delete >+ * @return true iff the file was really delete, false otherwise >+ */ >+public static boolean delete(IResource resource) { >+ try { >+ resource.delete(true, null); >+ if (isResourceDeleted(resource)) { >+ return true; >+ } >+ } >+ catch (CoreException e) { >+ // skip >+ } >+ return waitUntilResourceDeleted(resource); >+} >+/** >+ * Delete a file or directory and insure that the file is no longer present >+ * on file system. In case of directory, delete all the hierarchy underneath. >+ * >+ * @param path The path of the file or directory to delete >+ * @return true iff the file was really delete, false otherwise >+ */ >+public static boolean delete(String path) { >+ return delete(new File(path)); >+} >+/** > * Generate a display string from the given String. > * @param inputString the given input string > * >@@ -433,16 +578,10 @@ > * no-op if not a directory. > */ > public static void flushDirectoryContent(File dir) { >- if (dir.isDirectory()) { >- String[] files = dir.list(); >- if (files == null) return; >- for (int i = 0, max = files.length; i < max; i++) { >- File current = new File(dir, files[i]); >- if (current.isDirectory()) { >- flushDirectoryContent(current); >- } >- current.delete(); >- } >+ File[] files = dir.listFiles(); >+ if (files == null) return; >+ for (int i = 0, max = files.length; i < max; i++) { >+ delete(files[i]); > } > } > /** >@@ -499,11 +638,82 @@ > * Example of use: [org.eclipse.jdt.core.tests.util.Util.getOutputDirectory()] > */ > public static String getOutputDirectory() { >- String container = System.getProperty("user.home"); >- if (container == null){ >- return null; >+ return OUTPUT_DIRECTORY; >+} >+/** >+ * Returns the parent's child file matching the given file or null if not found. >+ * >+ * @param file The searched file in parent >+ * @return The parent's child matching the given file or null if not found. >+ */ >+private static File getParentChildFile(File file) { >+ File parent = file.getParentFile(); >+ if (parent == null || !parent.exists()) return null; >+ File[] files = parent.listFiles(); >+ int length = files==null ? 0 : files.length; >+ if (length > 0) { >+ for (int i=0; i<length; i++) { >+ if (files[i] == file) { >+ return files[i]; >+ } else if (files[i].equals(file)) { >+ return files[i]; >+ } else if (files[i].getPath().equals(file.getPath())) { >+ return files[i]; >+ } >+ } > } >- return toNativePath(container) + File.separator + OUTPUT_DIRECTORY; >+ return null; >+} >+/** >+ * Returns parent's child resource matching the given resource or null if not found. >+ * >+ * @param resource The searched file in parent >+ * @return The parent's child matching the given file or null if not found. >+ */ >+private static IResource getParentChildResource(IResource resource) { >+ IContainer parent = resource.getParent(); >+ if (parent == null || !parent.exists()) return null; >+ try { >+ IResource[] members = parent.members(); >+ int length = members ==null ? 0 : members.length; >+ if (length > 0) { >+ for (int i=0; i<length; i++) { >+ if (members[i] == resource) { >+ return members[i]; >+ } else if (members[i].equals(resource)) { >+ return members[i]; >+ } else if (members[i].getFullPath().equals(resource.getFullPath())) { >+ return members[i]; >+ } >+ } >+ } >+ } >+ catch (CoreException ce) { >+ // skip >+ } >+ return null; >+} >+/** >+ * Returns the test name from stack elements info. >+ * >+ * @return The name of the test currently running >+ */ >+private static String getTestName() { >+ StackTraceElement[] elements = new Exception().getStackTrace(); >+ int idx = 0, length=elements.length; >+ while (idx<length && !elements[idx++].getClassName().startsWith("org.eclipse.jdt")) { >+ // loop until JDT/Core class appears in the stack >+ } >+ if (idx<length) { >+ StackTraceElement testElement = null; >+ while (idx<length && elements[idx].getClassName().startsWith("org.eclipse.jdt")) { >+ testElement = elements[idx++]; >+ } >+ if (testElement != null) { >+ return testElement.getClassName() + " - " + testElement.getMethodName(); >+ } >+ } >+ return "?"; > } > /** > * Returns the next available port number on the local host. >@@ -545,6 +755,132 @@ > return buffer.toString(); > } > /** >+ * Returns whether a file is really deleted or not. >+ * Does not only rely on {@link File#exists()} method but also >+ * look if it's not in its parent children {@link #getParentChildFile(File)}. >+ * >+ * @param file The file to test if deleted >+ * @return true if the file does not exist and was not found in its parent children. >+ */ >+public static boolean isFileDeleted(File file) { >+ return !file.exists() && getParentChildFile(file) == null; >+} >+public static boolean isMacOS() { >+ return System.getProperty("os.name").indexOf("Mac") != -1; >+} >+/** >+ * Returns whether a resource is really deleted or not. >+ * Does not only rely on {@link IResource#isAccessible()} method but also >+ * look if it's not in its parent children {@link #getParentChildResource(IResource)}. >+ * >+ * @param resource The resource to test if deleted >+ * @return true if the resource is not accessible and was not found in its parent children. >+ */ >+public static boolean isResourceDeleted(IResource resource) { >+ return !resource.isAccessible() && getParentChildResource(resource) == null; >+} >+/** >+ * Print given file information with specified indentation. >+ * These information are:<ul> >+ * <li>read {@link File#canRead()}</li> >+ * <li>write {@link File#canWrite()}</li> >+ * <li>exists {@link File#exists()}</li> >+ * <li>is file {@link File#isFile()}</li> >+ * <li>is directory {@link File#isDirectory()}</li> >+ * <li>is hidden {@link File#isHidden()}</li> >+ * </ul> >+ * May recurse several level in parents hierarchy. >+ * May also display children, but then will not recusre in parent >+ * hierarchy to avoid infinite loop... >+ * >+ * @param file The file to display information >+ * @param indent Number of tab to print before the information >+ * @param recurse Display also information on <code>recurse</code>th parents in hierarchy. >+ * If negative then display children information instead. >+ */ >+private static void printFileInfo(File file, int indent, int recurse) { >+ String tab = ""; >+ for (int i=0; i<indent; i++) tab+="\t"; >+ System.out.print(tab+"- "+file.getName()+" file info: "); >+ String sep = ""; >+ if (file.canRead()) { >+ System.out.print("read"); >+ sep = ", "; >+ } >+ if (file.canWrite()) { >+ System.out.print(sep+"write"); >+ sep = ", "; >+ } >+ if (file.exists()) { >+ System.out.print(sep+"exist"); >+ sep = ", "; >+ } >+ if (file.isDirectory()) { >+ System.out.print(sep+"dir"); >+ sep = ", "; >+ } >+ if (file.isFile()) { >+ System.out.print(sep+"file"); >+ sep = ", "; >+ } >+ if (file.isHidden()) { >+ System.out.print(sep+"hidden"); >+ sep = ", "; >+ } >+ System.out.println(); >+ File[] files = file.listFiles(); >+ int length = files==null ? 0 : files.length; >+ if (length > 0) { >+ boolean children = recurse < 0; >+ System.out.print(tab+" + children: "); >+ if (children) System.out.println(); >+ for (int i=0; i<length; i++) { >+ if (children) { // display children >+ printFileInfo(files[i], indent+2, -1); >+ } else { >+ if (i>0) System.out.print(", "); >+ System.out.print(files[i].getName()); >+ if (files[i].isDirectory()) System.out.print("[dir]"); >+ else if (files[i].isFile()) System.out.print("[file]"); >+ else System.out.print("[?]"); >+ } >+ } >+ if (!children) System.out.println(); >+ } >+ if (recurse > 0) { >+ File parent = file.getParentFile(); >+ if (parent != null) printFileInfo(parent, indent+1, recurse-1); >+ } >+ } >+ /** >+ * Print stack trace with only JDT/Core elements. >+ * >+ * @param exception Exception of the stack trace. May be null, then a fake exception is used. >+ * @param indent Number of tab to display before the stack elements to display. >+ */ >+ private static void printJdtCoreStackTrace(Exception exception, int indent) { >+ String tab = ""; >+ for (int i=0; i<indent; i++) tab+="\t"; >+ StackTraceElement[] elements = (exception==null?new Exception():exception).getStackTrace(); >+ int idx = 0, length=elements.length; >+ while (idx<length && !elements[idx++].getClassName().startsWith("org.eclipse.jdt")) { >+ // loop until JDT/Core class appears in the stack >+ } >+ if (idx<length) { >+ System.out.print(tab+"- stack trace"); >+ if (exception == null) >+ System.out.println(":"); >+ else >+ System.out.println(" for exception "+exception+":"); >+ while (idx<length && elements[idx].getClassName().startsWith("org.eclipse.jdt")) { >+ StackTraceElement testElement = elements[idx++]; >+ System.out.println(tab+" -> "+testElement); >+ } >+ } else { >+ exception.printStackTrace(System.out); >+ } >+ } >+ /** > * Makes the given path a path using native path separators as returned by File.getPath() > * and trimming any extra slash. > */ >@@ -607,6 +943,157 @@ > } > } > } >+/** >+ * Wait until the file is _really_ deleted on file system. >+ * >+ * @param file Deleted file >+ * @return true if the file was finally deleted, false otherwise >+ */ >+private static boolean waitUntilFileDeleted(File file) { >+ if (DELETE_DEBUG) { >+ System.out.println(); >+ System.out.println("WARNING in test: "+getTestName()); >+ System.out.println(" - problems occured while deleting "+file); >+ printJdtCoreStackTrace(null, 1); >+ printFileInfo(file.getParentFile(), 1, -1); // display parent with its children >+ System.out.print(" - wait for ("+DELETE_MAX_WAIT+"ms max): "); >+ } >+ int count = 0; >+ int delay = 10; // ms >+ int maxRetry = DELETE_MAX_WAIT / delay; >+ int time = 0; >+ while (count < maxRetry) { >+ try { >+ count++; >+ Thread.sleep(delay); >+ time += delay; >+ if (time > DELETE_MAX_TIME) DELETE_MAX_TIME = time; >+ if (DELETE_DEBUG) System.out.print('.'); >+ if (file.exists()) { >+ if (file.delete()) { >+ // SUCCESS >+ if (DELETE_DEBUG) { >+ System.out.println(); >+ System.out.println(" => file really removed after "+time+"ms (max="+DELETE_MAX_TIME+"ms)"); >+ System.out.println(); >+ } >+ return true; >+ } >+ } >+ if (isFileDeleted(file)) { >+ // SUCCESS >+ if (DELETE_DEBUG) { >+ System.out.println(); >+ System.out.println(" => file disappeared after "+time+"ms (max="+DELETE_MAX_TIME+"ms)"); >+ System.out.println(); >+ } >+ return true; >+ } >+ // Increment waiting delay exponentially >+ if (count >= 10 && delay <= 100) { >+ count = 1; >+ delay *= 10; >+ maxRetry = DELETE_MAX_WAIT / delay; >+ if ((DELETE_MAX_WAIT%delay) != 0) { >+ maxRetry++; >+ } >+ } >+ } >+ catch (InterruptedException ie) { >+ break; // end loop >+ } >+ } >+ if (!DELETE_DEBUG) { >+ System.out.println(); >+ System.out.println("WARNING in test: "+getTestName()); >+ System.out.println(" - problems occured while deleting "+file); >+ printJdtCoreStackTrace(null, 1); >+ printFileInfo(file.getParentFile(), 1, -1); // display parent with its children >+ } >+ System.out.println(); >+ System.out.println(" !!! ERROR: "+file+" was never deleted even after having waited "+DELETE_MAX_TIME+"ms!!!"); >+ System.out.println(); >+ return false; >+} >+/** >+ * Wait until a resource is _really_ deleted on file system. >+ * >+ * @param resource Deleted resource >+ * @return true if the file was finally deleted, false otherwise >+ */ >+private static boolean waitUntilResourceDeleted(IResource resource) { >+ File file = resource.getLocation().toFile(); >+ if (DELETE_DEBUG) { >+ System.out.println(); >+ System.out.println("WARNING in test: "+getTestName()); >+ System.out.println(" - problems occured while deleting resource "+resource); >+ printJdtCoreStackTrace(null, 1); >+ printFileInfo(file.getParentFile(), 1, -1); // display parent with its children >+ System.out.print(" - wait for ("+DELETE_MAX_WAIT+"ms max): "); >+ } >+ int count = 0; >+ int delay = 10; // ms >+ int maxRetry = DELETE_MAX_WAIT / delay; >+ int time = 0; >+ while (count < maxRetry) { >+ try { >+ count++; >+ Thread.sleep(delay); >+ time += delay; >+ if (time > DELETE_MAX_TIME) DELETE_MAX_TIME = time; >+ if (DELETE_DEBUG) System.out.print('.'); >+ if (resource.isAccessible()) { >+ try { >+ resource.delete(true, null); >+ if (isResourceDeleted(resource) && isFileDeleted(file)) { >+ // SUCCESS >+ if (DELETE_DEBUG) { >+ System.out.println(); >+ System.out.println(" => resource really removed after "+time+"ms (max="+DELETE_MAX_TIME+"ms)"); >+ System.out.println(); >+ } >+ return true; >+ } >+ } >+ catch (CoreException e) { >+ // skip >+ } >+ } >+ if (isResourceDeleted(resource) && isFileDeleted(file)) { >+ // SUCCESS >+ if (DELETE_DEBUG) { >+ System.out.println(); >+ System.out.println(" => resource disappeared after "+time+"ms (max="+DELETE_MAX_TIME+"ms)"); >+ System.out.println(); >+ } >+ return true; >+ } >+ // Increment waiting delay exponentially >+ if (count >= 10 && delay <= 100) { >+ count = 1; >+ delay *= 10; >+ maxRetry = DELETE_MAX_WAIT / delay; >+ if ((DELETE_MAX_WAIT%delay) != 0) { >+ maxRetry++; >+ } >+ } >+ } >+ catch (InterruptedException ie) { >+ break; // end loop >+ } >+ } >+ if (!DELETE_DEBUG) { >+ System.out.println(); >+ System.out.println("WARNING in test: "+getTestName()); >+ System.out.println(" - problems occured while deleting resource "+resource); >+ printJdtCoreStackTrace(null, 1); >+ printFileInfo(file.getParentFile(), 1, -1); // display parent with its children >+ } >+ System.out.println(); >+ System.out.println(" !!! ERROR: "+resource+" was never deleted even after having waited "+DELETE_MAX_TIME+"ms!!!"); >+ System.out.println(); >+ return false; >+} > public static void writeToFile(String contents, String destinationFilePath) { > File destFile = new File(destinationFilePath); > FileOutputStream output = null; >@@ -630,7 +1117,9 @@ > public static void zip(File rootDir, String zipPath) throws IOException { > ZipOutputStream zip = null; > try { >- zip = new ZipOutputStream(new FileOutputStream(zipPath)); >+ File zipFile = new File(zipPath); >+ if (zipFile.exists()) delete(zipFile); >+ zip = new ZipOutputStream(new FileOutputStream(zipFile)); > zip(rootDir, zip, rootDir.getPath().length()+1); // 1 for last slash > } finally { > if (zip != null) { >@@ -639,20 +1128,19 @@ > } > } > private static void zip(File dir, ZipOutputStream zip, int rootPathLength) throws IOException { >- String[] list = dir.list(); >- if (list != null) { >- for (int i = 0, length = list.length; i < length; i++) { >- String name = list[i]; >- File file = new File(dir, name); >- if (file.isDirectory()) { >- zip(file, zip, rootPathLength); >- } else { >+ File[] files = dir.listFiles(); >+ if (files != null) { >+ for (int i = 0, length = files.length; i < length; i++) { >+ File file = files[i]; >+ if (file.isFile()) { > String path = file.getPath(); > path = path.substring(rootPathLength); > ZipEntry entry = new ZipEntry(path.replace('\\', '/')); > zip.putNextEntry(entry); > zip.write(org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(file)); > zip.closeEntry(); >+ } else { >+ zip(file, zip, rootPathLength); > } > } > } >Index: src/org/eclipse/jdt/core/tests/runtime/LocalVirtualMachine.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/LocalVirtualMachine.java,v >retrieving revision 1.9 >diff -u -r1.9 LocalVirtualMachine.java >--- src/org/eclipse/jdt/core/tests/runtime/LocalVirtualMachine.java 9 May 2005 17:06:13 -0000 1.9 >+++ src/org/eclipse/jdt/core/tests/runtime/LocalVirtualMachine.java 2 Apr 2007 15:43:19 -0000 >@@ -12,6 +12,8 @@ > > import java.io.*; > >+import org.eclipse.jdt.core.tests.util.Util; >+ > /** > * Wrapper around the external process that is running a local VM. > * This allows to kill this process when we exit this vm. >@@ -46,11 +48,11 @@ > this.process.destroy(); > } > } >-/** >+/* > * Cleans up the given directory by removing all the files it contains as well > * but leaving the directory. > * @throws TargetException if the target path could not be cleaned up >- */ >+ * > private void cleanupDirectory(File directory) throws TargetException { > if (!directory.exists()) { > return; >@@ -70,6 +72,7 @@ > } > } > } >+*/ > /** > * Cleans up this context's target path by removing all the files it contains > * but leaving the directory. >@@ -79,11 +82,11 @@ > if (this.evalTargetPath == null) return; > String targetPath = this.evalTargetPath; > if (LocalVMLauncher.TARGET_HAS_FILE_SYSTEM) { >- cleanupDirectory(new File(targetPath, LocalVMLauncher.REGULAR_CLASSPATH_DIRECTORY)); >- cleanupDirectory(new File(targetPath, LocalVMLauncher.BOOT_CLASSPATH_DIRECTORY)); >+ Util.delete(new File(targetPath, LocalVMLauncher.REGULAR_CLASSPATH_DIRECTORY)); >+ Util.delete(new File(targetPath, LocalVMLauncher.BOOT_CLASSPATH_DIRECTORY)); > File file = new File(targetPath, RuntimeConstants.SUPPORT_ZIP_FILE_NAME); > >- // workaround pb with Process.exitValue() that returns the process has exited, but it has not free the file yet >+ /* workaround pb with Process.exitValue() that returns the process has exited, but it has not free the file yet > int count = 10; > for (int i = 0; i < count; i++) { > if (file.delete()) { >@@ -94,11 +97,12 @@ > } catch (InterruptedException e) { > } > } >- if (file.exists()) { >+ */ >+ if (!Util.delete(file)) { > throw new TargetException("Could not delete " + file.getPath()); > } > } else { >- cleanupDirectory(new File(targetPath)); >+ Util.delete(targetPath); > } > } > /** >#P org.eclipse.jdt.core.tests >Index: Eclipse Java Tests Compiler/org/eclipse/jdt/tests/compiler/regression/NegativeTest.java >=================================================================== >RCS file: /home/cvs/numbat/org.eclipse.jdt.core.tests/Eclipse Java Tests Compiler/org/eclipse/jdt/tests/compiler/regression/NegativeTest.java,v >retrieving revision 1.265.2.4 >diff -u -r1.265.2.4 NegativeTest.java >--- Eclipse Java Tests Compiler/org/eclipse/jdt/tests/compiler/regression/NegativeTest.java 19 Oct 2005 17:04:42 -0000 1.265.2.4 >+++ Eclipse Java Tests Compiler/org/eclipse/jdt/tests/compiler/regression/NegativeTest.java 2 Apr 2007 15:42:54 -0000 >@@ -6,6 +6,7 @@ > import junit.framework.Test; > > import org.eclipse.jdt.core.tests.compiler.regression.AbstractRegressionTest; >+import org.eclipse.jdt.core.tests.util.Util; > import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; > > public class NegativeTest extends AbstractRegressionTest { >@@ -15312,7 +15313,7 @@ > }, > "SUCCESS"); > // delete binary file SecretClass (i.e. simulate removing it from classpath for subsequent compile) >- new File(OUTPUT_DIR, "plugin3" + File.separator + "SecretClass.class").delete(); >+ Util.delete(new File(OUTPUT_DIR, "plugin3" + File.separator + "SecretClass.class")); > > this.runNegativeTest( > new String[] { >@@ -15360,7 +15361,7 @@ > }, > "SUCCESS"); > // delete binary file SecretClass (i.e. simulate removing it from classpath for subsequent compile) >- new File(OUTPUT_DIR, "plugin3" + File.separator + "SecretClass.class").delete(); >+ Util.delete(new File(OUTPUT_DIR, "plugin3" + File.separator + "SecretClass.class")); > > this.runNegativeTest( > new String[] { >@@ -15410,7 +15411,7 @@ > }, > "SUCCESS"); > // delete binary file SecretClass (i.e. simulate removing it from classpath for subsequent compile) >- new File(OUTPUT_DIR, "plugin3" + File.separator + "SecretClass.class").delete(); >+ Util.delete(new File(OUTPUT_DIR, "plugin3" + File.separator + "SecretClass.class")); > > this.runNegativeTest( > new String[] { >@@ -15606,7 +15607,7 @@ > false, > null); > // discard LoopB.class and replace it with copy LoopB1.class so as to create cycle in binaries >- new File(OUTPUT_DIR, "p" + File.separator + "LoopB.class").delete(); >+ Util.delete(new File(OUTPUT_DIR, "p" + File.separator + "LoopB.class")); > new File(OUTPUT_DIR, "p" + File.separator + "LoopB1.class").renameTo(new File(OUTPUT_DIR, "p" + File.separator + "LoopB.class")); > > this.runNegativeTest( >Index: Eclipse Java Tests Model/src/org/eclipse/jdt/tests/core/JavaModelRegressionTestSetup.java >=================================================================== >RCS file: /home/cvs/numbat/org.eclipse.jdt.core.tests/Eclipse Java Tests Model/src/org/eclipse/jdt/tests/core/JavaModelRegressionTestSetup.java,v >retrieving revision 1.31 >diff -u -r1.31 JavaModelRegressionTestSetup.java >--- Eclipse Java Tests Model/src/org/eclipse/jdt/tests/core/JavaModelRegressionTestSetup.java 25 Nov 2004 15:18:26 -0000 1.31 >+++ Eclipse Java Tests Model/src/org/eclipse/jdt/tests/core/JavaModelRegressionTestSetup.java 2 Apr 2007 15:42:54 -0000 >@@ -22,6 +22,7 @@ > import org.eclipse.core.runtime.IProgressMonitor; > import org.eclipse.core.runtime.Path; > import org.eclipse.jdt.core.JavaCore; >+import org.eclipse.jdt.core.tests.util.Util; > > public class JavaModelRegressionTestSetup extends TestSetup { > public static JavaModelRegressionTestSetup CURRENT_TEST_SETUP = null; >@@ -224,9 +225,7 @@ > if (CURRENT_TEST_SETUP == this) { > RegressionTestSuite.fgJavaModel.close(); > RegressionTestSuite.fgJavaModel = null; >- new java.io.File(LOCAL_JDK + File.separator + "classes.zip").delete(); >- new java.io.File(LOCAL_JDK + File.separator + "src.zip").delete(); >- new java.io.File(LOCAL_JDK).delete(); >+ Util.delete(new File(LOCAL_JDK)); > } > } > } >Index: .options >=================================================================== >RCS file: .options >diff -N .options >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ .options 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,8 @@ >+# Turn on debug tracing for org.eclipse.jdt.core.tests plugin >+org.eclipse.jdt.core.tests/debug=true >+ >+# Reports deletion activity >+org.eclipse.jdt.core.tests/debug/delete=false >+ >+# Maximum time in ms waiting for delete operation succeed >+org.eclipse.jdt.core.tests/debug/delete/wait=10000 >Index: Eclipse Java Tests Runner/org/eclipse/jdt/core/tests/JDTCoreTestsPlugin.java >=================================================================== >RCS file: Eclipse Java Tests Runner/org/eclipse/jdt/core/tests/JDTCoreTestsPlugin.java >diff -N Eclipse Java Tests Runner/org/eclipse/jdt/core/tests/JDTCoreTestsPlugin.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ Eclipse Java Tests Runner/org/eclipse/jdt/core/tests/JDTCoreTestsPlugin.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,80 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2006 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.core.tests; >+ >+import org.eclipse.core.runtime.Platform; >+import org.eclipse.core.runtime.Plugin; >+import org.eclipse.jdt.core.tests.util.Util; >+import org.osgi.framework.BundleContext; >+ >+public class JDTCoreTestsPlugin extends Plugin { >+ >+// The shared plugin instance. >+private static JDTCoreTestsPlugin JDT_CORE_TESTS_PLUGIN; >+ >+/** >+ * The plug-in identifier of the JDT/Core tests support >+ * (value <code>"org.eclipse.jdt.core.tests"</code>). >+ */ >+public static final String PLUGIN_ID = "org.eclipse.jdt.core.tests" ; //$NON-NLS-1$ >+ >+private static final String DELETE_DEBUG = PLUGIN_ID + "/debug/delete" ; //$NON-NLS-1$ >+private static final String DELETE_MAX_WAIT = PLUGIN_ID + "/debug/delete/wait" ; //$NON-NLS-1$ >+ >+/** >+ * The constructor. >+ */ >+public JDTCoreTestsPlugin() { >+ JDT_CORE_TESTS_PLUGIN = this; >+} >+ >+/** >+ * This method is called upon plug-in activation >+ */ >+public void start(BundleContext context) throws Exception { >+ super.start(context); >+ configurePluginDebugOptions(); >+} >+ >+/** >+ * This method is called when the plug-in is stopped >+ */ >+public void stop(BundleContext context) throws Exception { >+ super.stop(context); >+ JDT_CORE_TESTS_PLUGIN = null; >+} >+ >+/** >+ * Returns the shared instance. >+ */ >+public static JDTCoreTestsPlugin getDefault() { >+ return JDT_CORE_TESTS_PLUGIN; >+} >+ >+/** >+ * Configure the plugin with respect to option settings defined in ".options" file >+ */ >+void configurePluginDebugOptions(){ >+ if(isDebugging()){ >+ String option = Platform.getDebugOption(DELETE_DEBUG); >+ if(option != null) { >+ Util.DELETE_DEBUG = option.equalsIgnoreCase("true") ; //$NON-NLS-1$ >+ } >+ option = Platform.getDebugOption(DELETE_MAX_WAIT); >+ if(option != null) { >+ int wait = Integer.parseInt(option); >+ if (wait > 1000 && wait <= 60000) { // between 1 and 60 seconds, else use default value (10s) >+ Util.DELETE_MAX_WAIT = wait; >+ } >+ } >+ } >+} >+} >#P org.eclipse.jdt.core.tests.performance >Index: src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.performance/src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceTests.java,v >retrieving revision 1.18 >diff -u -r1.18 FullSourceWorkspaceTests.java >--- src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceTests.java 9 May 2005 15:38:43 -0000 1.18 >+++ src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceTests.java 2 Apr 2007 15:43:28 -0000 >@@ -519,7 +519,7 @@ > } > errorsCount = main.globalErrorsCount; > } >- cleanupDirectory(new File(bins)); >+ Util.delete(bins); > warnings = main.globalWarningsCount; > } > >@@ -540,28 +540,6 @@ > this.scenarioComment.append(warnings); > } > >- /** >- * Delete a directory from file system. >- * @param directory >- */ >- protected void cleanupDirectory(File directory) { >- if (!directory.isDirectory() || !directory.exists()) { >- return; >- } >- String[] fileNames = directory.list(); >- for (int i = 0; i < fileNames.length; i++) { >- File file = new File(directory, fileNames[i]); >- if (file.isDirectory()) { >- cleanupDirectory(file); >- } else { >- if (!file.delete()) >- System.out.println("Could not delete file " + file.getPath()); //$NON-NLS-1$ >- } >- } >- if (!directory.delete()) >- System.out.println("Could not delete directory " + directory.getPath()); //$NON-NLS-1$ >- } >- > private void collectAllFiles(File root, ArrayList collector, FileFilter fileFilter) { > File[] files = root.listFiles(fileFilter); > for (int i = 0; i < files.length; i++) { >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/model/JavaProjectTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaProjectTests.java,v >retrieving revision 1.59 >diff -u -r1.59 JavaProjectTests.java >--- src/org/eclipse/jdt/core/tests/model/JavaProjectTests.java 16 Jun 2005 17:34:40 -0000 1.59 >+++ src/org/eclipse/jdt/core/tests/model/JavaProjectTests.java 2 Apr 2007 15:43:31 -0000 >@@ -841,13 +841,7 @@ > //System.out.println((System.currentTimeMillis() - start)+ "ms for "+roots.length+" roots"); > } finally { > if (libDir != null) { >- String[] libJars = libDir.list(); >- if (libJars != null) { >- for (int i = 0, length = libJars.length; i < length; i++) { >- new File(libDir, libJars[i]).delete(); >- } >- } >- libDir.delete(); >+ org.eclipse.jdt.core.tests.util.Util.delete(libDir); > } > this.deleteProject("P"); > JavaCore.removeClasspathVariable("MyVar", null); >@@ -880,13 +874,7 @@ > assertEquals("unexpected root raw entry:", classpath[0], rawEntry); // ensure first entry is associated to the root > } finally { > if (libDir != null) { >- String[] libJars = libDir.list(); >- if (libJars != null) { >- for (int i = 0, length = libJars.length; i < length; i++) { >- new File(libDir, libJars[i]).delete(); >- } >- } >- libDir.delete(); >+ org.eclipse.jdt.core.tests.util.Util.delete(libDir); > } > this.deleteProject("P"); > JavaCore.removeClasspathVariable("MyVar", null); >Index: src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java,v >retrieving revision 1.46.2.1 >diff -u -r1.46.2.1 TypeHierarchyTests.java >--- src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java 22 Sep 2005 20:31:46 -0000 1.46.2.1 >+++ src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java 2 Apr 2007 15:43:32 -0000 >@@ -380,9 +380,9 @@ > ); > } finally { > if (externalJar1 != null) >- new File(externalJar1).delete(); >+ Util.delete(externalJar1); > if (externalJar2 != null) >- new File(externalJar2).delete(); >+ Util.delete(externalJar2); > deleteProject("P"); > } > } >Index: src/org/eclipse/jdt/core/tests/model/JavaSearchTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchTests.java,v >retrieving revision 1.140 >diff -u -r1.140 JavaSearchTests.java >--- src/org/eclipse/jdt/core/tests/model/JavaSearchTests.java 7 May 2005 17:04:02 -0000 1.140 >+++ src/org/eclipse/jdt/core/tests/model/JavaSearchTests.java 2 Apr 2007 15:43:32 -0000 >@@ -20,6 +20,7 @@ > import org.eclipse.core.runtime.*; > import org.eclipse.jdt.core.*; > import org.eclipse.jdt.core.search.*; >+import org.eclipse.jdt.core.tests.util.Util; > import org.eclipse.jdt.internal.core.JavaModelStatus; > > /** >@@ -2020,7 +2021,7 @@ > this.resultCollector); > > } finally { >- externalJar.delete(); >+ Util.delete(externalJar); > project.setRawClasspath(classpath, null); > } > >Index: src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java,v >retrieving revision 1.141 >diff -u -r1.141 AbstractJavaModelTests.java >--- src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java 8 Jun 2005 09:03:20 -0000 1.141 >+++ src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java 2 Apr 2007 15:43:31 -0000 >@@ -979,29 +979,12 @@ > return project; > } > public void deleteFile(File file) { >- file = file.getAbsoluteFile(); >- if (!file.exists()) >- return; >- if (file.isDirectory()) { >- String[] files = file.list(); >- //file.list() can return null >- if (files != null) { >- for (int i = 0; i < files.length; ++i) { >- deleteFile(new File(file, files[i])); >- } >- } >- } >- boolean success = file.delete(); >- int retryCount = 60; // wait 1 minute at most >- while (!success && --retryCount >= 0) { >- try { >- Thread.sleep(1000); >- } catch (InterruptedException e) { >+ int retryCount = 0; >+ while (++retryCount <= 60) { // wait 1 minute at most >+ if (org.eclipse.jdt.core.tests.util.Util.delete(file)) { >+ break; > } >- success = file.delete(); > } >- if (success) return; >- System.err.println("Failed to delete " + file.getPath()); > } > protected void deleteFolder(IPath folderPath) throws CoreException { > deleteResource(getFolder(folderPath));
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 166977
:
55152
|
55199
|
55967
|
55972
|
62475
| 62679