use of org.jenkinsci.test.acceptance.po.FreeStyleJob in project acceptance-test-harness by jenkinsci.
the class WarningsPluginTest method should_override_tab_name_with_groovy_parser.
/**
* Checks that a dynamic Groovy parser can override package tab title.
*/
@Test
@WithPlugins("analysis-core@1.91")
public void should_override_tab_name_with_groovy_parser() {
String parserName = createParser(OVERRIDE_PARSER_SCRIPT);
FreeStyleJob job = createFreeStyleJob(RESOURCES + GROOVY_TWO_LINES_FILE_NAME, settings -> settings.addWorkspaceScanner(parserName, "**/" + GROOVY_TWO_LINES_FILE_NAME));
Build build = buildSuccessfulJob(job);
WarningsAction action = createJavaResultAction(build);
action.open();
assertThat(driver, hasContent("DEAD_A"));
assertThat(driver, hasContent("DEAD_B"));
assertThat(driver, hasContent("BEEF"));
assertThat(driver.getPageSource(), containsString("<div id=\"packages\">BEEFs</div>"));
}
use of org.jenkinsci.test.acceptance.po.FreeStyleJob in project acceptance-test-harness by jenkinsci.
the class WarningsPluginTest method should_resolve_environment_variables.
/**
* Verifies that environment variables are expanded in the file name pattern.
*/
@Test
@Issue("JENKINS-34157")
@WithPlugins("envinject")
public void should_resolve_environment_variables() {
FreeStyleJob job = createFreeStyleJob(RESOURCES + "jenkins-32150", settings -> {
settings.addWorkspaceScanner(CLANG_ID, "${ENV_PREFIX}/${PARAMETER}");
settings.addWorkspaceScanner(JAVA_TITLE, "${BUILD_NUMBER}/nothing");
settings.addWorkspaceScanner(JAVA_DOC_ID, "${BUILD_NUMBER}_${Reference}\\ND4\\ReleaseTools\\Build\\Log\\warning.log");
});
job.configure();
new EnvInjectConfig.Environment(job).properties.sendKeys("ENV_PREFIX=**");
String parameter = "PARAMETER";
job.addParameter(StringParameter.class).setName(parameter);
String reference = "Reference";
job.addParameter(StringParameter.class).setName(reference);
job.save();
Node slave = createSlaveForJob(job);
Map<String, String> parameters = new HashMap<>();
parameters.put("slavename", slave.getName());
parameters.put(parameter, "compile-log.txt");
parameters.put(reference, "master");
Build build = job.startBuild(parameters).shouldSucceed();
assertThatActionExists(job, build, "LLVM/Clang Warnings");
build.open();
int count = 10;
assertThat(driver, hasContent(CLANG_TITLE + ": " + count));
assertThat(build.getConsole(), containsString("[WARNINGS] Parsing warnings in files '**/compile-log.txt' with parser Clang (LLVM based)"));
assertThat(build.getConsole(), containsRegexp("\\[WARNINGS\\] Parsing warnings in files '[\\d]+/nothing'"));
assertThat(build.getConsole(), containsRegexp("\\[WARNINGS\\] Parsing warnings in files '[\\d]+_master\\\\ND4\\\\ReleaseTools\\\\Build\\\\Log\\\\warning.log'"));
}
use of org.jenkinsci.test.acceptance.po.FreeStyleJob in project acceptance-test-harness by jenkinsci.
the class WarningsPluginTest method should_detect_no_errors_in_console_log_and_workspace_when_there_are_none.
/**
* Checks that no warnings are reported if the build does nothing.
*/
@Test
public void should_detect_no_errors_in_console_log_and_workspace_when_there_are_none() {
FreeStyleJob job = createNoFilesFreeStyleJob(settings -> {
settings.addConsoleParser("Maven");
settings.addWorkspaceScanner(JAVA_TITLE, "**/*");
});
Build build = buildSuccessfulJob(job);
assertThatActionIsMissing(job, build, "Java Warnings");
assertThatActionIsMissing(job, build, "Maven Warnings");
build.open();
assertThat(driver, hasContent("Java Warnings: 0"));
assertThat(driver, hasContent("Maven Warnings: 0"));
}
use of org.jenkinsci.test.acceptance.po.FreeStyleJob in project acceptance-test-harness by jenkinsci.
the class WarningsPluginTest method should_scan_console_log_of_slave_build.
@Test
@WithDocker
@WithCredentials(credentialType = WithCredentials.SSH_USERNAME_PRIVATE_KEY, values = { CREDENTIALS_ID, CREDENTIALS_KEY })
@WithPlugins("ssh-slaves")
public void should_scan_console_log_of_slave_build() throws ExecutionException, InterruptedException {
DumbSlave dockerSlave = createDockerAgent();
FreeStyleJob job = prepareDockerSlave(dockerSlave);
job.configure();
job.copyResource(resource(RESOURCE_WARNING_MAIN_JAVA_PATH));
ShellBuildStep shellBuildStep = job.addBuildStep(ShellBuildStep.class);
shellBuildStep.command(CMD_WARNING_MAIN_JAVA_CONSOLE);
WarningsPublisher warningsPublisher = job.addPublisher(WarningsPublisher.class);
warningsPublisher.addConsoleScanner(JAVA_ID);
job.save();
Build build = job.startBuild().shouldSucceed();
assertThatActionExists(job, build, "Java Warnings");
WarningsAction action = createJavaResultAction(build);
assertThatWarningsCountInSummaryIs(action, 3);
String codeLine = action.getLinkedSourceFileText(AnalysisAction.Tab.DETAILS, "WarningMain.java", 10);
String[] codeLineArr = codeLine.trim().split("\\s+", 2);
assertThat("Warning should be at line", codeLineArr[0], is("10"));
assertThat("Assert failed comparing code line is", codeLineArr[1], is("text = (TextClass) text2;"));
}
use of org.jenkinsci.test.acceptance.po.FreeStyleJob in project acceptance-test-harness by jenkinsci.
the class WarningsPluginTest method runBuildWithRunAlwaysOption.
private FreeStyleJob runBuildWithRunAlwaysOption(final boolean canRunOnFailed) {
FreeStyleJob job = createFreeStyleJob(settings -> {
settings.addWorkspaceScanner(JAVA_TITLE, "**/*");
settings.setCanRunOnFailed(canRunOnFailed);
});
job.configure();
job.addShellStep("exit 1");
job.save();
return job;
}
Aggregations