use of jetbrains.buildServer.util.TestFor in project teamcity-powershell by JetBrains.
the class CommandLineProviderTest method testUseDefaultPowerShellIfVersionAny.
@SuppressWarnings({ "ResultOfMethodCallIgnored" })
@Test
@TestFor(issues = "TW-34557")
public void testUseDefaultPowerShellIfVersionAny() throws Exception {
final Map<String, String> runnerParams = new HashMap<>();
final Map<String, String> sharedConfigParams = new HashMap<>();
m.checking(new Expectations() {
{
allowing(myInfo).getExecutablePath();
will(returnValue("executablePath"));
never(myInfo).getVersion();
}
});
final List<String> result = myProvider.provideCommandLine(myInfo, runnerParams, myScriptFile, false, sharedConfigParams);
for (String str : result) {
if ("-Version".equals(str)) {
fail("PowerShell version should not be supplied if Any is selected in runner parameters");
}
}
}
use of jetbrains.buildServer.util.TestFor in project teamcity-powershell by JetBrains.
the class ScriptGeneratorTest method generateScript_FILE_WorkingDir.
@Test
@TestFor(issues = "TW-66762")
public void generateScript_FILE_WorkingDir() throws Exception {
final String fileName = "script.ps1";
final Map<String, String> runnerParams = new HashMap<>();
runnerParams.put(PowerShellConstants.RUNNER_MIN_VERSION, "1.0");
runnerParams.put(PowerShellConstants.RUNNER_EXECUTION_MODE, PowerShellExecutionMode.PS1.getValue());
runnerParams.put(PowerShellConstants.RUNNER_SCRIPT_MODE, PowerShellScriptMode.FILE.getValue());
// set working directory
File scriptFile = new File(myWorkingDir, fileName);
registerAsTempFile(scriptFile);
FileUtil.writeFile(scriptFile, "Write-Output \"works\"", "UTF-8");
runnerParams.put(PowerShellConstants.RUNNER_SCRIPT_FILE, fileName);
final File resultingScript = myGenerator.generateScript(runnerParams, myCheckoutDir, myTempDir, myWorkingDir);
assertEquals(scriptFile.getAbsolutePath(), resultingScript.getAbsolutePath());
}
use of jetbrains.buildServer.util.TestFor in project teamcity-powershell by JetBrains.
the class ScriptGeneratorTest method testGenerateScript_FILE_Exists.
@Test
@TestFor(issues = "TW-49208")
public void testGenerateScript_FILE_Exists() throws Exception {
final String fileName = "script.ps1";
final Map<String, String> runnerParams = new HashMap<>();
runnerParams.put(PowerShellConstants.RUNNER_MIN_VERSION, "1.0");
runnerParams.put(PowerShellConstants.RUNNER_EXECUTION_MODE, PowerShellExecutionMode.PS1.getValue());
runnerParams.put(PowerShellConstants.RUNNER_SCRIPT_MODE, PowerShellScriptMode.FILE.getValue());
File scriptFile = new File(myCheckoutDir, fileName);
registerAsTempFile(scriptFile);
FileUtil.writeFile(scriptFile, "Write-Output \"works\"", "UTF-8");
runnerParams.put(PowerShellConstants.RUNNER_SCRIPT_FILE, fileName);
final File resultingScript = myGenerator.generateScript(runnerParams, myCheckoutDir, myTempDir, myWorkingDir);
assertEquals(scriptFile.getAbsolutePath(), resultingScript.getAbsolutePath());
}
use of jetbrains.buildServer.util.TestFor in project teamcity-powershell by JetBrains.
the class PowerShellRunTypeTest method testGenerateAnyBitnessRequirement_NoMinVersion.
@Test
@TestFor(issues = "TW-44808")
public void testGenerateAnyBitnessRequirement_NoMinVersion() {
final Map<String, String> input = createDummyParameters(null);
final Collection<Requirement> requirements = runType.getRunnerSpecificRequirements(input);
assertEquals(1, requirements.size());
final Requirement r = requirements.iterator().next();
assertEquals("Exists=>(powershell_Core_x86|powershell_Core_x64|powershell_Desktop_x86|powershell_Desktop_x64)", r.getPropertyName());
assertNull(r.getPropertyValue());
assertEquals(RequirementType.EXISTS, r.getType());
}
use of jetbrains.buildServer.util.TestFor 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());
}
Aggregations