Search in sources :

Example 16 with ProjectWorkspace

use of com.facebook.buck.testutil.integration.ProjectWorkspace in project buck by facebook.

the class NdkCxxPlatformIntegrationTest method testWorkingDirectoryAndNdkHeaderPathsAreSanitized.

@Test
public void testWorkingDirectoryAndNdkHeaderPathsAreSanitized() throws IOException {
    ProjectWorkspace workspace = setupWorkspace("ndk_debug_paths");
    workspace.writeContentsToPath("[ndk]\n" + "  cpu_abis = arm, armv7, arm64, x86, x86_64\n" + "  gcc_version = 4.9\n" + "  app_platform = android-21\n", ".buckconfig");
    ProjectFilesystem filesystem = new ProjectFilesystem(workspace.getDestPath());
    BuildTarget target = BuildTargetFactory.newInstance(String.format("//:lib#android-%s,static", arch));
    workspace.runBuckBuild(target.getFullyQualifiedName()).assertSuccess();
    Path lib = workspace.getPath(BuildTargets.getGenPath(filesystem, target, "%s/lib" + target.getShortName() + ".a"));
    String contents = MorePaths.asByteSource(lib).asCharSource(Charsets.ISO_8859_1).read();
    // Verify that the working directory is sanitized.
    assertFalse(contents.contains(tmp.getRoot().toString()));
    // Verify that we don't have any references to the build toolchain in the debug info.
    for (NdkCxxPlatforms.Host host : NdkCxxPlatforms.Host.values()) {
        assertFalse(contents.contains(host.toString()));
    }
    // Verify that the NDK path is sanitized.
    assertFalse(contents.contains(getNdkRoot().toString()));
}
Also used : Path(java.nio.file.Path) ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) BuildTarget(com.facebook.buck.model.BuildTarget) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) Test(org.junit.Test)

Example 17 with ProjectWorkspace

use of com.facebook.buck.testutil.integration.ProjectWorkspace in project buck by facebook.

the class NdkLibraryIntegrationTest method cxxLibraryDep.

@Test
public void cxxLibraryDep() throws IOException {
    AssumeAndroidPlatform.assumeNdkIsAvailable();
    ProjectWorkspace workspace1 = TestDataHelper.createProjectWorkspaceForScenario(this, "cxx_deps", tmp1);
    workspace1.setUp();
    workspace1.runBuckBuild("//jni:foo").assertSuccess();
    ProjectWorkspace workspace2 = TestDataHelper.createProjectWorkspaceForScenario(this, "cxx_deps", tmp2);
    workspace2.setUp();
    workspace2.runBuckBuild("//jni:foo").assertSuccess();
    // Verify that rule keys generated from building in two different working directories
    // does not affect the rule key.
    assertNotEquals(workspace1.resolve(Paths.get("test")), workspace2.resolve(Paths.get("test")));
    assertEquals(workspace1.getBuildLog().getRuleKey("//jni:foo"), workspace2.getBuildLog().getRuleKey("//jni:foo"));
}
Also used : ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) Test(org.junit.Test)

Example 18 with ProjectWorkspace

use of com.facebook.buck.testutil.integration.ProjectWorkspace in project buck by facebook.

the class GenAidlIntegrationTest method buildingCleaningAndThenRebuildingFromCacheShouldWorkAsExpected.

@Test
public void buildingCleaningAndThenRebuildingFromCacheShouldWorkAsExpected() throws IOException {
    AssumeAndroidPlatform.assumeSdkIsAvailable();
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "cached_build", tmp);
    workspace.setUp();
    workspace.enableDirCache();
    // Populate the cache
    ProjectWorkspace.ProcessResult result = workspace.runBuckBuild("//:android-lib");
    result.assertSuccess();
    result = workspace.runBuckCommand("clean");
    result.assertSuccess();
    // Now the cache is clean, do the build where we expect the results to come from the cache
    result = workspace.runBuckBuild("//:android-lib");
    result.assertSuccess();
}
Also used : ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) Test(org.junit.Test)

Example 19 with ProjectWorkspace

use of com.facebook.buck.testutil.integration.ProjectWorkspace in project buck by facebook.

the class GenAidlIntegrationTest method rootDirectoryDoesntChangeBuild.

