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