use of com.facebook.buck.util.FakeProcess in project buck by facebook.
the class AppleSimulatorControllerTest method installingBundleInSimulatorWorks.
@Test
public void installingBundleInSimulatorWorks() throws IOException, InterruptedException {
FakeProcess fakeSimctlInstallProcess = new FakeProcess(0);
ProcessExecutorParams fakeSimctlInstallParams = ProcessExecutorParams.builder().setCommand(ImmutableList.of("path/to/simctl", "install", "70200ED8-EEF1-4BDB-BCCF-3595B137D67D", "Path/To/MyNeatApp.app")).build();
FakeProcessExecutor fakeProcessExecutor = new FakeProcessExecutor(ImmutableMap.of(fakeSimctlInstallParams, fakeSimctlInstallProcess));
AppleSimulatorController appleSimulatorController = new AppleSimulatorController(fakeProcessExecutor, SIMCTL_PATH, IOS_SIMULATOR_PATH);
boolean installed = appleSimulatorController.installBundleInSimulator("70200ED8-EEF1-4BDB-BCCF-3595B137D67D", Paths.get("Path/To/MyNeatApp.app"));
assertThat(installed, is(true));
}
use of com.facebook.buck.util.FakeProcess in project buck by facebook.
the class AppleSimulatorControllerTest method cannotStartSimulatorWhenSimulatorWithDifferentUdidExists.
@Test
public void cannotStartSimulatorWhenSimulatorWithDifferentUdidExists() 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("70200ED8-EEF1-4BDB-BCCF-3595B137D67D"), is(false));
}
use of com.facebook.buck.util.FakeProcess in project buck by facebook.
the class AppleSimulatorControllerTest method startingSimulatorWorksWhenSimulatorNotRunning.
@Test
public void startingSimulatorWorksWhenSimulatorNotRunning() throws IOException, InterruptedException {
ImmutableList.Builder<Map.Entry<ProcessExecutorParams, FakeProcess>> fakeProcessesBuilder = ImmutableList.builder();
fakeProcessesBuilder.add(new SimpleImmutableEntry<>(SIMCTL_LIST_PARAMS, new FakeProcess(0)));
fakeProcessesBuilder.add(new SimpleImmutableEntry<>(ProcessExecutorParams.builder().setCommand(ImmutableList.of("open", "-a", IOS_SIMULATOR_PATH.toString(), "--args", "-CurrentDeviceUDID", "70200ED8-EEF1-4BDB-BCCF-3595B137D67D")).build(), new FakeProcess(0)));
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) (Booted)\n", "")));
FakeProcessExecutor fakeProcessExecutor = new FakeProcessExecutor(fakeProcessesBuilder.build());
AppleSimulatorController appleSimulatorController = new AppleSimulatorController(fakeProcessExecutor, SIMCTL_PATH, IOS_SIMULATOR_PATH);
Optional<Long> result = appleSimulatorController.startSimulator("70200ED8-EEF1-4BDB-BCCF-3595B137D67D", 1000);
assertThat(result, is(Optional.of(0L)));
}
use of com.facebook.buck.util.FakeProcess in project buck by facebook.
the class ExternalJavacTest method externalJavacWillHashTheExternalIfNoVersionInformationIsReturned.
@Test
public void externalJavacWillHashTheExternalIfNoVersionInformationIsReturned() throws IOException {
Path javac = Files.createTempFile("fake", "javac");
javac.toFile().deleteOnExit();
ProcessExecutorParams javacExe = ProcessExecutorParams.builder().addCommand(javac.toAbsolutePath().toString(), "-version").build();
FakeProcess javacProc = new FakeProcess(0, "", "");
final FakeProcessExecutor executor = new FakeProcessExecutor(ImmutableMap.of(javacExe, javacProc));
ExternalJavac compiler = new ExternalJavac(Either.ofLeft(javac)) {
@Override
ProcessExecutor createProcessExecutor() {
return executor;
}
};
RuleKeyObjectSink sink = createMock(RuleKeyObjectSink.class);
expect(sink.setReflectively("javac", javac.toString())).andReturn(sink);
replay(sink);
compiler.appendToRuleKey(sink);
}
use of com.facebook.buck.util.FakeProcess in project buck by facebook.
the class ExternalJavacTest method externalJavacWillHashTheJavacVersionIfPresent.
@Test
public void externalJavacWillHashTheJavacVersionIfPresent() throws IOException {
Path javac = Files.createTempFile("fake", "javac");
javac.toFile().deleteOnExit();
String reportedJavacVersion = "mozzarella";
JavacVersion javacVersion = JavacVersion.of(reportedJavacVersion);
ProcessExecutorParams javacExe = ProcessExecutorParams.builder().addCommand(javac.toAbsolutePath().toString(), "-version").build();
FakeProcess javacProc = new FakeProcess(0, "", reportedJavacVersion);
final FakeProcessExecutor executor = new FakeProcessExecutor(ImmutableMap.of(javacExe, javacProc));
ExternalJavac compiler = new ExternalJavac(Either.ofLeft(javac)) {
@Override
ProcessExecutor createProcessExecutor() {
return executor;
}
};
RuleKeyObjectSink sink = createMock(RuleKeyObjectSink.class);
expect(sink.setReflectively("javac.version", javacVersion.toString())).andReturn(sink);
replay(sink);
compiler.appendToRuleKey(sink);
}
Aggregations