use of com.facebook.buck.util.FakeProcess in project buck by facebook.
the class CodeSignIdentityStoreTest method testInvalidIdentitiesAreIgnored.
@Test
public void testInvalidIdentitiesAreIgnored() throws Exception {
ProcessExecutorParams processExecutorParams = ProcessExecutorParams.builder().addCommand("unused").build();
FakeProcess process = new FakeProcess(0, " 1) AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA " + "\"iPhone Developer: Foo Bar (ABCDE12345)\" (CSSMERR_TP_CERT_REVOKED)\n" + " 2) AAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBB " + "\"iPhone Developer: Foo Bar (12345ABCDE)\" (CSSMERR_TP_CERT_EXPIRED)\n" + " 3) BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB " + "\"iPhone Developer: Foo Bar (54321EDCBA)\"\n" + " 3 valid identities found\n", "");
FakeProcessExecutor processExecutor = new FakeProcessExecutor(ImmutableMap.of(processExecutorParams, process));
CodeSignIdentityStore store = CodeSignIdentityStore.fromSystem(processExecutor, ImmutableList.of("unused"));
ImmutableList<CodeSignIdentity> expected = ImmutableList.of(CodeSignIdentity.builder().setFingerprint(CodeSignIdentity.toFingerprint("BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB")).setSubjectCommonName("iPhone Developer: Foo Bar (54321EDCBA)").build());
assertThat(store.getIdentities(), equalTo(expected));
}
use of com.facebook.buck.util.FakeProcess in project buck by facebook.
the class AppleConfigTest method getXcodeSelectDetectedAppleDeveloperDirectorySupplier.
@Test
public void getXcodeSelectDetectedAppleDeveloperDirectorySupplier() {
BuckConfig buckConfig = FakeBuckConfig.builder().build();
AppleConfig config = new AppleConfig(buckConfig);
ProcessExecutorParams xcodeSelectParams = ProcessExecutorParams.builder().setCommand(ImmutableList.of("xcode-select", "--print-path")).build();
FakeProcess fakeXcodeSelect = new FakeProcess(0, "/path/to/another/place", "");
FakeProcessExecutor processExecutor = new FakeProcessExecutor(ImmutableMap.of(xcodeSelectParams, fakeXcodeSelect));
Supplier<Optional<Path>> supplier = config.getAppleDeveloperDirectorySupplier(processExecutor);
assertNotNull(supplier);
assertEquals(Optional.of(Paths.get("/path/to/another/place")), supplier.get());
}
use of com.facebook.buck.util.FakeProcess in project buck by facebook.
the class XctoolRunTestsStepTest method xctoolCommandWhichReturnsExitCode400FailsStep.
@Test
public void xctoolCommandWhichReturnsExitCode400FailsStep() 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(400, "", "");
FakeProcessExecutor processExecutor = new FakeProcessExecutor(ImmutableMap.of(xctoolParams, fakeXctoolFailure));
ExecutionContext executionContext = TestExecutionContext.newBuilder().setProcessExecutor(processExecutor).setEnvironment(ImmutableMap.of()).build();
assertThat(step.execute(executionContext).getExitCode(), not(equalTo(0)));
}
use of com.facebook.buck.util.FakeProcess in project buck by facebook.
the class XctoolRunTestsStepTest method xctoolCommandWithTestSelectorFailsIfListTestsOnlyFails.
@Test
public void xctoolCommandWithTestSelectorFailsIfListTestsOnlyFails() 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();
FakeProcess fakeXctoolListTestsFailureProcess = new FakeProcess(42, "", "Chopper Dave, we have Uh-Oh");
FakeProcessExecutor processExecutor = new FakeProcessExecutor(ImmutableMap.of(xctoolListOnlyParams, fakeXctoolListTestsFailureProcess));
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(), allOf(containsString("xctool failed with exit code 42: Chopper Dave, we have Uh-Oh"), containsString("Failed to query tests with xctool")));
}
use of com.facebook.buck.util.FakeProcess in project buck by facebook.
the class XctoolRunTestsStepTest method xctoolCommandWhichReturnsExitCode1DoesNotFailStep.
@Test
public void xctoolCommandWhichReturnsExitCode1DoesNotFailStep() 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();
// Test failure is indicated by xctool exiting with exit code 1, so it shouldn't
// fail the step.
FakeProcess fakeXctoolTestFailure = new FakeProcess(1, "", "");
FakeProcessExecutor processExecutor = new FakeProcessExecutor(ImmutableMap.of(xctoolParams, fakeXctoolTestFailure));
ExecutionContext executionContext = TestExecutionContext.newBuilder().setProcessExecutor(processExecutor).setEnvironment(ImmutableMap.of()).build();
assertThat(step.execute(executionContext).getExitCode(), equalTo(0));
}
Aggregations