use of com.facebook.buck.util.FakeProcessExecutor in project buck by facebook.
the class XctoolRunTestsStepTest method xctoolCommandWithTestSelectorMatchingNothingDoesNotFail.
@Test
public void xctoolCommandWithTestSelectorMatchingNothingDoesNotFail() throws Exception {
FakeProjectFilesystem projectFilesystem = new FakeProjectFilesystem();
XctoolRunTestsStep step = new XctoolRunTestsStep(projectFilesystem, Paths.get("/path/to/xctool"), ImmutableMap.of(), Optional.empty(), "iphonesimulator", Optional.empty(), ImmutableSet.of(Paths.get("/path/to/FooTest.xctest"), Paths.get("/path/to/BarTest.xctest")), ImmutableMap.of(), Paths.get("/path/to/output.json"), Optional.empty(), Suppliers.ofInstance(Optional.of(Paths.get("/path/to/developer/dir"))), TestSelectorList.builder().addRawSelectors("Blargh#Xyzzy").build(), false, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty());
ProcessExecutorParams xctoolListOnlyParams = ProcessExecutorParams.builder().setCommand(ImmutableList.of("/path/to/xctool", "-reporter", "json-stream", "-sdk", "iphonesimulator", "run-tests", "-logicTest", "/path/to/FooTest.xctest", "-logicTest", "/path/to/BarTest.xctest", "-listTestsOnly")).setEnvironment(ImmutableMap.of("DEVELOPER_DIR", "/path/to/developer/dir")).setDirectory(projectFilesystem.getRootPath().toAbsolutePath()).setRedirectOutput(ProcessBuilder.Redirect.PIPE).build();
try (InputStream stdout = getClass().getResourceAsStream("testdata/xctool-output/list-tests-only.json");
InputStream stderr = new ByteArrayInputStream(new byte[0])) {
assertThat(stdout, not(nullValue()));
FakeProcess fakeXctoolListTestsProcess = new FakeProcess(0, ByteStreams.nullOutputStream(), stdout, stderr);
FakeProcessExecutor processExecutor = new FakeProcessExecutor(ImmutableMap.of(xctoolListOnlyParams, fakeXctoolListTestsProcess));
ExecutionContext executionContext = TestExecutionContext.newBuilder().setProcessExecutor(processExecutor).setEnvironment(ImmutableMap.of()).build();
assertThat(step.execute(executionContext).getExitCode(), equalTo(0));
}
}
use of com.facebook.buck.util.FakeProcessExecutor in project buck by facebook.
the class XctoolRunTestsStepTest method xctoolCommandWhichFailsPrintsStderrToConsole.
@Test
public void xctoolCommandWhichFailsPrintsStderrToConsole() throws Exception {
FakeProjectFilesystem projectFilesystem = new FakeProjectFilesystem();
XctoolRunTestsStep step = new XctoolRunTestsStep(projectFilesystem, Paths.get("/path/to/xctool"), ImmutableMap.of(), Optional.empty(), "iphonesimulator", Optional.empty(), ImmutableSet.of(Paths.get("/path/to/Foo.xctest")), ImmutableMap.of(), Paths.get("/path/to/output.json"), Optional.empty(), Suppliers.ofInstance(Optional.of(Paths.get("/path/to/developer/dir"))), TestSelectorList.EMPTY, false, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty());
ProcessExecutorParams xctoolParams = ProcessExecutorParams.builder().setCommand(ImmutableList.of("/path/to/xctool", "-reporter", "json-stream", "-sdk", "iphonesimulator", "run-tests", "-logicTest", "/path/to/Foo.xctest")).setEnvironment(ImmutableMap.of("DEVELOPER_DIR", "/path/to/developer/dir")).setDirectory(projectFilesystem.getRootPath().toAbsolutePath()).setRedirectOutput(ProcessBuilder.Redirect.PIPE).build();
FakeProcess fakeXctoolFailure = new FakeProcess(42, "", "Something went terribly wrong\n");
FakeProcessExecutor processExecutor = new FakeProcessExecutor(ImmutableMap.of(xctoolParams, fakeXctoolFailure));
TestConsole testConsole = new TestConsole();
ExecutionContext executionContext = TestExecutionContext.newBuilder().setProcessExecutor(processExecutor).setEnvironment(ImmutableMap.of()).setConsole(testConsole).build();
assertThat(step.execute(executionContext).getExitCode(), equalTo(42));
assertThat(testConsole.getTextWrittenToStdErr(), equalTo("xctool failed with exit code 42: Something went terribly wrong\n"));
}
use of com.facebook.buck.util.FakeProcessExecutor in project buck by facebook.
the class KnownBuildRuleTypesTest method createExecutor.
private ProcessExecutor createExecutor(String javac, String version) {
Map<ProcessExecutorParams, FakeProcess> processMap = new HashMap<>();
FakeProcess process = new FakeProcess(0, "", version);
ProcessExecutorParams params = ProcessExecutorParams.builder().setCommand(ImmutableList.of(javac, "-version")).build();
processMap.put(params, process);
addXcodeSelectProcess(processMap, FAKE_XCODE_DEV_PATH);
processMap.putAll(KnownBuildRuleTypesTestUtil.getPythonProcessMap(KnownBuildRuleTypesTestUtil.getPaths(environment)));
return new FakeProcessExecutor(processMap);
}
use of com.facebook.buck.util.FakeProcessExecutor in project buck by facebook.
the class AppleCoreSimulatorServiceControllerTest method coreSimulatorServicesKilledSuccessfully.
@Test
public void coreSimulatorServicesKilledSuccessfully() 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(0)));
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.FakeProcessExecutor 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))));
}
Aggregations