use of com.facebook.buck.util.FakeProcess in project buck by facebook.
the class AppleCoreSimulatorServiceControllerTest method coreSimulatorServicesKillSucceedsEvenIfNoSuchProcess.
@Test
public void coreSimulatorServicesKillSucceedsEvenIfNoSuchProcess() throws IOException, InterruptedException {
ImmutableList.Builder<Map.Entry<ProcessExecutorParams, FakeProcess>> fakeProcessesBuilder = ImmutableList.builder();
fakeProcessesBuilder.add(new SimpleImmutableEntry<>(LAUNCHCTL_LIST_PARAMS, new FakeProcess(0, "87823\t0\tcom.apple.CoreSimulator.CoreSimulatorService.117.15.1.lkhDXxRPp5yy\n" + "74617\t0\tcom.apple.CoreSimulator.SimDevice.CC1B0BAD-BAE6-4A53-92CF-F79850654057" + ".launchd_sim\n" + "74614\t0\tcom.apple.iphonesimulator.6564\n", "")));
fakeProcessesBuilder.add(new SimpleImmutableEntry<>(ProcessExecutorParams.builder().setCommand(ImmutableList.of("launchctl", "remove", "com.apple.CoreSimulator.CoreSimulatorService.117.15.1.lkhDXxRPp5yy")).build(), new FakeProcess(0)));
fakeProcessesBuilder.add(new SimpleImmutableEntry<>(ProcessExecutorParams.builder().setCommand(ImmutableList.of("launchctl", "remove", "com.apple.CoreSimulator.SimDevice.CC1B0BAD-BAE6-4A53-92CF-F79850654057." + "launchd_sim")).build(), new FakeProcess(3)));
fakeProcessesBuilder.add(new SimpleImmutableEntry<>(ProcessExecutorParams.builder().setCommand(ImmutableList.of("launchctl", "remove", "com.apple.iphonesimulator.6564")).build(), new FakeProcess(0)));
FakeProcessExecutor fakeProcessExecutor = new FakeProcessExecutor(fakeProcessesBuilder.build());
AppleCoreSimulatorServiceController appleCoreSimulatorServiceController = new AppleCoreSimulatorServiceController(fakeProcessExecutor);
assertThat(appleCoreSimulatorServiceController.killSimulatorProcesses(), is(true));
}
use of com.facebook.buck.util.FakeProcess in project buck by facebook.
the class AppleCoreSimulatorServiceControllerTest method coreSimulatorServicePathFetchedFromLaunchctlPrint.
@Test
public void coreSimulatorServicePathFetchedFromLaunchctlPrint() throws IOException, InterruptedException {
ImmutableList.Builder<Map.Entry<ProcessExecutorParams, FakeProcess>> fakeProcessesBuilder = ImmutableList.builder();
fakeProcessesBuilder.add(new SimpleImmutableEntry<>(LAUNCHCTL_LIST_PARAMS, new FakeProcess(0, "87823\t0\tcom.apple.CoreSimulator.CoreSimulatorService.117.15.1.lkhDXxRPp5yy\n", "")));
fakeProcessesBuilder.add(new SimpleImmutableEntry<>(ProcessExecutorParams.builder().setCommand(ImmutableList.of("launchctl", "print", "user/42/com.apple.CoreSimulator.CoreSimulatorService.117.15.1.lkhDXxRPp5yy")).build(), new FakeProcess(0, "com.apple.CoreSimulator.CoreSimulatorService.117.15.1.lkhDXxRPp5yy = {\n" + " path = xcode-dir/Developer/Library/PrivateFrameworks/CoreSimulator.framework" + "/Versions/A/XPCServices/com.apple.CoreSimulator.CoreSimulatorService.xpc\n" + "}\n", "")));
FakeProcessExecutor fakeProcessExecutor = new FakeProcessExecutor(fakeProcessesBuilder.build());
AppleCoreSimulatorServiceController appleCoreSimulatorServiceController = new AppleCoreSimulatorServiceController(fakeProcessExecutor);
Optional<Path> coreSimulatorServicePath = appleCoreSimulatorServiceController.getCoreSimulatorServicePath(new FakeUserIdFetcher(42));
Optional<Path> expected = Optional.of(Paths.get("xcode-dir/Developer/Library/PrivateFrameworks/CoreSimulator.framework/" + "Versions/A/XPCServices/com.apple.CoreSimulator.CoreSimulatorService.xpc"));
assertThat(coreSimulatorServicePath, is(equalTo(expected)));
}
use of com.facebook.buck.util.FakeProcess in project buck by facebook.
the class AppleCoreSimulatorServiceControllerTest method coreSimulatorServicesKillFailsIfUnrecognizedError.
@Test
public void coreSimulatorServicesKillFailsIfUnrecognizedError() throws IOException, InterruptedException {
ImmutableList.Builder<Map.Entry<ProcessExecutorParams, FakeProcess>> fakeProcessesBuilder = ImmutableList.builder();
fakeProcessesBuilder.add(new SimpleImmutableEntry<>(LAUNCHCTL_LIST_PARAMS, new FakeProcess(0, "87823\t0\tcom.apple.CoreSimulator.CoreSimulatorService.117.15.1.lkhDXxRPp5yy\n", "")));
fakeProcessesBuilder.add(new SimpleImmutableEntry<>(ProcessExecutorParams.builder().setCommand(ImmutableList.of("launchctl", "remove", "com.apple.CoreSimulator.CoreSimulatorService.117.15.1.lkhDXxRPp5yy")).build(), new FakeProcess(42)));
FakeProcessExecutor fakeProcessExecutor = new FakeProcessExecutor(fakeProcessesBuilder.build());
AppleCoreSimulatorServiceController appleCoreSimulatorServiceController = new AppleCoreSimulatorServiceController(fakeProcessExecutor);
assertThat(appleCoreSimulatorServiceController.killSimulatorProcesses(), is(false));
}
use of com.facebook.buck.util.FakeProcess in project buck by facebook.
the class AppleSimulatorControllerTest method canStartSimulatorWhenNoSimulatorBooted.
@Test
public void canStartSimulatorWhenNoSimulatorBooted() throws IOException, InterruptedException {
ImmutableList.Builder<Map.Entry<ProcessExecutorParams, FakeProcess>> fakeProcessesBuilder = ImmutableList.builder();
fakeProcessesBuilder.add(new SimpleImmutableEntry<>(SIMCTL_LIST_PARAMS, new FakeProcess(0, " iPhone 5 (45BD7164-686C-474F-8C68-3730432BC5F2) (Shutdown)\n" + " iPhone 5s (70200ED8-EEF1-4BDB-BCCF-3595B137D67D) (Shutdown)\n", "")));
FakeProcessExecutor fakeProcessExecutor = new FakeProcessExecutor(fakeProcessesBuilder.build());
AppleSimulatorController appleSimulatorController = new AppleSimulatorController(fakeProcessExecutor, SIMCTL_PATH, IOS_SIMULATOR_PATH);
assertThat(appleSimulatorController.canStartSimulator("45BD7164-686C-474F-8C68-3730432BC5F2"), is(true));
}
use of com.facebook.buck.util.FakeProcess in project buck by facebook.
the class AppleSimulatorControllerTest method canStartSimulatorWhenSimulatorAlreadyBooted.
@Test
public void canStartSimulatorWhenSimulatorAlreadyBooted() throws IOException, InterruptedException {
ImmutableList.Builder<Map.Entry<ProcessExecutorParams, FakeProcess>> fakeProcessesBuilder = ImmutableList.builder();
fakeProcessesBuilder.add(new SimpleImmutableEntry<>(SIMCTL_LIST_PARAMS, new FakeProcess(0, " iPhone 5 (45BD7164-686C-474F-8C68-3730432BC5F2) (Booted)\n" + " iPhone 5s (70200ED8-EEF1-4BDB-BCCF-3595B137D67D) (Shutdown)\n", "")));
FakeProcessExecutor fakeProcessExecutor = new FakeProcessExecutor(fakeProcessesBuilder.build());
AppleSimulatorController appleSimulatorController = new AppleSimulatorController(fakeProcessExecutor, SIMCTL_PATH, IOS_SIMULATOR_PATH);
assertThat(appleSimulatorController.canStartSimulator("45BD7164-686C-474F-8C68-3730432BC5F2"), is(true));
}
Aggregations