Search in sources :

Example 1 with TemporaryPaths

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

the class CxxCompilationDatabaseIntegrationTest method compilationDatabaseWithDepsFetchedFromCacheAlsoFetchesSymlinkTreeOrHeaderMapOfDeps.

@Test
public void compilationDatabaseWithDepsFetchedFromCacheAlsoFetchesSymlinkTreeOrHeaderMapOfDeps() throws Exception {
    // Create a new temporary path since this test uses a different testdata directory than the
    // one used in the common setup method.
    tmp.after();
    tmp = new TemporaryPaths();
    tmp.before();
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "compilation_database_with_deps", tmp);
    workspace.setUp();
    workspace.writeContentsToPath("[cxx]\ngtest_dep = //:fake-gtest\nsandbox_sources=" + sandboxSources, ".buckconfig");
    ProjectFilesystem filesystem = new FakeProjectFilesystem();
    // This test only fails if the directory cache is enabled and we don't update
    // the header map/symlink tree correctly when fetching from the cache.
    workspace.enableDirCache();
    addDepLibraryHeaderFiles(workspace);
    BuildTarget target = BuildTargetFactory.newInstance("//:library_with_header#default,compilation-database");
    // Populate the cache with the built rule
    workspace.buildAndReturnOutput(target.getFullyQualifiedName());
    Path dep1ExportedSymlinkTreeFolder = CxxDescriptionEnhancer.getHeaderSymlinkTreePath(filesystem, BuildTargetFactory.newInstance("//dep1:dep1"), HeaderVisibility.PUBLIC, CxxPlatformUtils.getHeaderModeForDefaultPlatform(tmp.getRoot()).getFlavor());
    Path dep2ExportedSymlinkTreeFolder = CxxDescriptionEnhancer.getHeaderSymlinkTreePath(filesystem, BuildTargetFactory.newInstance("//dep2:dep2"), HeaderVisibility.PUBLIC, CxxPlatformUtils.getHeaderModeForDefaultPlatform(tmp.getRoot()).getFlavor());
    // Validate the deps' symlink tree/header maps
    verifyHeaders(workspace, dep1ExportedSymlinkTreeFolder, "dep1/dep1.h", "dep1/dep1_new.h");
    verifyHeaders(workspace, dep2ExportedSymlinkTreeFolder, "dep2/dep2.h", "dep2/dep2_new.h");
    // Delete the newly-added files and build again
    Files.delete(workspace.getPath("dep1/dep1_new.h"));
    Files.delete(workspace.getPath("dep2/dep2_new.h"));
    workspace.buildAndReturnOutput(target.getFullyQualifiedName());
    verifyHeaders(workspace, dep1ExportedSymlinkTreeFolder, "dep1/dep1.h");
    verifyHeaders(workspace, dep2ExportedSymlinkTreeFolder, "dep2/dep2.h");
    // Restore the headers, build again, and check the deps' symlink tree/header maps
    addDepLibraryHeaderFiles(workspace);
    workspace.buildAndReturnOutput(target.getFullyQualifiedName());
    verifyHeaders(workspace, dep1ExportedSymlinkTreeFolder, "dep1/dep1.h", "dep1/dep1_new.h");
    verifyHeaders(workspace, dep2ExportedSymlinkTreeFolder, "dep2/dep2.h", "dep2/dep2_new.h");
}
Also used : Path(java.nio.file.Path) ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) BuildTarget(com.facebook.buck.model.BuildTarget) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) TemporaryPaths(com.facebook.buck.testutil.integration.TemporaryPaths) Test(org.junit.Test)

Example 2 with TemporaryPaths

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

the class CxxCompilationDatabaseIntegrationTest method compilationDatabaseWithGeneratedFilesFetchedFromCacheAlsoFetchesGeneratedSources.

@Test
public void compilationDatabaseWithGeneratedFilesFetchedFromCacheAlsoFetchesGeneratedSources() throws Exception {
    // Create a new temporary path since this test uses a different testdata directory than the
    // one used in the common setup method.
    tmp.after();
    tmp = new TemporaryPaths();
    tmp.before();
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "compilation_database_with_generated_files", tmp);
    workspace.setUp();
    workspace.enableDirCache();
    BuildTarget target = BuildTargetFactory.newInstance("//dep1:dep1#default,compilation-database");
    workspace.runBuckBuild(target.getFullyQualifiedName()).assertSuccess();
    workspace.runBuckCommand("clean").assertSuccess();
    workspace.runBuckBuild(target.getFullyQualifiedName()).assertSuccess();
    ProjectFilesystem filesystem = new FakeProjectFilesystem();
    BuildTarget sourceTarget = BuildTargetFactory.newInstance("//dep1:source");
    Path source = workspace.getPath(BuildTargets.getGenPath(filesystem, sourceTarget, "%s"));
    assertThat(Files.exists(source), is(true));
}
Also used : Path(java.nio.file.Path) ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) BuildTarget(com.facebook.buck.model.BuildTarget) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) TemporaryPaths(com.facebook.buck.testutil.integration.TemporaryPaths) Test(org.junit.Test)

Example 3 with TemporaryPaths

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

the class CxxCompilationDatabaseIntegrationTest method compilationDatabaseWithGeneratedFilesFetchedFromCacheAlsoFetchesGeneratedHeaders.

@Test
public void compilationDatabaseWithGeneratedFilesFetchedFromCacheAlsoFetchesGeneratedHeaders() throws Exception {
    // Create a new temporary path since this test uses a different testdata directory than the
    // one used in the common setup method.
    tmp.after();
    tmp = new TemporaryPaths();
    tmp.before();
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "compilation_database_with_generated_files", tmp);
    workspace.setUp();
    workspace.enableDirCache();
    BuildTarget target = BuildTargetFactory.newInstance("//:binary_with_dep#default,compilation-database");
    workspace.runBuckBuild(target.getFullyQualifiedName()).assertSuccess();
    workspace.runBuckCommand("clean").assertSuccess();
    workspace.runBuckBuild(target.getFullyQualifiedName()).assertSuccess();
    ProjectFilesystem filesystem = new FakeProjectFilesystem();
    BuildTarget headerTarget = BuildTargetFactory.newInstance("//dep1:header");
    Path header = workspace.getPath(BuildTargets.getGenPath(filesystem, headerTarget, "%s"));
    assertThat(Files.exists(header), is(true));
}
Also used : Path(java.nio.file.Path) ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) BuildTarget(com.facebook.buck.model.BuildTarget) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) TemporaryPaths(com.facebook.buck.testutil.integration.TemporaryPaths) Test(org.junit.Test)

Aggregations

ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)3 BuildTarget (com.facebook.buck.model.BuildTarget)3 FakeProjectFilesystem (com.facebook.buck.testutil.FakeProjectFilesystem)3 ProjectWorkspace (com.facebook.buck.testutil.integration.ProjectWorkspace)3 TemporaryPaths (com.facebook.buck.testutil.integration.TemporaryPaths)3 Path (java.nio.file.Path)3 Test (org.junit.Test)3