Skip to content

Commit

Permalink
pipeline and pipeline agent tests for multiple finders
Browse files Browse the repository at this point in the history
  • Loading branch information
sparkoo committed Apr 11, 2019
1 parent ba2ecf1 commit abc4cf2
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,25 @@ public void failureIfFoundInConsoleOnAgent() throws Exception {
assertLogContainsMatch(build.getLogFile(), ECHO_UNIQUE_TEXT, build, true);
rule.assertBuildStatus(Result.FAILURE, build);
}

@Test
public void lastFinderWins() throws Exception {
DumbSlave agent = rule.createOnlineSlave();
WorkflowJob project = rule.createProject(WorkflowJob.class, "pipeline");
project.setDefinition(
new CpsFlowDefinition(
String.format(
"node('%s') {isUnix() ? sh('echo foobar') : bat(\"prompt \\$G\\r\\necho foobar\")}\n"
+ "node('%s') {findText regexp: 'foobar', alsoCheckConsoleOutput: true, "
+ "textFinders: ["
+ "finder(regexp: 'foobar', unstableIfFound: true, alsoCheckConsoleOutput: true),"
+ "finder(regexp: 'foobar', notBuiltIfFound: true, alsoCheckConsoleOutput: true)"
+ "]}",
agent.getNodeName(), agent.getNodeName())));
WorkflowRun build = project.scheduleBuild2(0).get();
rule.waitForCompletion(build);
rule.assertLogContains("Checking console output", build);
assertLogContainsMatch(build.getLogFile(), ECHO_UNIQUE_TEXT, build, true);
rule.assertBuildStatus(Result.NOT_BUILT, build);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -185,4 +185,22 @@ public void notFoundInConsole() throws Exception {
rule.assertLogContains("Checking console output", build);
rule.assertBuildStatus(Result.SUCCESS, build);
}

@Test
public void lastFinderWins() throws Exception {
WorkflowJob project = rule.createProject(WorkflowJob.class, "pipeline");
project.setDefinition(
new CpsFlowDefinition(
"node {isUnix() ? sh('echo foobar') : bat(\"prompt \\$G\\r\\necho foobar\")}\n"
+ "node {findText regexp: 'foobar', alsoCheckConsoleOutput: true, "
+ "textFinders: ["
+ "finder(regexp: 'foobar', unstableIfFound: true, alsoCheckConsoleOutput: true),"
+ "finder(regexp: 'foobar', notBuiltIfFound: true, alsoCheckConsoleOutput: true)"
+ "]}"));
WorkflowRun build = project.scheduleBuild2(0).get();
rule.waitForCompletion(build);
rule.assertLogContains("Checking console output", build);
assertLogContainsMatch(build.getLogFile(), ECHO_UNIQUE_TEXT, build, true);
rule.assertBuildStatus(Result.NOT_BUILT, build);
}
}

0 comments on commit abc4cf2

Please sign in to comment.