Source:
private ImmutableList<TestResultSummary> parseTestResults() throws IOException { ImmutableList.Builder<TestResultSummary> summariesBuilder = ImmutableList.builder(); try (BufferedReader reader = Files.newBufferedReader( getProjectFilesystem().resolve(getPathToTestResults()), Charsets.UTF_8)) { Set<String> currentTests = new HashSet<>(); List<String> stdout = new ArrayList<>(); String line; while ((line = reader.readLine()) != null) { Matcher matcher; if ((matcher = TEST_START_PATTERN.matcher(line)).matches()) { currentTests.add(matcher.group("name")); } else if ((matcher = TEST_FINISHED_PATTERN.matcher(line)).matches()) { if (!currentTests.contains(matcher.group("name"))) { throw new RuntimeException( String.format( "Error parsing test output: test case end '%s' does not match any start in [%s]", matcher.group("name"), Joiner.on(", ").join(currentTests))); } ResultType result = ResultType.FAILURE; if ("PASS".equals(matcher.group("status"))) { result = ResultType.SUCCESS; } else if ("SKIP".equals(matcher.group("status"))) { result = ResultType.ASSUMPTION_VIOLATION; } double timeTaken = 0.0; try { timeTaken = Float.parseFloat(matcher.group("duration")); } catch (NumberFormatException ex) { Throwables.throwIfUnchecked(ex); } summariesBuilder.add( new TestResultSummary( "go_test", matcher.group("name"), result, (long) (timeTaken * 1000), "", "", Joiner.on(System.lineSeparator()).join(stdout), "")); currentTests.remove(matcher.group("name")); stdout.clear(); } else { stdout.add(line); } } for (String t : currentTests) { summariesBuilder.add( new TestResultSummary( "go_test", t, ResultType.FAILURE, 0, "incomplete", "", Joiner.on(System.lineSeparator()).join(stdout), "")); } } return summariesBuilder.build(); }

Target:
private ImmutableList<TestResultSummary> parseTestResults() throws IOException { ImmutableList.Builder<TestResultSummary> summariesBuilder = ImmutableList.builder(); try (BufferedReader reader = Files.newBufferedReader( getProjectFilesystem().resolve(getPathToTestResults()), Charsets.UTF_8)) { Set<String> currentTests = new HashSet<>(); List<String> stdout = new ArrayList<>(); String line; while ((line = reader.readLine()) != null) { Matcher matcher; if ((matcher = TEST_START_PATTERN.matcher(line)).matches()) { currentTests.add(matcher.group("name")); } else if ((matcher = TEST_FINISHED_PATTERN.matcher(line)).matches()) { if (!currentTests.contains(matcher.group("name"))) { throw new RuntimeException( String.format( "Error parsing test output: test case end '%s' does not match any start in [%s]", matcher.group("name"), Joiner.on(", ").join(currentTests))); } ResultType result = ResultType.FAILURE; if ("PASS".equals(matcher.group("status"))) { result = ResultType.SUCCESS; } else if ("SKIP".equals(matcher.group("status"))) { result = ResultType.ASSUMPTION_VIOLATION; } double timeTaken = 0.0; try { timeTaken = Float.parseFloat(matcher.group("duration")); } catch (NumberFormatException ex) { Throwables.throwIfUnchecked(ex); } summariesBuilder.add( new TestResultSummary( "go_test", matcher.group("name"), result, (long) (timeTaken * 1000), "", "", Joiner.on(System.lineSeparator()).join(stdout), "")); currentTests.remove(matcher.group("name")); stdout.clear(); } else { stdout.add(line); } } for (String testName : currentTests) { summariesBuilder.add( new TestResultSummary( "go_test", testName, ResultType.FAILURE, 0, "incomplete", "", Joiner.on(System.lineSeparator()).join(stdout), "")); } } return summariesBuilder.build(); }