use of com.facebook.buck.util.ProcessExecutor in project buck by facebook.
the class OcamlRuleBuilder method executeProcessAndGetStdout.
private static Optional<String> executeProcessAndGetStdout(Path baseDir, ImmutableList<String> cmd) throws IOException, InterruptedException {
ImmutableSet.Builder<ProcessExecutor.Option> options = ImmutableSet.builder();
options.add(ProcessExecutor.Option.EXPECTING_STD_OUT);
ProcessExecutor exe = new DefaultProcessExecutor(Console.createNullConsole());
ProcessExecutorParams params = ProcessExecutorParams.builder().setCommand(cmd).setDirectory(baseDir).build();
ProcessExecutor.Result result = exe.launchAndExecute(params, options.build(), /* stdin */
Optional.empty(), /* timeOutMs */
Optional.empty(), /* timeOutHandler */
Optional.empty());
if (result.getExitCode() != 0) {
throw new HumanReadableException(result.getStderr().get());
}
return result.getStdout();
}
use of com.facebook.buck.util.ProcessExecutor in project buck by facebook.
the class CodeSignIdentityStoreTest method testCodeSignIdentitiesCommandOverride.
@Test
public void testCodeSignIdentitiesCommandOverride() throws Exception {
ProcessExecutor executor = new DefaultProcessExecutor(new TestConsole());
Path testdataDir = TestDataHelper.getTestDataDirectory(this).resolve("code_sign_identity_store");
CodeSignIdentityStore store = CodeSignIdentityStore.fromSystem(executor, ImmutableList.of(testdataDir.resolve("fake_identities.sh").toString()));
ImmutableList<CodeSignIdentity> expected = ImmutableList.of(CodeSignIdentity.builder().setFingerprint(CodeSignIdentity.toFingerprint("0000000000000000000000000000000000000000")).setSubjectCommonName("iPhone Developer: Fake").build());
assertThat(store.getIdentities(), is(equalTo(expected)));
}
use of com.facebook.buck.util.ProcessExecutor in project buck by facebook.
the class ProvisioningProfileMetadataTest method testParseProvisioningProfileFile.
@Test
public void testParseProvisioningProfileFile() throws Exception {
assumeTrue(Platform.detect() == Platform.MACOS);
ProcessExecutor executor = new DefaultProcessExecutor(new TestConsole());
Path testdataDir = TestDataHelper.getTestDataDirectory(this).resolve("provisioning_profiles");
Path testFile = testdataDir.resolve("sample.mobileprovision");
ProvisioningProfileMetadata data = ProvisioningProfileMetadata.fromProvisioningProfilePath(executor, ProvisioningProfileStore.DEFAULT_READ_COMMAND, testFile);
assertThat(data.getExpirationDate(), is(equalTo(new NSDate("9999-03-05T01:33:40Z").getDate())));
assertThat(data.getAppID(), is(equalTo(new Pair<>("ABCDE12345", "com.example.TestApp"))));
assertThat(data.getUUID(), is(equalTo("00000000-0000-0000-0000-000000000000")));
assertThat(data.getProfilePath(), is(equalTo(testFile)));
assertThat(data.getDeveloperCertificateFingerprints(), equalTo(ImmutableSet.of(HashCode.fromString("be16fc419bfb6b59a86bc08755ba0f332ec574fb"))));
// Test old-style provisioning profile without "Platforms" field
data = ProvisioningProfileMetadata.fromProvisioningProfilePath(executor, ProvisioningProfileStore.DEFAULT_READ_COMMAND, testdataDir.resolve("sample_without_platforms.mobileprovision"));
assertThat(data.getDeveloperCertificateFingerprints(), equalTo(ImmutableSet.of(HashCode.fromString("be16fc419bfb6b59a86bc08755ba0f332ec574fb"))));
thrown.expect(IOException.class);
ProvisioningProfileMetadata.fromProvisioningProfilePath(executor, ProvisioningProfileStore.DEFAULT_READ_COMMAND, testdataDir.resolve("invalid.mobileprovision"));
}
use of com.facebook.buck.util.ProcessExecutor in project buck by facebook.
the class ProvisioningProfileMetadataTest method testFilteredEntitlementsStripOut.
@Test
public void testFilteredEntitlementsStripOut() throws Exception {
assumeTrue(Platform.detect() == Platform.MACOS);
ProcessExecutor executor = new DefaultProcessExecutor(new TestConsole());
Path testdataDir = TestDataHelper.getTestDataDirectory(this).resolve("provisioning_profiles");
Path testFile = testdataDir.resolve("sample.mobileprovision");
ProvisioningProfileMetadata data = ProvisioningProfileMetadata.fromProvisioningProfilePath(executor, ProvisioningProfileStore.DEFAULT_READ_COMMAND, testFile);
assertTrue(data.getEntitlements().containsKey("com.apple.developer.icloud-container-development-container-identifiers"));
assertFalse(data.getMergeableEntitlements().containsKey("com.apple.developer.icloud-container-development-container-identifiers"));
}
use of com.facebook.buck.util.ProcessExecutor in project buck by facebook.
the class InstallCommandIntegrationTest method appleBundleInstallsAndRunsInIphoneSimulatorWithDwarfDebugging.
@Test
public void appleBundleInstallsAndRunsInIphoneSimulatorWithDwarfDebugging() throws IOException, InterruptedException {
assumeThat(Platform.detect(), is(Platform.MACOS));
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "apple_app_bundle", tmp);
workspace.setUp();
workspace.enableDirCache();
// build locally
ProcessResult result = workspace.runBuckCommand("install", "--config", "apple.default_debug_info_format_for_binaries=DWARF", "--config", "apple.default_debug_info_format_for_libraries=DWARF", "--config", "apple.default_debug_info_format_for_tests=DWARF", "-r", "//:DemoApp");
assumeFalse(result.getStderr().contains("no appropriate simulator found"));
result.assertSuccess();
// find port to connect lldb to
// "lldb -p 12345"
Pattern p = Pattern.compile("lldb -p \\d{1,6}");
Matcher matcher = p.matcher(result.getStderr());
assertThat(matcher.find(), equalTo(true));
String[] lldbCommand = matcher.group().split(" ");
ProcessExecutor executor = new DefaultProcessExecutor(new TestConsole());
// run lldb session
ProcessExecutor.Result lldbResult = executor.launchAndExecute(ProcessExecutorParams.builder().addCommand(lldbCommand).build(), ImmutableSet.of(), Optional.of("b application:didFinishLaunchingWithOptions:\nb\nexit\nY\n"), Optional.empty(), Optional.empty());
assertThat(lldbResult.getExitCode(), equalTo(0));
// check that lldb resolved breakpoint locations
String lldbOutput = lldbResult.getStdout().orElse("");
assertThat(lldbOutput, containsString("Current breakpoints:"));
assertThat(lldbOutput, containsString("name = 'application:didFinishLaunchingWithOptions:', " + "locations = 1, resolved = 1, hit count = 0"));
// clean buck out
workspace.runBuckCommand("clean");
// build again - get everything from cache now
result = workspace.runBuckCommand("install", "--config", "apple.default_debug_info_format_for_binaries=DWARF", "--config", "apple.default_debug_info_format_for_libraries=DWARF", "--config", "apple.default_debug_info_format_for_tests=DWARF", "-r", "//:DemoApp");
result.assertSuccess();
matcher = p.matcher(result.getStderr());
assertThat(matcher.find(), equalTo(true));
String[] lldbCommand2 = matcher.group().split(" ");
// run lldb session again - now on top of files fetched from cache
lldbResult = executor.launchAndExecute(ProcessExecutorParams.builder().addCommand(lldbCommand2).build(), ImmutableSet.of(), Optional.of("b application:didFinishLaunchingWithOptions:\nb\nexit\nY\n"), Optional.empty(), Optional.empty());
assertThat(lldbResult.getExitCode(), equalTo(0));
// check that lldb resolved breakpoint locations with files from cache
lldbOutput = lldbResult.getStdout().orElse("");
assertThat(lldbOutput, containsString("Current breakpoints:"));
assertThat(lldbOutput, containsString("name = 'application:didFinishLaunchingWithOptions:', " + "locations = 1, resolved = 1, hit count = 0"));
}
Aggregations