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"));
}
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"));
}
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"));
}
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"));
}
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);
}
Aggregations