Search in sources :

Example 1 with WarningsAction

use of org.jenkinsci.test.acceptance.plugins.warnings.WarningsAction in project acceptance-test-harness by jenkinsci.

the class WarningsPluginTest method should_not_skip_failed_builds_with_option_run_always.

/**
 * Checks that the warnings plugin will not skip build results if "Run always" is checked.
 */
@Test
@Issue("28479")
@Ignore("Reactivate after JENKINS-28479 has been fixed.")
public void should_not_skip_failed_builds_with_option_run_always() {
    FreeStyleJob job = runBuildWithRunAlwaysOption(true);
    Build build = buildJobAndWait(job).shouldFail();
    assertThatActionExists(job, build, "Java Warnings");
    WarningsAction action = createJavaResultAction(build);
    assertThatWarningsCountInSummaryIs(action, 131);
    assertThatNewWarningsCountInSummaryIs(action, 131);
}
Also used : Build(org.jenkinsci.test.acceptance.po.Build) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) WarningsAction(org.jenkinsci.test.acceptance.plugins.warnings.WarningsAction) Ignore(org.junit.Ignore) Issue(org.jvnet.hudson.test.Issue) Test(org.junit.Test)

Example 2 with WarningsAction

use of org.jenkinsci.test.acceptance.plugins.warnings.WarningsAction in project acceptance-test-harness by jenkinsci.

the class WarningsPluginTest method should_resolve_workspace_files.

/**
 * Verifies that Jenkins scans the workspace for all available files to resolve relative paths
 * of files with warnings when the option 'resolve-relative-paths' is enabled.
 */
@Test
@Issue("JENKINS-32150")
@WithPlugins("analysis-core@1.76")
public void should_resolve_workspace_files() {
    FreeStyleJob job = createFreeStyleJob(RESOURCES + "jenkins-32150", settings -> {
        settings.addWorkspaceScanner(CLANG_ID, "**/compile-log.txt");
        settings.setCanResolveRelativePaths(true);
    });
    Build build = buildSuccessfulJob(job);
    assertThatActionExists(job, build, "LLVM/Clang Warnings");
    build.open();
    int count = 10;
    assertThat(driver, hasContent("LLVM/Clang Warnings: " + count));
    WarningsAction action = new WarningsAction(build, "LLVM/Clang", "Clang (LLVM based)");
    assertThatWarningsCountInSummaryIs(action, count);
    assertThatNewWarningsCountInSummaryIs(action, count);
    action.open();
    assertThat(action.getNumberOfWarnings(), is(count));
    assertThat(action.getNumberOfNewWarnings(), is(count));
    assertThat(action.getNumberOfFixedWarnings(), is(0));
    assertThat(action.getNumberOfWarningsWithHighPriority(), is(0));
    assertThat(action.getNumberOfWarningsWithNormalPriority(), is(count));
    assertThat(action.getNumberOfWarningsWithLowPriority(), is(0));
    assertThatFilesTabIsCorrectlyFilled(action);
    assertThatWarningsTabIsCorrectlyFilled(action);
    verifySourceLine(action, "file-in-subdir.txt", 2, "02 EXAMPLE IN SUBDIR", "Some other warning");
    verifySourceLine(action, "file.txt", 6, "06 EXAMPLE", "Some warning SECOND");
    // Since multi-file-in-subdir.txt is contained twice in the workspace no source code is resolved
    verifySourceLine(action, "multi-file-in-subdir.txt", 3, "03 Is the file 'multi-file-in-subdir.txt' contained more than once in your workspace?", "Another warning");
}
Also used : Build(org.jenkinsci.test.acceptance.po.Build) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) WarningsAction(org.jenkinsci.test.acceptance.plugins.warnings.WarningsAction) Issue(org.jvnet.hudson.test.Issue) Test(org.junit.Test) WithPlugins(org.jenkinsci.test.acceptance.junit.WithPlugins)

Example 3 with WarningsAction

use of org.jenkinsci.test.acceptance.plugins.warnings.WarningsAction 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>"));
}
Also used : Build(org.jenkinsci.test.acceptance.po.Build) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) WarningsAction(org.jenkinsci.test.acceptance.plugins.warnings.WarningsAction) Test(org.junit.Test) WithPlugins(org.jenkinsci.test.acceptance.junit.WithPlugins)

