use of jetbrains.buildServer.util.TestFor in project teamcity-git by JetBrains.
the class RevisionsCacheTest method should_not_save_revision_if_there_was_reset.
@TestFor(issues = { "TW-23460" })
@Test(dataProvider = "reset")
public void should_not_save_revision_if_there_was_reset(@NotNull BiConsumer<RevisionsCache, File> reset) throws Exception {
File repo = repository("1");
Semaphore s1 = new Semaphore(1);
s1.acquire();
Semaphore s2 = new Semaphore(1);
s2.acquire();
Thread mapFullPath = new Thread(() -> {
try {
RepositoryRevisionCache repoCache = myCache.getRepositoryCache(repo, RevisionCacheType.COMMIT_CACHE);
long resetCounter = repoCache.getResetCounter();
if (repoCache.hasRevision("v1") == null) {
s1.release();
// long commit lookup (we didn't find it)
s2.acquire();
repoCache.saveRevision("v1", false, resetCounter);
}
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
});
mapFullPath.start();
// collect changes which resets cache:
s1.acquire();
reset.accept(myCache, repo);
s2.release();
mapFullPath.join();
then(myCache.getRepositoryCache(repo, RevisionCacheType.COMMIT_CACHE).hasRevision("v1")).isNull();
}
use of jetbrains.buildServer.util.TestFor in project teamcity-powershell by JetBrains.
the class PowerShellIntegrationTests method should_run_simple_command_file_ps1.
@Test(dataProvider = "supportedBitnessProvider")
@TestFor(issues = "TW-29803")
public void should_run_simple_command_file_ps1(@NotNull final PowerShellBitness bits) throws Throwable {
final File dir = createTempDir();
final File code = new File(dir, "code.ps1");
FileUtil.writeFileAndReportErrors(code, "echo works");
setRunnerParameter(PowerShellConstants.RUNNER_EXECUTION_MODE, PowerShellExecutionMode.PS1.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("works"));
}
use of jetbrains.buildServer.util.TestFor in project teamcity-powershell by JetBrains.
the class PowerShellIntegrationTests method should_run_simple_command_file_stdin.
@Test(dataProvider = "supportedBitnessProvider")
@TestFor(issues = "TW-29803")
public void should_run_simple_command_file_stdin(@NotNull final PowerShellBitness bits) throws Throwable {
final File code = createTempFile("echo works");
setRunnerParameter(PowerShellConstants.RUNNER_MIN_VERSION, "2.0");
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("works"));
}
use of jetbrains.buildServer.util.TestFor in project teamcity-powershell by JetBrains.
the class PowerShellIntegrationTests method testMultilineArguments.
@SuppressWarnings("TestMethodWithIncorrectSignature")
@Test(dataProvider = "supportedBitnessProvider")
@TestFor(issues = "TW-65627")
public void testMultilineArguments(@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, "param(\n" + "\t[string] $param1 = \"\"\n" + ")\n" + "\n" + "Write-Output \"praram1: $param1.\"");
setRunnerParameter(PowerShellConstants.RUNNER_BITNESS, bits.getValue());
setRunnerParameter(PowerShellConstants.RUNNER_SCRIPT_ARGUMENTS, "-param1 \"line1a = line1b\nline2a = line2b\"");
setBuildConfigurationParameter(PowerShellConstants.PARAM_ARGS_MULTILINE, "true");
final SFinishedBuild build = doTest(null);
dumpBuildLogLocally(build);
Assert.assertTrue(build.getBuildStatus().isSuccessful());
Assert.assertTrue(getBuildLog(build).contains("\"line1a = line1b line2a = line2b\""));
Assert.assertTrue(getBuildLog(build).contains("praram1: line1a = line1b line2a = line2b."));
}
use of jetbrains.buildServer.util.TestFor in project teamcity-powershell by JetBrains.
the class PowerShellIntegrationTests method testShouldKeepGeneratedFiles_Global.
@SuppressWarnings("TestMethodWithIncorrectSignature")
@Test(dataProvider = "supportedBitnessProvider")
@TestFor(issues = { "TW-39841", "TW-49772" })
public void testShouldKeepGeneratedFiles_Global(@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\r\n");
setRunnerParameter(PowerShellConstants.RUNNER_BITNESS, bits.getValue());
setBuildConfigurationParameter("teamcity.dont.delete.temp.files", "true");
final SFinishedBuild build = doTest(null);
assertEquals(1, getTempFiles().length);
dumpBuildLogLocally(build);
Assert.assertTrue(build.getBuildStatus().isSuccessful());
Assert.assertTrue(getBuildLog(build).contains("works"));
}
Aggregations