use of com.facebook.buck.util.FakeProcessExecutor 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.FakeProcessExecutor 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.FakeProcessExecutor in project buck by facebook.
the class AppleConfigTest method getUnspecifiedAppleDeveloperDirectorySupplier.
@Test
public void getUnspecifiedAppleDeveloperDirectorySupplier() {
BuckConfig buckConfig = FakeBuckConfig.builder().build();
AppleConfig config = new AppleConfig(buckConfig);
assertNotNull(config.getAppleDeveloperDirectorySupplier(new FakeProcessExecutor()));
}
use of com.facebook.buck.util.FakeProcessExecutor in project buck by facebook.
the class AppleConfigTest method getSpecifiedAppleDeveloperDirectorySupplier.
@Test
public void getSpecifiedAppleDeveloperDirectorySupplier() {
BuckConfig buckConfig = FakeBuckConfig.builder().setSections(ImmutableMap.of("apple", ImmutableMap.of("xcode_developer_dir", "/path/to/somewhere"))).build();
AppleConfig config = new AppleConfig(buckConfig);
Supplier<Optional<Path>> supplier = config.getAppleDeveloperDirectorySupplier(new FakeProcessExecutor());
assertNotNull(supplier);
assertEquals(Optional.of(Paths.get("/path/to/somewhere")), supplier.get());
// Developer directory for tests should fall back to developer dir if not separately specified.
Supplier<Optional<Path>> supplierForTests = config.getAppleDeveloperDirectorySupplierForTests(new FakeProcessExecutor());
assertNotNull(supplierForTests);
assertEquals(Optional.of(Paths.get("/path/to/somewhere")), supplierForTests.get());
}
use of com.facebook.buck.util.FakeProcessExecutor 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)));
}
Aggregations