Skip to content
Snippets Groups Projects
Commit 9ed877f4 authored by Florian Angerer's avatar Florian Angerer
Browse files

Added test traits to ignore some unimportant differences in the debugger's output.

parent 1b3c812e
Branches
No related tags found
No related merge requests found
......@@ -77,7 +77,10 @@ public class TestBase {
MayIgnoreWarningContext,
ContainsReferences, // replaces references in form of 0xbcdef1 for numbers
IgnoreWhitespace, // removes all whitespace from the whole output
IgnoreCase; // ignores upper/lower case differences
IgnoreCase, // ignores upper/lower case differences
IgnoreDebugPath, // ignores <path> in debug output like "debug at <path> #..."
IgnoreDebugDepth, // ignores call depth printed by the debugger ("Browse[<call depth>]")
IgnoreDebugExitFrom; // ignores the debugger's "exiting from ..."
@Override
public String getName() {
......@@ -608,6 +611,15 @@ public class TestBase {
if (output.contains(Output.ContainsReferences)) {
return convertReferencesInOutput(out);
}
if (output.contains(Output.IgnoreDebugPath)) {
return convertDebugOutput(out);
}
if (output.contains(Output.IgnoreDebugExitFrom)) {
return removeExitingFrom(out);
}
if (output.contains(Output.IgnoreDebugDepth)) {
return removeDebugCallDepth(out);
}
return out;
}
}
......@@ -731,6 +743,33 @@ public class TestBase {
return result;
}
private static String convertDebugOutput(String out) {
String prefix = "debug at ";
return removeAllOccurrencesBetween(out, prefix, prefix.length(), "#", 0);
}
private static String removeExitingFrom(String out) {
return removeAllOccurrencesBetween(out, "exiting from:", 0, "\n", 1);
}
private static String removeDebugCallDepth(String out) {
String prefix = "Browse[";
return removeAllOccurrencesBetween(out, prefix, prefix.length(), "]", 0);
}
private static String removeAllOccurrencesBetween(String out, String prefix, int prefixOffset, String suffix, int suffixOffset) {
StringBuilder sb = new StringBuilder(out);
int idxPrefix = -1;
int idxSuffix = -1;
while ((idxPrefix = sb.indexOf(prefix, idxPrefix + 1)) > 0 && (idxSuffix = sb.indexOf(suffix, idxPrefix)) > idxPrefix) {
sb.replace(idxPrefix + prefixOffset, idxSuffix + suffixOffset, "");
}
return sb.toString();
}
private boolean searchWhiteLists(WhiteList[] whiteLists, String input, String expected, String result, TestTraitsSet testTraits) {
if (whiteLists == null) {
return false;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment