From 57ba53ae396c7b0d7b9cc4718fbcc84c364a91a7 Mon Sep 17 00:00:00 2001 From: Andrew Gvozdev Date: Mon, 26 Oct 2009 01:49:15 +0000 Subject: [PATCH] bug 212596: JUnit failures in cdt.managedbuilder.test.suite Changes to be able to handle MACRO += syntax with trailing backslash --- .../testplugin/ManagedBuildTestHelper.java | 128 ++++++++++++------ 1 file changed, 84 insertions(+), 44 deletions(-) diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/suite/org/eclipse/cdt/managedbuilder/testplugin/ManagedBuildTestHelper.java b/build/org.eclipse.cdt.managedbuilder.core.tests/suite/org/eclipse/cdt/managedbuilder/testplugin/ManagedBuildTestHelper.java index 7b498a84bb6..c632f0b9664 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/suite/org/eclipse/cdt/managedbuilder/testplugin/ManagedBuildTestHelper.java +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/suite/org/eclipse/cdt/managedbuilder/testplugin/ManagedBuildTestHelper.java @@ -20,6 +20,7 @@ import java.io.InputStream; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.Arrays; +import java.util.Iterator; import java.util.List; import java.util.Set; import java.util.TreeSet; @@ -63,6 +64,7 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.jobs.Job; import org.eclipse.ui.dialogs.IOverwriteQuery; import org.eclipse.ui.wizards.datatransfer.ImportOperation; import org.eclipse.ui.wizards.datatransfer.ZipFileStructureProvider; @@ -121,6 +123,17 @@ public class ManagedBuildTestHelper { // Open the project if we have to if (!project.isOpen()) { project.open(new NullProgressMonitor()); + // CDT opens the Project with BACKGROUND_REFRESH enabled which causes the + // refresh manager to refresh the project 200ms later. This Job interferes + // with the resource change handler firing see: bug 271264 + try { + // CDT opens the Project with BACKGROUND_REFRESH enabled which causes the + // refresh manager to refresh the project 200ms later. This Job interferes + // with the resource change handler firing see: bug 271264 + Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_REFRESH, null); + } catch (Exception e) { + // Ignore + } } return project; @@ -462,10 +475,10 @@ public class ManagedBuildTestHelper { final String ECHO_INVOKING_PATTERN = " @echo 'Invoking: .* C\\+\\+ .*'"; final String IFNEQ_PATTERN = "ifneq \\(\\$\\(strip \\$\\(.*\\)\\),\\)"; final String INCLUDE_PATTERN = "-include \\$\\(.*\\)"; - final String MACRO_PATTERN = "\\S* :=.*"; + final String MACRO_PATTERN = "\\S* [:+]=.*"; final String EMPTY_MACRO_PATTERN = "\\S* :="; - ArrayList testArray = getContents(testFile); - ArrayList benchmarkArray = getContents(benchmarkFile); + ArrayList testArray = mergeContinuationLines(getContents(testFile)); + ArrayList benchmarkArray = mergeContinuationLines(getContents(benchmarkFile)); Set testNotMatchingLines = new TreeSet(); Set benchNotMatchingLines = new TreeSet(); @@ -571,6 +584,20 @@ public class ManagedBuildTestHelper { } return lines; } + + private static ArrayList mergeContinuationLines(ArrayList lines) { + for (int i=0;i 1) { - IPath newDir = tmpSrcDir; - do { - IPath dir = file.uptoSegment(1); - newDir = newDir.append(dir); - file = file.removeFirstSegments(1); - succeed = newDir.toFile().mkdir(); - } while (file.segmentCount() > 1); - } - IPath destFile = tmpSrcDir.append(files[i]); - FileWriter writer = null; - try { - writer = new FileWriter(destFile.toFile()); - } catch (Exception e) { - Assert.fail("File " + files[i].toString() + " could not be written."); - return null; - } - try { - int c; - do { - c = srcReader.read(); - if (c == -1) break; - writer.write(c); - } while (c != -1); - srcReader.close(); - writer.close(); - } catch (Exception e) { - Assert.fail("File " + file.toString() + " could not be copied."); - } + tmpSrcDirFile.mkdir(); + if (!tmpSrcDirFile.exists()) { + Assert.fail("Can't create temporary directory " + tmpSrcDirFile.toString()); + } + for (int i=0; i 1) { + IPath newDir = tmpSrcDir; + do { + IPath dir = file.uptoSegment(1); + newDir = newDir.append(dir); + file = file.removeFirstSegments(1); + newDir.toFile().mkdir(); + if (!newDir.toFile().exists()) { + Assert.fail("Can't create temporary directory " + tmpSrcDirFile.toString()); + } + } while (file.segmentCount() > 1); + } + IPath destFile = tmpSrcDir.append(files[i]); + FileWriter writer = null; + try { + writer = new FileWriter(destFile.toFile()); + } catch (Exception e) { + Assert.fail("File " + files[i].toString() + " could not be written."); + return null; + } + try { + int c; + do { + c = srcReader.read(); + if (c == -1) break; + writer.write(c); + } while (c != -1); + srcReader.close(); + writer.close(); + } catch (Exception e) { + Assert.fail("File " + file.toString() + " could not be copied."); } } } } + IWorkspace workspace = ResourcesPlugin.getWorkspace(); + IWorkspaceRoot root = workspace.getRoot(); + for (IFile rc : root.findFilesForLocation(tmpSrcDir)) { + try { + rc.refreshLocal(IFile.DEPTH_INFINITE, null); + } catch (CoreException e) { + // ignore exception + } + } return tmpSrcDir; }