Search in sources :

Example 31 with DefaultProcessExecutor

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

the class ProvisioningProfileCopyStepTest method testEntitlementsDoesNotMergeInvalidProfileKeys.

@Test
public void testEntitlementsDoesNotMergeInvalidProfileKeys() 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.of(entitlementsFile), 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 32 with DefaultProcessExecutor

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

the class ProvisioningProfileCopyStepTest method testFailsWithInvalidInfoPlist.

@Test
public void testFailsWithInvalidInfoPlist() throws Exception {
    assumeTrue(Platform.detect() == Platform.MACOS);
    thrown.expect(HumanReadableException.class);
    thrown.expectMessage(startsWith("Unable to get bundle ID from info.plist"));
    ProvisioningProfileCopyStep step = new ProvisioningProfileCopyStep(projectFilesystem, testdataDir.resolve("Invalid.plist"), ApplePlatform.IPHONEOS, Optional.empty(), Optional.empty(), 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 33 with DefaultProcessExecutor

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

the class ProvisioningProfileMetadataTest method testProvisioningProfileReadCommandOverride.

@Test
public void testProvisioningProfileReadCommandOverride() throws Exception {
    ProcessExecutor executor = new DefaultProcessExecutor(new TestConsole());
    Path testdataDir = TestDataHelper.getTestDataDirectory(this).resolve("provisioning_profiles");
    ProvisioningProfileMetadata data = ProvisioningProfileMetadata.fromProvisioningProfilePath(executor, ImmutableList.of(testdataDir.resolve("fake_read_command.sh").toString()), Paths.get("unused"));
    assertThat(data.getAppID(), is(equalTo(new Pair<>("0000000000", "com.example.override"))));
}
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 34 with DefaultProcessExecutor

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

the class LuaBinaryIntegrationTest method setUp.

@Before
public void setUp() throws Exception {
    // We don't currently support windows.
    assumeThat(Platform.detect(), Matchers.not(Platform.WINDOWS));
    // Verify that a Lua interpreter is available on the system.
    LuaBuckConfig fakeConfig = new LuaBuckConfig(FakeBuckConfig.builder().build(), new ExecutableFinder());
    Optional<Path> luaOptional = fakeConfig.getSystemLua();
    assumeTrue(luaOptional.isPresent());
    lua = luaOptional.get();
    // Try to detect if a Lua devel package is available, which is needed to C/C++ support.
    BuildRuleResolver resolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
    CxxPlatform cxxPlatform = DefaultCxxPlatforms.build(Platform.detect(), new FakeProjectFilesystem(), new CxxBuckConfig(FakeBuckConfig.builder().build()));
    ProcessExecutorParams params = ProcessExecutorParams.builder().setCommand(ImmutableList.<String>builder().addAll(cxxPlatform.getCc().resolve(resolver).getCommandPrefix(new SourcePathResolver(new SourcePathRuleFinder(resolver)))).add("-includelua.h", "-E", "-").build()).setRedirectInput(ProcessBuilder.Redirect.PIPE).build();
    ProcessExecutor executor = new DefaultProcessExecutor(Console.createNullConsole());
    ProcessExecutor.LaunchedProcess launchedProcess = executor.launchProcess(params);
    launchedProcess.getOutputStream().close();
    int exitCode = executor.waitForLaunchedProcess(launchedProcess).getExitCode();
    luaDevel = exitCode == 0;
    if (starterType == LuaBinaryDescription.StarterType.NATIVE) {
        assumeTrue("Lua devel package required for native starter", luaDevel);
    }
    // Setup the workspace.
    workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "lua_binary", tmp);
    workspace.setUp();
    workspace.writeContentsToPath(Joiner.on(System.lineSeparator()).join(ImmutableList.of("[lua]", "  starter_type = " + starterType.toString().toLowerCase(), "  native_link_strategy = " + nativeLinkStrategy.toString().toLowerCase(), "[cxx]", "  sandbox_sources =" + sandboxSources)), ".buckconfig");
    LuaBuckConfig config = getLuaBuckConfig();
    assertThat(config.getStarterType(), Matchers.equalTo(Optional.of(starterType)));
    assertThat(config.getNativeLinkStrategy(), Matchers.equalTo(nativeLinkStrategy));
}
Also used : Path(java.nio.file.Path) FakeExecutableFinder(com.facebook.buck.io.FakeExecutableFinder) ExecutableFinder(com.facebook.buck.io.ExecutableFinder) ProcessExecutorParams(com.facebook.buck.util.ProcessExecutorParams) DefaultProcessExecutor(com.facebook.buck.util.DefaultProcessExecutor) CxxPlatform(com.facebook.buck.cxx.CxxPlatform) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) Matchers.containsString(org.hamcrest.Matchers.containsString) ProcessExecutor(com.facebook.buck.util.ProcessExecutor) DefaultProcessExecutor(com.facebook.buck.util.DefaultProcessExecutor) CxxBuckConfig(com.facebook.buck.cxx.CxxBuckConfig) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) Before(org.junit.Before)

Example 35 with DefaultProcessExecutor

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

the class PrebuiltPythonLibraryIntegrationTest method setUp.

@Before
public void setUp() throws IOException, InterruptedException {
    workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "prebuilt_package", tmp);
    workspace.setUp();
    // EGGs are versioned to the version of Python they were built it, but the EGG for this test
    // doesn't actually matter.
    String version = new PythonBuckConfig(FakeBuckConfig.builder().build(), new ExecutableFinder()).getPythonEnvironment(new DefaultProcessExecutor(new TestConsole(Verbosity.SILENT))).getPythonVersion().getVersionString();
    if (!version.startsWith("2.6")) {
        workspace.move("dist/package-0.1-py2.6.egg", "dist/package-0.1-py" + version.substring(0, 3) + ".egg");
    }
}
Also used : ExecutableFinder(com.facebook.buck.io.ExecutableFinder) DefaultProcessExecutor(com.facebook.buck.util.DefaultProcessExecutor) TestConsole(com.facebook.buck.testutil.TestConsole) Before(org.junit.Before)

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