use of com.facebook.buck.util.ProcessExecutorParams in project buck by facebook.
the class AppleSimulatorControllerTest method launchingInstalledBundleInSimulatorWorks.
@Test
public void launchingInstalledBundleInSimulatorWorks() throws IOException, InterruptedException {
FakeProcess fakeSimctlLaunchProcess = new FakeProcess(0, "com.facebook.MyNeatApp: 42", "");
ProcessExecutorParams fakeSimctlLaunchParams = ProcessExecutorParams.builder().setCommand(ImmutableList.of("path/to/simctl", "launch", "70200ED8-EEF1-4BDB-BCCF-3595B137D67D", "com.facebook.MyNeatApp")).build();
FakeProcessExecutor fakeProcessExecutor = new FakeProcessExecutor(ImmutableMap.of(fakeSimctlLaunchParams, fakeSimctlLaunchProcess));
AppleSimulatorController appleSimulatorController = new AppleSimulatorController(fakeProcessExecutor, SIMCTL_PATH, IOS_SIMULATOR_PATH);
Optional<Long> launchedPID = appleSimulatorController.launchInstalledBundleInSimulator("70200ED8-EEF1-4BDB-BCCF-3595B137D67D", "com.facebook.MyNeatApp", AppleSimulatorController.LaunchBehavior.DO_NOT_WAIT_FOR_DEBUGGER, ImmutableList.of());
assertThat(launchedPID, is(equalTo(Optional.of(42L))));
}
use of com.facebook.buck.util.ProcessExecutorParams in project buck by facebook.
the class AppleSimulatorControllerTest method launchingInstalledBundleWithArgsPassesArgsThroughToSimCtl.
@Test
public void launchingInstalledBundleWithArgsPassesArgsThroughToSimCtl() throws IOException, InterruptedException {
FakeProcess fakeSimctlLaunchProcess = new FakeProcess(0, "com.facebook.MyNeatApp: 42", "");
ProcessExecutorParams fakeSimctlLaunchParams = ProcessExecutorParams.builder().setCommand(ImmutableList.of("path/to/simctl", "launch", "70200ED8-EEF1-4BDB-BCCF-3595B137D67D", "com.facebook.MyNeatApp", "arg1", "arg2")).build();
FakeProcessExecutor fakeProcessExecutor = new FakeProcessExecutor(ImmutableMap.of(fakeSimctlLaunchParams, fakeSimctlLaunchProcess));
AppleSimulatorController appleSimulatorController = new AppleSimulatorController(fakeProcessExecutor, SIMCTL_PATH, IOS_SIMULATOR_PATH);
Optional<Long> launchedPID = appleSimulatorController.launchInstalledBundleInSimulator("70200ED8-EEF1-4BDB-BCCF-3595B137D67D", "com.facebook.MyNeatApp", AppleSimulatorController.LaunchBehavior.DO_NOT_WAIT_FOR_DEBUGGER, ImmutableList.of("arg1", "arg2"));
assertThat(launchedPID, is(equalTo(Optional.of(42L))));
}
use of com.facebook.buck.util.ProcessExecutorParams in project buck by facebook.
the class AppleSimulatorControllerTest method launchingInstalledBundleWaitingForDebuggerWorks.
@Test
public void launchingInstalledBundleWaitingForDebuggerWorks() throws IOException, InterruptedException {
FakeProcess fakeSimctlLaunchProcess = new FakeProcess(0, "com.facebook.MyNeatApp: 42", "");
ProcessExecutorParams fakeSimctlLaunchParams = ProcessExecutorParams.builder().setCommand(ImmutableList.of("path/to/simctl", "launch", "-w", "70200ED8-EEF1-4BDB-BCCF-3595B137D67D", "com.facebook.MyNeatApp")).build();
FakeProcessExecutor fakeProcessExecutor = new FakeProcessExecutor(ImmutableMap.of(fakeSimctlLaunchParams, fakeSimctlLaunchProcess));
AppleSimulatorController appleSimulatorController = new AppleSimulatorController(fakeProcessExecutor, SIMCTL_PATH, IOS_SIMULATOR_PATH);
Optional<Long> launchedPID = appleSimulatorController.launchInstalledBundleInSimulator("70200ED8-EEF1-4BDB-BCCF-3595B137D67D", "com.facebook.MyNeatApp", AppleSimulatorController.LaunchBehavior.WAIT_FOR_DEBUGGER, ImmutableList.of());
assertThat(launchedPID, is(equalTo(Optional.of(42L))));
}
use of com.facebook.buck.util.ProcessExecutorParams in project buck by facebook.
the class AppleSimulatorDiscoveryTest method appleSimulatorsDiscoveredFromSimctlList.
@Test
public void appleSimulatorsDiscoveredFromSimctlList() throws IOException, InterruptedException {
ImmutableSet<AppleSimulator> simulators;
try (OutputStream stdin = new ByteArrayOutputStream();
InputStream stdout = getClass().getResourceAsStream("testdata/simctl-list.txt");
InputStream stderr = new ByteArrayInputStream(new byte[0])) {
FakeProcess fakeXcrunSimctlList = new FakeProcess(0, stdin, stdout, stderr);
ProcessExecutorParams processExecutorParams = ProcessExecutorParams.builder().setCommand(ImmutableList.of("path/to/simctl", "list")).build();
FakeProcessExecutor fakeProcessExecutor = new FakeProcessExecutor(ImmutableMap.of(processExecutorParams, fakeXcrunSimctlList));
simulators = AppleSimulatorDiscovery.discoverAppleSimulators(fakeProcessExecutor, Paths.get("path/to/simctl"));
}
ImmutableSet<AppleSimulator> expected = ImmutableSet.<AppleSimulator>builder().add(AppleSimulator.builder().setName("iPhone 4s").setUdid("F7C1CC9A-945E-4258-BA84-DEEBE683798B").setSimulatorState(AppleSimulatorState.SHUTDOWN).build()).add(AppleSimulator.builder().setName("iPhone 5").setUdid("45BD7164-686C-474F-8C68-3730432BC5F2").setSimulatorState(AppleSimulatorState.SHUTDOWN).build()).add(AppleSimulator.builder().setName("iPhone 5s").setUdid("70200ED8-EEF1-4BDB-BCCF-3595B137D67D").setSimulatorState(AppleSimulatorState.BOOTED).build()).add(AppleSimulator.builder().setName("iPhone 6 Plus").setUdid("92340ACF-2C44-455F-BACD-573B133FB20E").setSimulatorState(AppleSimulatorState.SHUTDOWN).build()).add(AppleSimulator.builder().setName("iPhone 6").setUdid("A75FF972-FE12-4656-A8CC-99572879D4A3").setSimulatorState(AppleSimulatorState.SHUTDOWN).build()).add(AppleSimulator.builder().setName("iPad 2").setUdid("CC1B0BAD-BAE6-4A53-92CF-F79850654057").setSimulatorState(AppleSimulatorState.SHUTTING_DOWN).build()).add(AppleSimulator.builder().setName("iPad Retina").setUdid("137AAA25-54A1-42E8-8202-84DEADD668E1").setSimulatorState(AppleSimulatorState.SHUTDOWN).build()).add(AppleSimulator.builder().setName("iPad Air").setUdid("554B2E0F-63F3-4400-8319-5C5062CF4C95").setSimulatorState(AppleSimulatorState.SHUTDOWN).build()).add(AppleSimulator.builder().setName("Resizable iPhone").setUdid("58E3748F-F7E6-4A45-B52C-A136B59F7A42").setSimulatorState(AppleSimulatorState.CREATING).build()).add(AppleSimulator.builder().setName("Resizable iPad").setUdid("56FE1CBC-61FF-443D-8E23-19D05864C6DB").setSimulatorState(AppleSimulatorState.SHUTDOWN).build()).build();
assertThat(simulators, is(equalTo(expected)));
}
use of com.facebook.buck.util.ProcessExecutorParams in project buck by facebook.
the class ProcessTrackerTest method testEventClass.
@Test
public void testEventClass() {
ProcessResourceConsumptionEvent event1 = new ProcessResourceConsumptionEvent("name42", Optional.empty(), Optional.empty(), Optional.empty());
assertEquals("name42", event1.getExecutableName());
assertEquals(Optional.empty(), event1.getParams());
assertEquals(Optional.empty(), event1.getContext());
assertEquals(Optional.empty(), event1.getResourceConsumption());
ProcessExecutorParams params = createParams("name100p");
ProcessResourceConsumption res = createConsumption(123, 45, 7011);
ProcessResourceConsumptionEvent event2 = new ProcessResourceConsumptionEvent("name100e", Optional.of(params), Optional.of(CONTEXT), Optional.of(res));
assertEquals("name100e", event2.getExecutableName());
assertEquals(Optional.of(params), event2.getParams());
assertEquals(Optional.of(CONTEXT), event2.getContext());
assertEquals(Optional.of(res), event2.getResourceConsumption());
}
Aggregations