Search in sources :

Example 56 with ProcessExecutorParams

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))));
}
Also used : ProcessExecutorParams(com.facebook.buck.util.ProcessExecutorParams) FakeProcessExecutor(com.facebook.buck.util.FakeProcessExecutor) FakeProcess(com.facebook.buck.util.FakeProcess) Test(org.junit.Test)

Example 57 with ProcessExecutorParams

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))));
}
Also used : ProcessExecutorParams(com.facebook.buck.util.ProcessExecutorParams) FakeProcessExecutor(com.facebook.buck.util.FakeProcessExecutor) FakeProcess(com.facebook.buck.util.FakeProcess) Test(org.junit.Test)

Example 58 with ProcessExecutorParams

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))));
}
Also used : ProcessExecutorParams(com.facebook.buck.util.ProcessExecutorParams) FakeProcessExecutor(com.facebook.buck.util.FakeProcessExecutor) FakeProcess(com.facebook.buck.util.FakeProcess) Test(org.junit.Test)

Example 59 with ProcessExecutorParams

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)));
}
Also used : ProcessExecutorParams(com.facebook.buck.util.ProcessExecutorParams) ByteArrayInputStream(java.io.ByteArrayInputStream) FakeProcessExecutor(com.facebook.buck.util.FakeProcessExecutor) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) OutputStream(java.io.OutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) FakeProcess(com.facebook.buck.util.FakeProcess) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Test(org.junit.Test)

Example 60 with ProcessExecutorParams

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());
}
Also used : ProcessResourceConsumptionEvent(com.facebook.buck.util.perf.ProcessTracker.ProcessResourceConsumptionEvent) ProcessExecutorParams(com.facebook.buck.util.ProcessExecutorParams) ProcessResourceConsumption(com.facebook.buck.util.ProcessResourceConsumption) Test(org.junit.Test)

Aggregations

ProcessExecutorParams (com.facebook.buck.util.ProcessExecutorParams)72 ProcessExecutor (com.facebook.buck.util.ProcessExecutor)32 FakeProcess (com.facebook.buck.util.FakeProcess)30 Test (org.junit.Test)30 FakeProcessExecutor (com.facebook.buck.util.FakeProcessExecutor)21 ExecutionContext (com.facebook.buck.step.ExecutionContext)19 TestExecutionContext (com.facebook.buck.step.TestExecutionContext)19 IOException (java.io.IOException)18 FakeProjectFilesystem (com.facebook.buck.testutil.FakeProjectFilesystem)12 TestConsole (com.facebook.buck.testutil.TestConsole)12 Path (java.nio.file.Path)11 DefaultProcessExecutor (com.facebook.buck.util.DefaultProcessExecutor)8 ListeningProcessExecutor (com.facebook.buck.util.ListeningProcessExecutor)6 HumanReadableException (com.facebook.buck.util.HumanReadableException)5 ImmutableList (com.google.common.collect.ImmutableList)5 ImmutableSet (com.google.common.collect.ImmutableSet)5 ImmutableMap (com.google.common.collect.ImmutableMap)4 InputStream (java.io.InputStream)4 InputStreamReader (java.io.InputStreamReader)4 Matcher (java.util.regex.Matcher)4