Search in sources :

Example 6 with DefaultProcessExecutor

use of com.facebook.buck.util.DefaultProcessExecutor in project buck by facebook.

the class ProvisioningProfileCopyStepTest method testFailsWithInvalidEntitlementsPlist.

@Test
public void testFailsWithInvalidEntitlementsPlist() throws Exception {
    assumeTrue(Platform.detect() == Platform.MACOS);
    thrown.expect(HumanReadableException.class);
    thrown.expectMessage(startsWith("Malformed entitlement .plist: "));
    ProvisioningProfileCopyStep step = new ProvisioningProfileCopyStep(projectFilesystem, testdataDir.resolve("Info.plist"), ApplePlatform.IPHONEOS, Optional.empty(), Optional.of(testdataDir.resolve("Invalid.plist")), ProvisioningProfileStore.fromSearchPath(new DefaultProcessExecutor(new TestConsole()), ProvisioningProfileStore.DEFAULT_READ_COMMAND, testdataDir), outputFile, xcentFile, codeSignIdentityStore, Optional.empty());
    step.execute(executionContext);
}
Also used : DefaultProcessExecutor(com.facebook.buck.util.DefaultProcessExecutor) TestConsole(com.facebook.buck.testutil.TestConsole) Test(org.junit.Test)

Example 7 with DefaultProcessExecutor

use of com.facebook.buck.util.DefaultProcessExecutor in project buck by facebook.

the class ProvisioningProfileCopyStepTest method testNoEntitlementsDoesNotMergeInvalidProfileKeys.

@Test
public void testNoEntitlementsDoesNotMergeInvalidProfileKeys() throws Exception {
    assumeTrue(Platform.detect() == Platform.MACOS);
    ProvisioningProfileCopyStep step = new ProvisioningProfileCopyStep(projectFilesystem, testdataDir.resolve("Info.plist"), ApplePlatform.IPHONEOS, Optional.of("00000000-0000-0000-0000-000000000000"), Optional.empty(), ProvisioningProfileStore.fromSearchPath(new DefaultProcessExecutor(new TestConsole()), ProvisioningProfileStore.DEFAULT_READ_COMMAND, testdataDir), outputFile, xcentFile, codeSignIdentityStore, Optional.empty());
    step.execute(executionContext);
    ProvisioningProfileMetadata selectedProfile = step.getSelectedProvisioningProfileFuture().get().get();
    ImmutableMap<String, NSObject> profileEntitlements = selectedProfile.getEntitlements();
    assertTrue(profileEntitlements.containsKey("com.apple.developer.icloud-container-development-container-identifiers"));
    Optional<String> xcentContents = projectFilesystem.readFileIfItExists(xcentFile);
    assertTrue(xcentContents.isPresent());
    NSDictionary xcentPlist = (NSDictionary) PropertyListParser.parse(xcentContents.get().getBytes());
    assertFalse(xcentPlist.containsKey("com.apple.developer.icloud-container-development-container-identifiers"));
    assertEquals(xcentPlist.get("com.apple.developer.team-identifier"), profileEntitlements.get("com.apple.developer.team-identifier"));
}
Also used : NSObject(com.dd.plist.NSObject) DefaultProcessExecutor(com.facebook.buck.util.DefaultProcessExecutor) NSDictionary(com.dd.plist.NSDictionary) NSString(com.dd.plist.NSString) TestConsole(com.facebook.buck.testutil.TestConsole) Test(org.junit.Test)

Example 8 with DefaultProcessExecutor

use of com.facebook.buck.util.DefaultProcessExecutor 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"));
}
Also used : Path(java.nio.file.Path) DefaultProcessExecutor(com.facebook.buck.util.DefaultProcessExecutor) ProcessExecutor(com.facebook.buck.util.ProcessExecutor) DefaultProcessExecutor(com.facebook.buck.util.DefaultProcessExecutor) TestConsole(com.facebook.buck.testutil.TestConsole) NSDate(com.dd.plist.NSDate) Test(org.junit.Test)

Example 9 with DefaultProcessExecutor

use of com.facebook.buck.util.DefaultProcessExecutor 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"));
}
Also used : Path(java.nio.file.Path) DefaultProcessExecutor(com.facebook.buck.util.DefaultProcessExecutor) ProcessExecutor(com.facebook.buck.util.ProcessExecutor) DefaultProcessExecutor(com.facebook.buck.util.DefaultProcessExecutor) TestConsole(com.facebook.buck.testutil.TestConsole) Test(org.junit.Test)

Example 10 with DefaultProcessExecutor

use of com.facebook.buck.util.DefaultProcessExecutor 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"));
}
Also used : Pattern(java.util.regex.Pattern) ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) DefaultProcessExecutor(com.facebook.buck.util.DefaultProcessExecutor) Matcher(java.util.regex.Matcher) ProcessResult(com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult) Matchers.containsString(org.hamcrest.Matchers.containsString) ProcessExecutor(com.facebook.buck.util.ProcessExecutor) DefaultProcessExecutor(com.facebook.buck.util.DefaultProcessExecutor) TestConsole(com.facebook.buck.testutil.TestConsole) Test(org.junit.Test)

Aggregations

DefaultProcessExecutor (com.facebook.buck.util.DefaultProcessExecutor)37 TestConsole (com.facebook.buck.testutil.TestConsole)27 Test (org.junit.Test)21 ProcessExecutor (com.facebook.buck.util.ProcessExecutor)20 Path (java.nio.file.Path)13 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)8 ProcessExecutorParams (com.facebook.buck.util.ProcessExecutorParams)7 ExecutableFinder (com.facebook.buck.io.ExecutableFinder)5 FakeProjectFilesystem (com.facebook.buck.testutil.FakeProjectFilesystem)5 ProjectWorkspace (com.facebook.buck.testutil.integration.ProjectWorkspace)5 NSDictionary (com.dd.plist.NSDictionary)3 NSString (com.dd.plist.NSString)3 SymbolGetter (com.facebook.buck.android.AndroidNdkHelper.SymbolGetter)3 BuckConfig (com.facebook.buck.cli.BuckConfig)3 BuildRuleResolver (com.facebook.buck.rules.BuildRuleResolver)3 DefaultCellPathResolver (com.facebook.buck.rules.DefaultCellPathResolver)3 DefaultTargetNodeToBuildRuleTransformer (com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer)3 SourcePathResolver (com.facebook.buck.rules.SourcePathResolver)3 SourcePathRuleFinder (com.facebook.buck.rules.SourcePathRuleFinder)3 HumanReadableException (com.facebook.buck.util.HumanReadableException)3