Search in sources :

Example 1 with SFinishedBuild

use of jetbrains.buildServer.serverSide.SFinishedBuild in project teamcity-powershell by JetBrains.

the class PowerShellIntegrationTests method testShouldWriteBOMinExternalFileMode.

@SuppressWarnings("TestMethodWithIncorrectSignature")
@Test(dataProvider = "supportedBitnessProvider")
@TestFor(issues = "TW-44082")
public void testShouldWriteBOMinExternalFileMode(@NotNull final PowerShellBitness bits) throws Throwable {
    setRunnerParameter(PowerShellConstants.RUNNER_EXECUTION_MODE, PowerShellExecutionMode.PS1.getValue());
    setRunnerParameter(PowerShellConstants.RUNNER_SCRIPT_MODE, PowerShellScriptMode.CODE.getValue());
    setRunnerParameter(PowerShellConstants.RUNNER_SCRIPT_CODE, "$var = \"Value is \u00f8\u00e5\u00e6\"\r\n Write-Output $var\r\n");
    setRunnerParameter(PowerShellConstants.RUNNER_BITNESS, bits.getValue());
    setBuildConfigurationParameter(PowerShellConstants.CONFIG_KEEP_GENERATED, "true");
    final SFinishedBuild build = doTest(null);
    assertEquals(1, getTempFiles().length);
    final File generatedScript = getTempFiles()[0];
    try (InputStreamReader reader = new InputStreamReader(new FileInputStream(generatedScript), FILES_ENCODING)) {
        char[] buf = new char[1];
        assertEquals(1, reader.read(buf));
        assertEquals("BOM is not written to external file", '\ufeff', buf[0]);
    } catch (IOException e) {
        fail(e.getMessage());
    }
    final String fileContents = FileUtil.readText(getTempFiles()[0], FILES_ENCODING);
    assertTrue("Non-ASCII symbols were not written to generated script", fileContents.contains("\u00f8\u00e5\u00e6"));
    dumpBuildLogLocally(build);
    Assert.assertTrue(build.getBuildStatus().isSuccessful());
}
Also used : SFinishedBuild(jetbrains.buildServer.serverSide.SFinishedBuild) Test(org.testng.annotations.Test) TestFor(jetbrains.buildServer.util.TestFor)

Example 2 with SFinishedBuild

use of jetbrains.buildServer.serverSide.SFinishedBuild in project teamcity-powershell by JetBrains.

the class PowerShellIntegrationTests method testOutputIsWrittenFromScriptInFile.

@SuppressWarnings("TestMethodWithIncorrectSignature")
@Test(dataProvider = "supportedBitnessProvider")
@TestFor(issues = "TW-34775")
public void testOutputIsWrittenFromScriptInFile(@NotNull final PowerShellBitness bits) throws Throwable {
    final File dir = createTempDir();
    final File code = new File(dir, "code.ps1");
    FileUtil.writeFileAndReportErrors(code, "param ([string]$PowerShellParam = \"value\",)\n" + "Write-Host \"String from Write-Host\"\n" + "Write-Output \"String from Write-Output\"\n" + "Write-Host \"Function call from Write-Host $((Get-Date -Year 2000 -Month 12 -Day 31).DayOfYear)\"\n" + "Write-Output \"Function call from Write-Output $((Get-Date -Year 2000 -Month 12 -Day 31).DayOfYear)\"\n");
    setRunnerParameter(PowerShellConstants.RUNNER_EXECUTION_MODE, PowerShellExecutionMode.STDIN.getValue());
    setRunnerParameter(PowerShellConstants.RUNNER_SCRIPT_MODE, PowerShellScriptMode.FILE.getValue());
    setRunnerParameter(PowerShellConstants.RUNNER_SCRIPT_FILE, code.getPath());
    setRunnerParameter(PowerShellConstants.RUNNER_BITNESS, bits.getValue());
    final SFinishedBuild build = doTest(null);
    dumpBuildLogLocally(build);
    Assert.assertTrue(build.getBuildStatus().isSuccessful());
    Assert.assertTrue(getBuildLog(build).contains("String from Write-Host"));
    Assert.assertTrue(getBuildLog(build).contains("String from Write-Output"));
    Assert.assertTrue(getBuildLog(build).contains("Function call from Write-Host 366"));
    Assert.assertTrue(getBuildLog(build).contains("Function call from Write-Output 366"));
}
Also used : SFinishedBuild(jetbrains.buildServer.serverSide.SFinishedBuild) Test(org.testng.annotations.Test) TestFor(jetbrains.buildServer.util.TestFor)

Example 3 with SFinishedBuild

use of jetbrains.buildServer.serverSide.SFinishedBuild in project teamcity-powershell by JetBrains.

the class PowerShellIntegrationTests method should_run_simple_command_code_stdin.

