Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Gvozdev2009-10-10 03:21:40 +0000
committerAndrew Gvozdev2009-10-10 03:21:40 +0000
commit0c776079d1fb46fe1a61e3256399988748c30988 (patch)
treecbfb4d2475cc79c683c8479e71d8ad690e05effd /build/org.eclipse.cdt.managedbuilder.core.tests
parenta6da33292e76f239d74a4442f86baf8166a87c5f (diff)
downloadorg.eclipse.cdt-0c776079d1fb46fe1a61e3256399988748c30988.tar.gz
org.eclipse.cdt-0c776079d1fb46fe1a61e3256399988748c30988.tar.xz
org.eclipse.cdt-0c776079d1fb46fe1a61e3256399988748c30988.zip
bug 212596: JUnit failures in cdt.managedbuilder.test.suite
More heuristics added to makefile compare algorithm
Diffstat (limited to 'build/org.eclipse.cdt.managedbuilder.core.tests')
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core.tests/suite/org/eclipse/cdt/managedbuilder/testplugin/ManagedBuildTestHelper.java48
1 files changed, 46 insertions, 2 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 7a2bc38fdd4..1c167c45146 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
@@ -21,6 +21,7 @@ import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.util.Set;
import java.util.TreeSet;
import java.util.zip.ZipFile;
@@ -450,17 +451,32 @@ public class ManagedBuildTestHelper {
return ext.equals("mk");
}
+ /**
+ * Compare makefiles using a bunch of heuristics to avoid ordering mismatches
+ *
+ * @param testFile - location of actual makefile
+ * @param benchmarkFile - location of the benchmark file
+ * @return {@code true} if matches, {@code false} otherwise
+ */
private static boolean compareMakefiles(IPath testFile, IPath benchmarkFile) {
+ final String ECHO_LINKER_PATTERN = " @echo 'Invoking: .* C\\+\\+ Linker'";
+ final String IFNEQ_PATTERN = "ifneq \\(\\$\\(strip \\$\\(.*\\)\\),\\)";
+ final String INCLUDE_PATTERN = "-include \\$\\(.*\\)";
ArrayList<String> testArray = getContents(testFile);
ArrayList<String> benchmarkArray = getContents(benchmarkFile);
- if (testArray.size()!=benchmarkArray.size())
+ if (testArray.size()!=benchmarkArray.size()) {
+ System.out.println("testArray.size="+testArray.size()+ " while benchmarkArray.size="+benchmarkArray.size());
return false;
+ }
+ Set<String> testNotMatchingLines = new TreeSet<String>();
+ Set<String> benchNotMatchingLines = new TreeSet<String>();
for (int i=0;i<benchmarkArray.size();i++) {
String testLine = testArray.get(i);
String benchmarkLine = benchmarkArray.get(i);
if (!testLine.equals(benchmarkLine)) {
if (testLine.startsWith(" -$(RM) ")) {
+ // accommodate to arbitrary order of 'rm' parameters
final String DELIMITERS = "[ $]";
String[] testMacros = new TreeSet<String>(Arrays.asList(testLine.split(DELIMITERS))).toArray(new String[0]);
String[] benchMacros = new TreeSet<String>(Arrays.asList(benchmarkLine.split(DELIMITERS))).toArray(new String[0]);
@@ -472,12 +488,40 @@ public class ManagedBuildTestHelper {
return false;
}
}
- return true;
+ } else if (testLine.matches(ECHO_LINKER_PATTERN) && benchmarkLine.matches(ECHO_LINKER_PATTERN)) {
+ // accommodate for variable linker name (GCC vs. Cygwin)
+ continue;
+ } else if (testLine.matches(IFNEQ_PATTERN) && benchmarkLine.matches(IFNEQ_PATTERN)) {
+ // accommodate for variable order of different macro's blocks (see also INCLUDE_PATTERN)
+ // ifneq ($(strip $(CXX_DEPS)),)
+ // -include $(CXX_DEPS)
+ // endif
+ testNotMatchingLines.add(testLine);
+ benchNotMatchingLines.add(benchmarkLine);
+ } else if (testLine.matches(INCLUDE_PATTERN) && benchmarkLine.matches(INCLUDE_PATTERN)) {
+ // accommodate for variable order of different macro's blocks (see IFNEQ_PATTERN)
+ testNotMatchingLines.add(testLine);
+ benchNotMatchingLines.add(benchmarkLine);
} else {
+ System.out.println("Following lines do not match:");
+ System.out.println("actual : ["+testLine+"]");
+ System.out.println("expected: ["+benchmarkLine+"]");
return false;
}
}
}
+
+ // Check if all lines of ifneq blocks match (irrespective of order)
+ String[] testNotMatchingLinesArray = testNotMatchingLines.toArray(new String[0]);
+ String[] benchNotMatchingLinesArray = benchNotMatchingLines.toArray(new String[0]);
+ for (int i=0;i<testNotMatchingLinesArray.length;i++) {
+ if (! testNotMatchingLinesArray[i].equals(benchNotMatchingLinesArray[i])) {
+ System.out.println("Following sorted lines do not match:");
+ System.out.println("actual : ["+testNotMatchingLinesArray[i]+"]");
+ System.out.println("expected: ["+benchNotMatchingLinesArray[i]+"]");
+ return false;
+ }
+ }
return true;
}

Back to the top