Search in sources :

Example 6 with TestFor

use of jetbrains.buildServer.util.TestFor 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 7 with TestFor

use of jetbrains.buildServer.util.TestFor 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 8 with TestFor

use of jetbrains.buildServer.util.TestFor 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 9 with TestFor

use of jetbrains.buildServer.util.TestFor 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)

Example 10 with TestFor

use of jetbrains.buildServer.util.TestFor in project teamcity-powershell by JetBrains.

the class RegistryPowerShellDetectorTest method testDetectPowerShell_5_1.

@Test
@TestFor(issues = "TW-46689")
public void testDetectPowerShell_5_1() {
    m.checking(new Expectations() {

        {
            allowing(acc).readRegistryText(LOCAL_MACHINE, BIT32, "SOFTWARE\\Microsoft\\PowerShell\\3\\PowerShellEngine", "PowerShellVersion");
            will(returnValue("5.1.14393.0"));
            allowing(acc).readRegistryText(LOCAL_MACHINE, BIT32, "SOFTWARE\\Microsoft\\PowerShell\\1\\PowerShellEngine", "PowerShellVersion");
            will(returnValue("2.0"));
        }
    });
    final String ver = new PowerShellRegistry(BIT32, acc).getInstalledVersion();
    assertEquals("5.1.14393.0", ver);
}
Also used : Expectations(org.jmock.Expectations) Test(org.testng.annotations.Test) TestFor(jetbrains.buildServer.util.TestFor)

Aggregations

TestFor (jetbrains.buildServer.util.TestFor)129 Test (org.testng.annotations.Test)81 File (java.io.File)65 GitTestUtil.dataFile (jetbrains.buildServer.buildTriggers.vcs.git.tests.GitTestUtil.dataFile)56 VcsRootImpl (jetbrains.buildServer.vcs.impl.VcsRootImpl)26 CheckoutRules (jetbrains.buildServer.vcs.CheckoutRules)21 VcsRoot (jetbrains.buildServer.vcs.VcsRoot)17 SFinishedBuild (jetbrains.buildServer.serverSide.SFinishedBuild)12 VcsException (jetbrains.buildServer.vcs.VcsException)11 URIish (org.eclipse.jgit.transport.URIish)11 Repository (org.eclipse.jgit.lib.Repository)9 BaseFinderTest (jetbrains.buildServer.server.rest.data.BaseFinderTest)7 AfterMethod (org.testng.annotations.AfterMethod)7 BeforeMethod (org.testng.annotations.BeforeMethod)7 Method (java.lang.reflect.Method)6 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)6 GitTestUtil.copyRepository (jetbrains.buildServer.buildTriggers.vcs.git.tests.GitTestUtil.copyRepository)6 Build (jetbrains.buildServer.server.rest.model.build.Build)6 BuildTypeImpl (jetbrains.buildServer.serverSide.impl.BuildTypeImpl)6 FileUtil.writeFile (jetbrains.buildServer.util.FileUtil.writeFile)6