use of com.facebook.buck.util.ProcessExecutorParams in project buck by facebook.
the class XctoolRunTestsStepTest method xctoolCommandWithOnlyLogicTests.
@Test
public void xctoolCommandWithOnlyLogicTests() 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 fakeXctoolSuccess = new FakeProcess(0, "", "");
FakeProcessExecutor processExecutor = new FakeProcessExecutor(ImmutableMap.of(xctoolParams, fakeXctoolSuccess));
ExecutionContext executionContext = TestExecutionContext.newBuilder().setProcessExecutor(processExecutor).setEnvironment(ImmutableMap.of()).build();
assertThat(step.execute(executionContext).getExitCode(), equalTo(0));
}
use of com.facebook.buck.util.ProcessExecutorParams in project buck by facebook.
the class XctoolRunTestsStepTest method testDirectoryAndLevelPassedInEnvironment.
@Test
public void testDirectoryAndLevelPassedInEnvironment() 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.of("TEST_LOG_PATH"), Optional.of(Paths.get("/path/to/test-logs")), Optional.of("TEST_LOG_LEVEL"), Optional.of("verbose"), Optional.empty(), Optional.of("/path/to/snapshotimages"));
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", "XCTOOL_TEST_ENV_TEST_LOG_PATH", "/path/to/test-logs", "XCTOOL_TEST_ENV_TEST_LOG_LEVEL", "verbose", "XCTOOL_TEST_ENV_FB_REFERENCE_IMAGE_DIR", "/path/to/snapshotimages")).setDirectory(projectFilesystem.getRootPath().toAbsolutePath()).setRedirectOutput(ProcessBuilder.Redirect.PIPE).build();
FakeProcess fakeXctoolSuccess = new FakeProcess(0, "", "");
FakeProcessExecutor processExecutor = new FakeProcessExecutor(ImmutableMap.of(xctoolParams, fakeXctoolSuccess));
ExecutionContext executionContext = TestExecutionContext.newBuilder().setProcessExecutor(processExecutor).setEnvironment(ImmutableMap.of()).build();
assertThat(step.execute(executionContext).getExitCode(), equalTo(0));
}
use of com.facebook.buck.util.ProcessExecutorParams in project buck by facebook.
the class XctoolRunTestsStepTest method xctoolCommandWithTestSelectorFiltersTests.
@Test
public void xctoolCommandWithTestSelectorFiltersTests() 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("#.*Magic.*").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);
ProcessExecutorParams xctoolRunTestsParamsWithOnlyFilters = ProcessExecutorParams.builder().addCommand("/path/to/xctool", "-reporter", "json-stream", "-sdk", "iphonesimulator", "run-tests", "-logicTest", "/path/to/FooTest.xctest", "-logicTest", "/path/to/BarTest.xctest", "-only", "/path/to/FooTest.xctest:FooTest/testMagicValue,FooTest/testAnotherMagicValue", "-only", "/path/to/BarTest.xctest:BarTest/testYetAnotherMagicValue").setEnvironment(ImmutableMap.of("DEVELOPER_DIR", "/path/to/developer/dir")).setDirectory(projectFilesystem.getRootPath().toAbsolutePath()).setRedirectOutput(ProcessBuilder.Redirect.PIPE).build();
FakeProcess fakeXctoolSuccess = new FakeProcess(0, "", "");
FakeProcessExecutor processExecutor = new FakeProcessExecutor(ImmutableMap.of(xctoolListOnlyParams, fakeXctoolListTestsProcess, // the return value of this xctool is, so we make it always succeed.)
xctoolRunTestsParamsWithOnlyFilters, fakeXctoolSuccess));
ExecutionContext executionContext = TestExecutionContext.newBuilder().setProcessExecutor(processExecutor).setEnvironment(ImmutableMap.of()).build();
assertThat(step.execute(executionContext).getExitCode(), equalTo(0));
}
}
use of com.facebook.buck.util.ProcessExecutorParams 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.ProcessExecutorParams 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);
}
Aggregations