use of com.facebook.buck.util.HumanReadableException in project buck by facebook.
the class WorkerProcessTest method testDoesNotBlockOnLargeStderr.
@Test(timeout = 20 * 1000)
public void testDoesNotBlockOnLargeStderr() throws IOException {
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "worker_process", temporaryPaths);
workspace.setUp();
ProjectFilesystem projectFilesystem = new ProjectFilesystem(workspace.getDestPath());
Console console = new Console(Verbosity.ALL, System.out, System.err, Ansi.withoutTty());
String script;
if (Platform.detect() == Platform.WINDOWS) {
script = workspace.getDestPath().resolve("script.bat").toString();
} else {
script = "./script.py";
}
WorkerProcess workerProcess = new WorkerProcess(new DefaultProcessExecutor(console), ProcessExecutorParams.builder().setCommand(ImmutableList.of(script)).setDirectory(workspace.getDestPath()).build(), projectFilesystem, temporaryPaths.newFolder());
try {
workerProcess.ensureLaunchAndHandshake();
fail("Handshake should have failed");
} catch (HumanReadableException e) {
// Check that all of the process's stderr was reported.
assertThat(e.getMessage().length(), is(greaterThan(1024 * 1024)));
}
}
use of com.facebook.buck.util.HumanReadableException in project buck by facebook.
the class WorkerProcessProtocolZeroTest method testReceiveHandshakeWithIncorrectID.
@Test
public void testReceiveHandshakeWithIncorrectID() throws IOException {
int handshakeID = 123;
int differentHandshakeID = 456;
JsonReader jsonReader = createMockJsonReaderForReceiveHandshake(differentHandshakeID, "handshake", "0");
WorkerProcessProtocol protocol = new WorkerProcessProtocolZero(fakeProcessExecutor, fakeLaunchedProcess, dummyJsonWriter, jsonReader, newTempFile());
try {
protocol.receiveHandshake(handshakeID);
} catch (HumanReadableException e) {
assertThat(e.getMessage(), Matchers.containsString(String.format("Expected handshake response's \"id\" value to be \"%d\"", handshakeID)));
}
}
use of com.facebook.buck.util.HumanReadableException in project buck by facebook.
the class WorkerProcessProtocolZeroTest method testReceiveCommandResponseWithInvalidType.
@Test
public void testReceiveCommandResponseWithInvalidType() throws IOException {
int messageID = 123;
JsonReader jsonReader = createMockJsonReaderForReceiveCommandResponse(messageID, "INVALID RESPONSE TYPE", 0);
WorkerProcessProtocol protocol = new WorkerProcessProtocolZero(fakeProcessExecutor, fakeLaunchedProcess, dummyJsonWriter, jsonReader, newTempFile());
try {
protocol.receiveCommandResponse(messageID);
} catch (HumanReadableException e) {
assertThat(e.getMessage(), Matchers.containsString("Expected response's \"type\" to be one of"));
}
}
use of com.facebook.buck.util.HumanReadableException in project buck by facebook.
the class WorkerProcessProtocolZeroTest method testSendCommandResponseWithWrongType.
@Test
public void testSendCommandResponseWithWrongType() throws IOException {
StringWriter jsonSentToWorkerProcess = new StringWriter();
WorkerProcessProtocol protocol = new WorkerProcessProtocolZero(fakeProcessExecutor, fakeLaunchedProcess, new JsonWriter(jsonSentToWorkerProcess), dummyJsonReader, newTempFile());
try {
protocol.sendCommandResponse(123, "WRONG_TYPE", 1);
} catch (HumanReadableException e) {
assertThat(e.getMessage(), Matchers.containsString("Expected response's \"type\" to be one of"));
}
}
use of com.facebook.buck.util.HumanReadableException in project buck by facebook.
the class WorkerProcessProtocolZeroTest method testReceiveCommandWithInvalidType.
@Test
public void testReceiveCommandWithInvalidType() throws IOException {
int messageID = 123;
JsonReader jsonReader = createMockJsonReaderForReceiveCommand(messageID, "INVALID RESPONSE TYPE", "/path/to/args", "/path/to/stdout", "/path/to/stderr");
WorkerProcessProtocol protocol = new WorkerProcessProtocolZero(fakeProcessExecutor, fakeLaunchedProcess, dummyJsonWriter, jsonReader, newTempFile());
try {
protocol.receiveCommand(messageID);
} catch (HumanReadableException e) {
assertThat(e.getMessage(), Matchers.containsString("Expected command's \"type\" to be \"command\""));
}
}
Aggregations