Skip to content

Commit

Permalink
Merge pull request #23 from nwinkler/excerpt-start-end
Browse files Browse the repository at this point in the history
Fix the Build Log Excerpt Macro Start/End Order
  • Loading branch information
slide authored Sep 10, 2016
2 parents bd60183 + bd5947b commit d02c055
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,12 @@ String getContent(BufferedReader reader) throws IOException {
started = true;
continue;
}
if (endPattern.matcher(line).matches()) break;

if (started) buffer.append(line).append('\n');
if (started) {
if (endPattern.matcher(line).matches()) break;

buffer.append(line).append('\n');
}
}
return buffer.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,19 @@ public void testGetContent_regexpStartEndTags()

assertEquals("7\n8\n9\n", result);
}

@Test
public void testGetContent_regexpStartEndTagsEndBeforeStart()
throws Exception {
AbstractBuild build = mock(AbstractBuild.class);
when(build.getLogReader()).thenReturn(new StringReader("1\n2\nSTOP3\n4\n5\nTEST STARTED\n7\n8\n9\nTEST STOPED\n10\n11\n12\n"));

buildLogExcerptMacro.start = ".*START.*";
buildLogExcerptMacro.end = ".*STOP.*";

final String result = buildLogExcerptMacro.evaluate(build, listener, BuildLogExcerptMacro.MACRO_NAME);

assertEquals("7\n8\n9\n", result);
}
}

0 comments on commit d02c055

Please sign in to comment.