@Test(dataProvider = "supportedBitnessProvider")
@TestFor(issues = "TW-29803")
public void should_run_simple_command_code_stdin(@NotNull final PowerShellBitness bits) throws Throwable {
    setRunnerParameter(PowerShellConstants.RUNNER_MIN_VERSION, "2.0");
    setRunnerParameter(PowerShellConstants.RUNNER_EXECUTION_MODE, PowerShellExecutionMode.STDIN.getValue());
    setRunnerParameter(PowerShellConstants.RUNNER_SCRIPT_MODE, PowerShellScriptMode.CODE.getValue());
    setRunnerParameter(PowerShellConstants.RUNNER_SCRIPT_CODE, "echo works");
    setRunnerParameter(PowerShellConstants.RUNNER_BITNESS, bits.getValue());
    final SFinishedBuild build = doTest(null);
    dumpBuildLogLocally(build);
    Assert.assertTrue(build.getBuildStatus().isSuccessful());
    Assert.assertTrue(getBuildLog(build).contains("works"));
}
Also used : SFinishedBuild(jetbrains.buildServer.serverSide.SFinishedBuild) Test(org.testng.annotations.Test) TestFor(jetbrains.buildServer.util.TestFor)

Example 4 with SFinishedBuild

use of jetbrains.buildServer.serverSide.SFinishedBuild in project teamcity-powershell by JetBrains.

the class PowerShellIntegrationTests method should_run_simple_command_code_ps1.

@Test(dataProvider = "supportedBitnessProvider")
@TestFor(issues = "TW-29803")
public void should_run_simple_command_code_ps1(@NotNull final PowerShellBitness bits) throws Throwable {
    setRunnerParameter(PowerShellConstants.RUNNER_EXECUTION_MODE, PowerShellExecutionMode.PS1.getValue());
    setRunnerParameter(PowerShellConstants.RUNNER_SCRIPT_MODE, PowerShellScriptMode.CODE.getValue());
    setRunnerParameter(PowerShellConstants.RUNNER_SCRIPT_CODE, "echo works");
    setRunnerParameter(PowerShellConstants.RUNNER_BITNESS, bits.getValue());
    final SFinishedBuild build = doTest(null);
    dumpBuildLogLocally(build);
    Assert.assertTrue(build.getBuildStatus().isSuccessful());
    Assert.assertTrue(getBuildLog(build).contains("works"));
}
Also used : SFinishedBuild(jetbrains.buildServer.serverSide.SFinishedBuild) Test(org.testng.annotations.Test) TestFor(jetbrains.buildServer.util.TestFor)

Example 5 with SFinishedBuild

use of jetbrains.buildServer.serverSide.SFinishedBuild in project teamcity-powershell by JetBrains.

the class PowerShellIntegrationTests method testShouldKeepGeneratedFiles_PowerShellSpecific.

@SuppressWarnings("TestMethodWithIncorrectSignature")
@Test(dataProvider = "supportedBitnessProvider")
@TestFor(issues = { "TW-39841", "TW-49772" })
public void testShouldKeepGeneratedFiles_PowerShellSpecific(@NotNull final PowerShellBitness bits) throws Throwable {
    setRunnerParameter(PowerShellConstants.RUNNER_EXECUTION_MODE, PowerShellExecutionMode.PS1.getValue());
    setRunnerParameter(PowerShellConstants.RUNNER_SCRIPT_MODE, PowerShellScriptMode.CODE.getValue());
    setRunnerParameter(PowerShellConstants.RUNNER_SCRIPT_CODE, "echo works");
    setRunnerParameter(PowerShellConstants.RUNNER_BITNESS, bits.getValue());
    setBuildConfigurationParameter(PowerShellConstants.CONFIG_KEEP_GENERATED, "true");
    final SFinishedBuild build = doTest(null);
    assertEquals(1, getTempFiles().length);
    dumpBuildLogLocally(build);
    Assert.assertTrue(build.getBuildStatus().isSuccessful());
    Assert.assertTrue(getBuildLog(build).contains("works"));
}
Also used : SFinishedBuild(jetbrains.buildServer.serverSide.SFinishedBuild) Test(org.testng.annotations.Test) TestFor(jetbrains.buildServer.util.TestFor)

Aggregations

SFinishedBuild (jetbrains.buildServer.serverSide.SFinishedBuild)34 Test (org.testng.annotations.Test)32 TestFor (jetbrains.buildServer.util.TestFor)12 BuildTypeImpl (jetbrains.buildServer.serverSide.impl.BuildTypeImpl)9 FakeHttpServletRequest (jetbrains.buildServer.controllers.fakes.FakeHttpServletRequest)7 TestOccurrences (jetbrains.buildServer.server.rest.model.problem.TestOccurrences)7 TestScope (jetbrains.buildServer.server.rest.data.problem.scope.TestScope)4 Set (java.util.Set)3 Collectors (java.util.stream.Collectors)3 TestOccurrence (jetbrains.buildServer.server.rest.model.problem.TestOccurrence)3 BeanContext (jetbrains.buildServer.server.rest.util.BeanContext)2 ProjectEx (jetbrains.buildServer.serverSide.impl.ProjectEx)2 SkipException (org.testng.SkipException)2 BufferedImage (java.awt.image.BufferedImage)1 SUserGroup (jetbrains.buildServer.groups.SUserGroup)1 BaseFinderTest (jetbrains.buildServer.server.rest.data.BaseFinderTest)1 Build (jetbrains.buildServer.server.rest.model.build.Build)1 User (jetbrains.buildServer.server.rest.model.user.User)1 BuildPromotionEx (jetbrains.buildServer.serverSide.BuildPromotionEx)1 BuildTypeEx (jetbrains.buildServer.serverSide.BuildTypeEx)1