Example 4 with WarningsAction

use of org.jenkinsci.test.acceptance.plugins.warnings.WarningsAction 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;"));
}
Also used : Build(org.jenkinsci.test.acceptance.po.Build) WarningsPublisher(org.jenkinsci.test.acceptance.plugins.warnings.WarningsPublisher) ShellBuildStep(org.jenkinsci.test.acceptance.po.ShellBuildStep) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) WarningsAction(org.jenkinsci.test.acceptance.plugins.warnings.WarningsAction) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) DumbSlave(org.jenkinsci.test.acceptance.po.DumbSlave) WithCredentials(org.jenkinsci.test.acceptance.junit.WithCredentials) Test(org.junit.Test) WithPlugins(org.jenkinsci.test.acceptance.junit.WithPlugins) WithDocker(org.jenkinsci.test.acceptance.junit.WithDocker)

Example 5 with WarningsAction

use of org.jenkinsci.test.acceptance.plugins.warnings.WarningsAction in project acceptance-test-harness by jenkinsci.

the class WarningsPluginTest method should_handle_invalid_ulr_gracefully.

/**
 * Verifies that providing a wrong URL to the detail factories should navigate to the top-level page.
 */
@Test
@Issue("JENKINS-37195")
public void should_handle_invalid_ulr_gracefully() {
    FreeStyleJob job = createFreeStyleJob(settings -> settings.addConsoleParser(JAVA_ID));
    catWarningsToConsole(job);
    buildSuccessfulJob(job);
    WarningsAction action = createJavaProjectAction(job);
    action.open();
    visitLastPackage();
    String packageRegex = "package.-?\\d+";
    driver.get(driver.getCurrentUrl().replaceAll(packageRegex, "package.01234"));
    assertThat(driver, hasContent("Aggregated Compiler Warnings"));
    visitLastPackage();
    driver.get(driver.getCurrentUrl().replaceAll(packageRegex, "package.NO_NUMBER"));
    assertThat(driver, hasContent("Aggregated Compiler Warnings"));
    visitLastPackage();
    List<WebElement> fileLinks = all(by.xpath("//table[@id='files']//td[@class='pane']//a"));
    int size = fileLinks.size();
    assertThat(size, is(5));
    fileLinks.get(size - 1).click();
    assertThat(driver, hasContent("tmp/clover55196.tmp/net/sourceforge/pmd/renderers - File YAHTMLRenderer.java"));
    driver.get(driver.getCurrentUrl().replaceAll("file.-?\\d+", "file.NO_NUMBER"));
    assertThat(driver, hasContent("Compiler Warnings - Source Folder tmp/clover55196.tmp/net/sourceforge/pmd/renderers"));
}
Also used : FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) WarningsAction(org.jenkinsci.test.acceptance.plugins.warnings.WarningsAction) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) WebElement(org.openqa.selenium.WebElement) Issue(org.jvnet.hudson.test.Issue) Test(org.junit.Test)

Aggregations

WarningsAction (org.jenkinsci.test.acceptance.plugins.warnings.WarningsAction)14 Test (org.junit.Test)10 FreeStyleJob (org.jenkinsci.test.acceptance.po.FreeStyleJob)9 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)8 Build (org.jenkinsci.test.acceptance.po.Build)8 WithPlugins (org.jenkinsci.test.acceptance.junit.WithPlugins)5 WithCredentials (org.jenkinsci.test.acceptance.junit.WithCredentials)3 WithDocker (org.jenkinsci.test.acceptance.junit.WithDocker)3 Issue (org.jvnet.hudson.test.Issue)3 WarningsPublisher (org.jenkinsci.test.acceptance.plugins.warnings.WarningsPublisher)2 DumbSlave (org.jenkinsci.test.acceptance.po.DumbSlave)2 ShellBuildStep (org.jenkinsci.test.acceptance.po.ShellBuildStep)2 Ignore (org.junit.Ignore)1 WebElement (org.openqa.selenium.WebElement)1