use of com.thoughtworks.go.util.command.InMemoryStreamConsumer in project gocd by gocd.
the class GitMaterialUpdaterTest method shouldDeleteAndRecheckoutDirectoryWhenBranchChanges.
@Test
public void shouldDeleteAndRecheckoutDirectoryWhenBranchChanges() throws Exception {
GitTestRepo repoWithBranch = GitTestRepo.testRepoAtBranch(GIT_FOO_BRANCH_BUNDLE, "foo", temporaryFolder);
GitMaterial material = new GitMaterial(repoWithBranch.projectRepositoryUrl(), true);
updateTo(material, new RevisionContext(new StringRevision("origin/master")), JobResult.Passed);
InMemoryStreamConsumer output = inMemoryConsumer();
CommandLine.createCommandLine("git").withEncoding("UTF-8").withArg("branch").withWorkingDir(workingDir).run(output, "");
assertThat(output.getStdOut(), Is.is("* master"));
GitMaterial material1 = new GitMaterial(repoWithBranch.projectRepositoryUrl(), "foo", null, true);
updateTo(material1, new RevisionContext(new StringRevision("origin/foo")), JobResult.Passed);
output = inMemoryConsumer();
CommandLine.createCommandLine("git").withEncoding("UTF-8").withArg("branch").withWorkingDir(workingDir).run(output, "");
assertThat(output.getStdOut(), Is.is("* foo"));
}
use of com.thoughtworks.go.util.command.InMemoryStreamConsumer in project gocd by gocd.
the class GitMaterialTest method shouldDeleteAndRecheckoutDirectoryWhenBranchChanges.
@Test
public void shouldDeleteAndRecheckoutDirectoryWhenBranchChanges() throws Exception {
git = new GitMaterial(gitFooBranchBundle.projectRepositoryUrl());
git.latestModification(workingDir, new TestSubprocessExecutionContext());
InMemoryStreamConsumer output = inMemoryConsumer();
CommandLine.createCommandLine("git").withEncoding("UTF-8").withArg("branch").withWorkingDir(workingDir).run(output, "");
assertThat(output.getStdOut(), is("* master"));
git = new GitMaterial(gitFooBranchBundle.projectRepositoryUrl(), "foo");
git.latestModification(workingDir, new TestSubprocessExecutionContext());
output = inMemoryConsumer();
CommandLine.createCommandLine("git").withEncoding("UTF-8").withArg("branch").withWorkingDir(workingDir).run(output, "");
assertThat(output.getStdOut(), is("* foo"));
}
use of com.thoughtworks.go.util.command.InMemoryStreamConsumer in project gocd by gocd.
the class PipelineConfigServicePerformanceTest method takeHeapDump.
private void takeHeapDump(File dumpDir, int i) {
InMemoryStreamConsumer outputStreamConsumer = inMemoryConsumer();
CommandLine commandLine = CommandLine.createCommandLine("jmap").withArgs("-J-d64", String.format("-dump:format=b,file=%s/%s.hprof", dumpDir.getAbsoluteFile(), i), ManagementFactory.getRuntimeMXBean().getName().split("@")[0]);
LOGGER.info(commandLine.describe());
int exitCode = commandLine.run(outputStreamConsumer, "thread" + i);
LOGGER.info(outputStreamConsumer.getAllOutput());
assertThat(exitCode, is(0));
LOGGER.info("Heap dump available at " + dumpDir.getAbsolutePath());
}
use of com.thoughtworks.go.util.command.InMemoryStreamConsumer in project gocd by gocd.
the class P4Material method getP4.
protected P4Client getP4(File baseDir) {
InMemoryStreamConsumer outputConsumer = inMemoryConsumer();
P4Client p4 = null;
try {
p4 = p4(baseDir, outputConsumer);
} catch (Exception e) {
bomb(e.getMessage() + " " + outputConsumer.getStdError(), e);
}
return p4;
}
use of com.thoughtworks.go.util.command.InMemoryStreamConsumer in project gocd by gocd.
the class P4MaterialTest method shouldGenerateTheSameP4ClientValueForCommandAndEnvironment.
@Test
void shouldGenerateTheSameP4ClientValueForCommandAndEnvironment() throws Exception {
P4Material p4Material = new P4Material("server:10", "out-of-the-window");
ReflectionUtil.setField(p4Material, "folder", "crapy_dir");
P4Client p4Client = p4Material._p4(workingDir, new InMemoryStreamConsumer(), false);
assertThat(p4Client).isNotNull();
String client = (String) ReflectionUtil.getField(p4Client, "p4ClientName");
assertThat(client).isEqualTo(p4Material.clientName(workingDir));
}
Aggregations