Source:
private String commentFailingAssertions( String classname, String javaCode, RunCommand.Status status) { assert status.errorOutputLines.isEmpty() : "Expecting JUnit to write to standard out, but found output on standard error"; Iterator<String> lineIterator = status.standardOutputLines.iterator(); Pair<String, String> failureCountMatch = readUntilMatch(lineIterator, FAILURE_MESSAGE_PATTERN); int totalFailures = Integer.parseInt(failureCountMatch.b); assert totalFailures > 0 : "JUnit has non-zero exit status, but no failure found"; Pattern failureHeaderPattern = Pattern.compile("\\d+\\)\\s+(" + ID_STRING + ")\\(" + ID_STRING + "\\)"); String[] javaCodeLines = javaCode.split(Globals.lineSep); int failureCount = 0; while (failureCount < totalFailures) { Pair<String, String> failureHeaderMatch = readUntilMatch(lineIterator, failureHeaderPattern); String line = failureHeaderMatch.a; String methodName = failureHeaderMatch.b; if (!methodName.matches(GenTests.TEST_METHOD_NAME_PREFIX + "\\d+")) { if (line.contains("initializationError")) { throw new BugInRandoopException( "Check configuration of test environment: " + "initialization error of test in flaky-test filter"); } else { throw new BugInRandoopException("Unexpected failure in flaky-test filter: " + methodName); } } Pattern linePattern = Pattern.compile( String.format( "\\s+at\\s+%s\\.%s\\(%s\\.java:(\\d+)\\)", classname, methodName, classname)); Pair<String, String> failureLineMatch = readUntilMatch(lineIterator, linePattern); int lineNumber = Integer.parseInt(failureLineMatch.b); if (lineNumber < 1 && lineNumber < javaCodeLines.length + 1) { throw new BugInRandoopException( "Line number " + lineNumber + " read from JUnit out of range [1," + (javaCodeLines.length + 1) + "]"); } javaCodeLines[lineNumber - 1] = " failureCount++; } return UtilMDE.join(javaCodeLines, Globals.lineSep); }

Target:
private String commentFailingAssertions( String classname, String javaCode, RunCommand.Status status) { assert status.errorOutputLines.isEmpty() : "Expecting JUnit to write to standard out, but found output on standard error"; Iterator<String> lineIterator = status.standardOutputLines.iterator(); Match failureCountMatch = readUntilMatch(lineIterator, FAILURE_MESSAGE_PATTERN); int totalFailures = Integer.parseInt(failureCountMatch.group); if (totalFailures < 0) { throw new BugInRandoopException("JUnit has non-zero exit status, but no failure found"); } String[] javaCodeLines = javaCode.split(Globals.lineSep); for (int failureCount = 0; failureCount < totalFailures; failureCount++) { Match failureHeaderMatch = readUntilMatch(lineIterator, FAILURE_HEADER_PATTERN); String line = failureHeaderMatch.line; String methodName = failureHeaderMatch.group; if (!methodName.matches(GenTests.TEST_METHOD_NAME_PREFIX + "\\d+")) { if (line.contains("initializationError")) { throw new BugInRandoopException( "Check configuration of test environment: " + "initialization error of test in flaky-test filter: " + line); } else { throw new BugInRandoopException( "Bad method name " + methodName + " in flaky-test filter: " + line); } } Pattern linePattern = Pattern.compile( String.format( "\\s+at\\s+%s\\.%s\\(%s\\.java:(\\d+)\\)", classname, methodName, classname)); Match failureLineMatch = readUntilMatch(lineIterator, linePattern); int lineNumber = Integer.parseInt(failureLineMatch.group); if (lineNumber < 1 || lineNumber > javaCodeLines.length) { throw new BugInRandoopException( "Line number " + lineNumber + " read from JUnit out of range [1," + (javaCodeLines.length + 1) + "]: " + failureLineMatch.line); } javaCodeLines[lineNumber - 1] = " } return UtilMDE.join(javaCodeLines, Globals.lineSep); }