1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

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

more heuristics
This commit is contained in:
Andrew Gvozdev 2009-10-11 04:47:24 +00:00
parent 344430ef99
commit 33038927b7

View file

@ -459,9 +459,10 @@ public class ManagedBuildTestHelper {
* @return {@code true} if matches, {@code false} otherwise * @return {@code true} if matches, {@code false} otherwise
*/ */
private static boolean compareMakefiles(IPath testFile, IPath benchmarkFile) { private static boolean compareMakefiles(IPath testFile, IPath benchmarkFile) {
final String ECHO_LINKER_PATTERN = " @echo 'Invoking: .* C\\+\\+ Linker'"; 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* :=.*";
ArrayList<String> testArray = getContents(testFile); ArrayList<String> testArray = getContents(testFile);
ArrayList<String> benchmarkArray = getContents(benchmarkFile); ArrayList<String> benchmarkArray = getContents(benchmarkFile);
if (testArray.size()!=benchmarkArray.size()) { if (testArray.size()!=benchmarkArray.size()) {
@ -488,7 +489,7 @@ public class ManagedBuildTestHelper {
return false; return false;
} }
} }
} else if (testLine.matches(ECHO_LINKER_PATTERN) && benchmarkLine.matches(ECHO_LINKER_PATTERN)) { } else if (testLine.matches(ECHO_INVOKING_PATTERN) && benchmarkLine.matches(ECHO_INVOKING_PATTERN)) {
// accommodate for variable linker name (GCC vs. Cygwin) // accommodate for variable linker name (GCC vs. Cygwin)
continue; continue;
} else if (testLine.matches(IFNEQ_PATTERN) && benchmarkLine.matches(IFNEQ_PATTERN)) { } else if (testLine.matches(IFNEQ_PATTERN) && benchmarkLine.matches(IFNEQ_PATTERN)) {
@ -502,23 +503,30 @@ public class ManagedBuildTestHelper {
// accommodate for variable order of different macro's blocks (see IFNEQ_PATTERN) // accommodate for variable order of different macro's blocks (see IFNEQ_PATTERN)
testNotMatchingLines.add(testLine); testNotMatchingLines.add(testLine);
benchNotMatchingLines.add(benchmarkLine); benchNotMatchingLines.add(benchmarkLine);
} else if (testLine.matches(MACRO_PATTERN) && benchmarkLine.matches(MACRO_PATTERN)) {
// accommodate for variable order of macros
testNotMatchingLines.add(testLine);
benchNotMatchingLines.add(benchmarkLine);
} else { } else {
System.out.println("Following lines do not match:"); System.out.println("Following lines do not match ("+testFile.lastSegment()+"):");
System.out.println("actual : ["+testLine+"]"); System.out.println("actual : ["+testLine+"], file "+testFile);
System.out.println("expected: ["+benchmarkLine+"]"); System.out.println("expected: ["+benchmarkLine+"], file "+benchmarkFile);
return false; return false;
} }
} }
} }
// Check if all lines of ifneq blocks match (irrespective of order) // Check if all collected lines match irrespective of order
String[] testNotMatchingLinesArray = testNotMatchingLines.toArray(new String[0]); String[] testNotMatchingLinesArray = testNotMatchingLines.toArray(new String[0]);
String[] benchNotMatchingLinesArray = benchNotMatchingLines.toArray(new String[0]); String[] benchNotMatchingLinesArray = benchNotMatchingLines.toArray(new String[0]);
for (int i=0;i<testNotMatchingLinesArray.length;i++) { for (int i=0;i<testNotMatchingLinesArray.length;i++) {
if (! testNotMatchingLinesArray[i].equals(benchNotMatchingLinesArray[i])) { if (! testNotMatchingLinesArray[i].equals(benchNotMatchingLinesArray[i])) {
System.out.println("Following sorted lines do not match:"); System.out.println("Following line is missing ("+testFile.lastSegment()+"):");
System.out.println("actual : ["+testNotMatchingLinesArray[i]+"]"); if (testNotMatchingLinesArray[i].compareTo(benchNotMatchingLinesArray[i]) < 0) {
System.out.println("expected: ["+benchNotMatchingLinesArray[i]+"]"); System.out.println("line ["+testNotMatchingLinesArray[i]+"], missing in file "+benchmarkFile);
} else {
System.out.println("line ["+benchNotMatchingLinesArray[i]+"], missing in file "+testFile);
}
return false; return false;
} }
} }