1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 22:52:11 +02:00

bug 212596: JUnit failures in cdt.managedbuilder.test.suite

Changes to be able to handle MACRO += syntax with trailing backslash
This commit is contained in:
Andrew Gvozdev 2009-10-26 01:49:15 +00:00
parent 4cd1523cc1
commit 57ba53ae39

View file

@ -20,6 +20,7 @@ import java.io.InputStream;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.TreeSet; 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.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.ui.dialogs.IOverwriteQuery; import org.eclipse.ui.dialogs.IOverwriteQuery;
import org.eclipse.ui.wizards.datatransfer.ImportOperation; import org.eclipse.ui.wizards.datatransfer.ImportOperation;
import org.eclipse.ui.wizards.datatransfer.ZipFileStructureProvider; import org.eclipse.ui.wizards.datatransfer.ZipFileStructureProvider;
@ -121,6 +123,17 @@ public class ManagedBuildTestHelper {
// Open the project if we have to // Open the project if we have to
if (!project.isOpen()) { if (!project.isOpen()) {
project.open(new NullProgressMonitor()); 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; return project;
@ -462,10 +475,10 @@ public class ManagedBuildTestHelper {
final String ECHO_INVOKING_PATTERN = " @echo 'Invoking: .* C\\+\\+ .*'"; final String ECHO_INVOKING_PATTERN = " @echo 'Invoking: .* C\\+\\+ .*'";
final String IFNEQ_PATTERN = "ifneq \\(\\$\\(strip \\$\\(.*\\)\\),\\)"; final String IFNEQ_PATTERN = "ifneq \\(\\$\\(strip \\$\\(.*\\)\\),\\)";
final String INCLUDE_PATTERN = "-include \\$\\(.*\\)"; final String INCLUDE_PATTERN = "-include \\$\\(.*\\)";
final String MACRO_PATTERN = "\\S* :=.*"; final String MACRO_PATTERN = "\\S* [:+]=.*";
final String EMPTY_MACRO_PATTERN = "\\S* :="; final String EMPTY_MACRO_PATTERN = "\\S* :=";
ArrayList<String> testArray = getContents(testFile); ArrayList<String> testArray = mergeContinuationLines(getContents(testFile));
ArrayList<String> benchmarkArray = getContents(benchmarkFile); ArrayList<String> benchmarkArray = mergeContinuationLines(getContents(benchmarkFile));
Set<String> testNotMatchingLines = new TreeSet<String>(); Set<String> testNotMatchingLines = new TreeSet<String>();
Set<String> benchNotMatchingLines = new TreeSet<String>(); Set<String> benchNotMatchingLines = new TreeSet<String>();
@ -571,6 +584,20 @@ public class ManagedBuildTestHelper {
} }
return lines; return lines;
} }
private static ArrayList<String> mergeContinuationLines(ArrayList<String> lines) {
for (int i=0;i<lines.size();) {
String line = lines.get(i);
if (line.endsWith("\\") && i+1<lines.size()) {
lines.set(i, line.substring(0, line.length()-1)+lines.get(i+1));
lines.remove(i+1);
// do not advance i and check the renewed line again
continue;
}
i++;
}
return lines;
}
static public boolean compareBenchmarks(final IProject project, IPath testDir, String[] fileNames) { static public boolean compareBenchmarks(final IProject project, IPath testDir, String[] fileNames) {
return compareBenchmarks(project, testDir, new Path("benchmarks").append(testDir), fileNames); return compareBenchmarks(project, testDir, new Path("benchmarks").append(testDir), fileNames);
@ -728,51 +755,64 @@ public class ManagedBuildTestHelper {
Assert.fail("Temporary directory " + tmpSrcDirFile.toString() + " already exists."); Assert.fail("Temporary directory " + tmpSrcDirFile.toString() + " already exists.");
} }
} }
boolean succeed = tmpSrcDirFile.mkdir(); tmpSrcDirFile.mkdir();
if (succeed) { if (!tmpSrcDirFile.exists()) {
for (int i=0; i<files.length; i++) { Assert.fail("Can't create temporary directory " + tmpSrcDirFile.toString());
IPath file = files[i]; }
IPath srcFile = srcDir.append(file); for (int i=0; i<files.length; i++) {
FileReader srcReader = null; IPath file = files[i];
try { IPath srcFile = srcDir.append(file);
srcReader = new FileReader(srcFile.toFile()); FileReader srcReader = null;
} catch (Exception e) { try {
Assert.fail("File " + file.toString() + " could not be read."); srcReader = new FileReader(srcFile.toFile());
return null; } catch (Exception e) {
} Assert.fail("File " + file.toString() + " could not be read.");
if (file.segmentCount() > 1) { return null;
IPath newDir = tmpSrcDir; }
do { if (file.segmentCount() > 1) {
IPath dir = file.uptoSegment(1); IPath newDir = tmpSrcDir;
newDir = newDir.append(dir); do {
file = file.removeFirstSegments(1); IPath dir = file.uptoSegment(1);
succeed = newDir.toFile().mkdir(); newDir = newDir.append(dir);
} while (file.segmentCount() > 1); file = file.removeFirstSegments(1);
} newDir.toFile().mkdir();
IPath destFile = tmpSrcDir.append(files[i]); if (!newDir.toFile().exists()) {
FileWriter writer = null; Assert.fail("Can't create temporary directory " + tmpSrcDirFile.toString());
try { }
writer = new FileWriter(destFile.toFile()); } while (file.segmentCount() > 1);
} catch (Exception e) { }
Assert.fail("File " + files[i].toString() + " could not be written."); IPath destFile = tmpSrcDir.append(files[i]);
return null; FileWriter writer = null;
} try {
try { writer = new FileWriter(destFile.toFile());
int c; } catch (Exception e) {
do { Assert.fail("File " + files[i].toString() + " could not be written.");
c = srcReader.read(); return null;
if (c == -1) break; }
writer.write(c); try {
} while (c != -1); int c;
srcReader.close(); do {
writer.close(); c = srcReader.read();
} catch (Exception e) { if (c == -1) break;
Assert.fail("File " + file.toString() + " could not be copied."); 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; return tmpSrcDir;
} }