@Test
public void rootDirectoryDoesntChangeBuild() throws IOException {
    AssumeAndroidPlatform.assumeSdkIsAvailable();
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "cached_build", tmp);
    workspace.setUp();
    Path outputOne = workspace.buildAndReturnOutput("//:AService");
    ProjectWorkspace workspaceTwo = TestDataHelper.createProjectWorkspaceForScenario(this, "cached_build", tmp2);
    workspaceTwo.setUp();
    Path outputTwo = workspaceTwo.buildAndReturnOutput("//:AService");
    assertEquals(workspace.getBuildLog().getRuleKey("//:AService"), workspaceTwo.getBuildLog().getRuleKey("//:AService"));
    try (ZipFile zipOne = new ZipFile(outputOne.toFile());
        ZipFile zipTwo = new ZipFile(outputTwo.toFile())) {
        Enumeration<? extends ZipEntry> entriesOne = zipOne.entries(), entriesTwo = zipTwo.entries();
        while (entriesOne.hasMoreElements()) {
            assertTrue(entriesTwo.hasMoreElements());
            ZipEntry entryOne = entriesOne.nextElement(), entryTwo = entriesTwo.nextElement();
            // Compare data first, otherwise crc difference will cause a failure and you don't get to
            // see the actual difference.
            assertEquals(zipEntryData(zipOne, entryOne), zipEntryData(zipTwo, entryTwo));
            assertEquals(zipEntryDebugString(entryOne), zipEntryDebugString(entryTwo));
        }
        assertFalse(entriesTwo.hasMoreElements());
    }
    assertEquals(new String(Files.readAllBytes(outputOne)), new String(Files.readAllBytes(outputTwo)));
}
Also used : Path(java.nio.file.Path) ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) ZipFile(java.util.zip.ZipFile) ZipEntry(java.util.zip.ZipEntry) Test(org.junit.Test)

Example 20 with ProjectWorkspace

use of com.facebook.buck.testutil.integration.ProjectWorkspace in project buck by facebook.

the class AppleBundleIntegrationTest method infoPlistSubstitutionsAreApplied.

@Test
public void infoPlistSubstitutionsAreApplied() throws Exception {
    assumeTrue(Platform.detect() == Platform.MACOS);
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "application_bundle_with_substitutions", tmp);
    workspace.setUp();
    BuildTarget target = workspace.newBuildTarget("//:DemoApp#iphonesimulator-x86_64,no-debug");
    workspace.runBuckCommand("build", target.getFullyQualifiedName()).assertSuccess();
    workspace.verify(Paths.get("DemoApp_output.expected"), BuildTargets.getGenPath(filesystem, BuildTarget.builder(target).addFlavors(AppleDescriptions.NO_INCLUDE_FRAMEWORKS_FLAVOR).build(), "%s"));
    Path appPath = BuildTargets.getGenPath(filesystem, BuildTarget.builder(target).addFlavors(AppleDescriptions.NO_INCLUDE_FRAMEWORKS_FLAVOR).build(), "%s").resolve(target.getShortName() + ".app");
    assertTrue(Files.exists(workspace.getPath(appPath.resolve(target.getShortName()))));
}
Also used : Path(java.nio.file.Path) ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) BuildTarget(com.facebook.buck.model.BuildTarget) Test(org.junit.Test)

Aggregations

ProjectWorkspace (com.facebook.buck.testutil.integration.ProjectWorkspace)747 Test (org.junit.Test)726 Path (java.nio.file.Path)219 BuildTarget (com.facebook.buck.model.BuildTarget)177 ProcessResult (com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult)127 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)89 Matchers.containsString (org.hamcrest.Matchers.containsString)50 BuckBuildLog (com.facebook.buck.testutil.integration.BuckBuildLog)47 ProcessExecutor (com.facebook.buck.util.ProcessExecutor)35 ZipInspector (com.facebook.buck.testutil.integration.ZipInspector)21 HumanReadableException (com.facebook.buck.util.HumanReadableException)14 OcamlRuleBuilder.createStaticLibraryBuildTarget (com.facebook.buck.ocaml.OcamlRuleBuilder.createStaticLibraryBuildTarget)13 TestConsole (com.facebook.buck.testutil.TestConsole)12 FakeProjectFilesystem (com.facebook.buck.testutil.FakeProjectFilesystem)10 DefaultProcessExecutor (com.facebook.buck.util.DefaultProcessExecutor)10 Cell (com.facebook.buck.rules.Cell)9 TestContext (com.facebook.buck.testutil.integration.TestContext)9 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)9 MappedByteBuffer (java.nio.MappedByteBuffer)9 FileChannel (java.nio.channels.FileChannel)9