use of com.thoughtworks.go.util.command.ProcessOutputStreamConsumer in project gocd by gocd.
the class ProcessWrapperTest method shouldThrowExceptionWhenExecutableDoesNotExist.
@Test
public void shouldThrowExceptionWhenExecutableDoesNotExist() throws IOException {
CommandLine line = CommandLine.createCommandLine("doesnotexist");
try {
ProcessOutputStreamConsumer outputStreamConsumer = inMemoryConsumer();
line.execute(outputStreamConsumer, new EnvironmentVariableContext(), null);
fail("Expected exception");
} catch (CommandLineException e) {
assertThat(e.getMessage(), containsString("Make sure this command can execute manually."));
assertThat(e.getMessage(), containsString("doesnotexist"));
assertThat(e.getResult(), notNullValue());
}
}
use of com.thoughtworks.go.util.command.ProcessOutputStreamConsumer in project gocd by gocd.
the class BuildSession method newSafeConsole.
private SafeOutputStreamConsumer newSafeConsole() {
ProcessOutputStreamConsumer processConsumer = new ProcessOutputStreamConsumer<>(console, console);
SafeOutputStreamConsumer streamConsumer = new SafeOutputStreamConsumer(processConsumer);
for (String secret : secretSubstitutions.keySet()) {
streamConsumer.addSecret(new SecretSubstitution(secret, secretSubstitutions.get(secret)));
}
return streamConsumer;
}
use of com.thoughtworks.go.util.command.ProcessOutputStreamConsumer in project gocd by gocd.
the class MaterialAgentFactoryTest method shouldCreateMaterialAgent_withAgentsUuidAsSubprocessExecutionContextNamespace.
@Test
public void shouldCreateMaterialAgent_withAgentsUuidAsSubprocessExecutionContextNamespace() throws IOException {
String agentUuid = "uuid-01783738";
File workingDirectory = temporaryFolder.newFolder();
MaterialAgentFactory factory = new MaterialAgentFactory(new ProcessOutputStreamConsumer(new DevNull(), new DevNull()), workingDirectory, new AgentIdentifier("host", "1.1.1.1", agentUuid), packageRepositoryExtension, scmExtension);
GitMaterial gitMaterial = new GitMaterial("http://foo", "master", "dest_folder");
MaterialAgent agent = factory.createAgent(new MaterialRevision(gitMaterial));
assertThat(agent, is(instanceOf(AbstractMaterialAgent.class)));
SubprocessExecutionContext execCtx = (SubprocessExecutionContext) ReflectionUtil.getField(agent, "execCtx");
assertThat(execCtx.getProcessNamespace("fingerprint"), is(CachedDigestUtils.sha256Hex(String.format("%s%s%s", "fingerprint", agentUuid, gitMaterial.workingdir(workingDirectory)))));
}
use of com.thoughtworks.go.util.command.ProcessOutputStreamConsumer in project gocd by gocd.
the class TfsExecutorTest method createBuildSession.
private void createBuildSession() {
AgentIdentifier agentIdentifier = mock(AgentIdentifier.class);
when(workingDir.getAbsolutePath()).thenReturn("working dir");
ProcessOutputStreamConsumer processOutputStreamConsumer = mock(ProcessOutputStreamConsumer.class);
buildSession = mock(BuildSession.class);
when(buildSession.resolveRelativeDir("working dir")).thenReturn(workingDir);
when(buildSession.getAgentIdentifier()).thenReturn(agentIdentifier);
when(buildSession.processOutputStreamConsumer()).thenReturn(processOutputStreamConsumer);
}
use of com.thoughtworks.go.util.command.ProcessOutputStreamConsumer in project gocd by gocd.
the class SvnTestRepo method checkInOneFile.
public void checkInOneFile(String fileName, SvnMaterial svnMaterial) throws Exception {
final File baseDir = temporaryFolder.newFolder();
tmpFolders.add(baseDir);
ProcessOutputStreamConsumer consumer = inMemoryConsumer();
Revision revision = latestRevision(svnMaterial, baseDir, new TestSubprocessExecutionContext());
svnMaterial.updateTo(consumer, baseDir, new RevisionContext(revision), new TestSubprocessExecutionContext());
File workingDir = new File(baseDir, svnMaterial.getFolder());
File newFileToAdd = new File(workingDir, fileName);
newFileToAdd.getParentFile().mkdirs();
FileUtils.writeStringToFile(newFileToAdd, "", UTF_8);
svnMaterial.add(consumer, newFileToAdd);
svnMaterial.commit(consumer, workingDir, "adding file [" + svnMaterial.getFolder() + "/" + fileName + "]");
}
Aggregations