Search in sources :

Example 31 with BuckBuildLog

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

the class CxxLibraryIntegrationTest method preferredLinkageOverridesParentLinkStyle.

@Test
public void preferredLinkageOverridesParentLinkStyle() throws Exception {
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "preferred_linkage", tmp);
    workspace.setUp();
    BuckBuildLog buildLog;
    workspace.runBuckBuild("//:foo-prefer-shared#default").assertSuccess();
    buildLog = workspace.getBuildLog();
    buildLog.assertTargetBuiltLocally("//:always_static#default,static-pic");
    buildLog.assertTargetBuiltLocally("//:always_shared#default,shared");
    buildLog.assertTargetBuiltLocally("//:agnostic#default,shared");
    buildLog.assertTargetBuiltLocally("//:foo-prefer-shared#default");
    workspace.runBuckBuild("//:foo-prefer-static#default").assertSuccess();
    buildLog = workspace.getBuildLog();
    buildLog.assertTargetBuiltLocally("//:always_static#default,static");
    buildLog.assertTargetHadMatchingRuleKey("//:always_shared#default,shared");
    buildLog.assertTargetBuiltLocally("//:agnostic#default,static");
    buildLog.assertTargetBuiltLocally("//:foo-prefer-static#default");
}
Also used : ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) BuckBuildLog(com.facebook.buck.testutil.integration.BuckBuildLog) Test(org.junit.Test)

Example 32 with BuckBuildLog

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

the class PrebuiltCxxLibraryIntegrationTest method prebuiltCxxLibraryFromGenrule.

@Test
public void prebuiltCxxLibraryFromGenrule() throws IOException {
    assumeTrue(Platform.detect() != Platform.WINDOWS);
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "prebuilt_cxx_from_genrule", tmp);
    workspace.setUp();
    workspace.enableDirCache();
    final String binaryTargetString = "//core:binary";
    final String staticBuildTargetString = "//test_lib:bar#static,default";
    final String sharedBuildTargetString = "//test_lib:bar#shared,default";
    workspace.runBuckBuild(binaryTargetString).assertSuccess();
    // Clean everything
    workspace.runBuckCommand("clean").assertSuccess();
    // After a clean make sure that everything was in cache.
    workspace.runBuckBuild(binaryTargetString).assertSuccess();
    BuckBuildLog buildLog = workspace.getBuildLog();
    buildLog.assertTargetWasFetchedFromCache(binaryTargetString);
    // Make sure that the static library isn't cached but can still be built.
    workspace.runBuckBuild(staticBuildTargetString).assertSuccess();
    buildLog = workspace.getBuildLog();
    buildLog.assertTargetBuiltLocally(staticBuildTargetString);
    workspace.runBuckBuild(sharedBuildTargetString).assertSuccess();
    workspace.runBuckBuild(binaryTargetString).assertSuccess();
    buildLog = workspace.getBuildLog();
    // Others will be MATCHING_RULE_KEY
    for (BuildTarget buildTarget : buildLog.getAllTargets()) {
        buildLog.assertNotTargetBuiltLocally(buildTarget.toString());
    }
}
Also used : ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) BuckBuildLog(com.facebook.buck.testutil.integration.BuckBuildLog) BuildTarget(com.facebook.buck.model.BuildTarget) Test(org.junit.Test)

Example 33 with BuckBuildLog

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

the class DBinaryIntegrationTest method cxx.

@Test
public void cxx() throws Exception {
    Assumptions.assumeDCompilerUsable();
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "cxx", tmp);
    workspace.setUp();
    workspace.runBuckBuild("-v", "10", "//:test").assertSuccess();
    BuckBuildLog buildLog = workspace.getBuildLog();
    buildLog.assertTargetBuiltLocally("//:test");
    workspace.resetBuildLogFile();
    ProcessExecutor.Result result = workspace.runCommand(workspace.resolve(BuildTargets.getGenPath(filesystem, BuildTargetFactory.newInstance("//:test").withFlavors(DBinaryDescription.BINARY_FLAVOR), "%s/test")).toString());
    assertEquals(0, result.getExitCode());
    assertEquals("1 + 1 = 2\n100 + 1 = 5\n", result.getStdout().get());
    assertEquals("", result.getStderr().get());
}
Also used : ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) BuckBuildLog(com.facebook.buck.testutil.integration.BuckBuildLog) ProcessExecutor(com.facebook.buck.util.ProcessExecutor) Test(org.junit.Test)

Example 34 with BuckBuildLog

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

the class PrecompiledHeaderIntegrationTest method touchingPchReferencedHeaderShouldNotCauseClangToRejectPch.

@Test
public void touchingPchReferencedHeaderShouldNotCauseClangToRejectPch() throws Exception {
    assumeTrue(Platform.detect() != Platform.WINDOWS);
    workspace.runBuckBuild("//:some_binary#default").assertSuccess();
    workspace.resetBuildLogFile();
    // Change this file (not in the pch) to trigger recompile.
    workspace.writeContentsToPath("int lib_func() { return 0; }", "lib.c");
    // Touch this file that contributes to the PCH without changing its contents.
    workspace.writeContentsToPath(workspace.getFileContents("referenced_by_prefix_header_from_dependency.h"), "referenced_by_prefix_header_from_dependency.h");
    workspace.runBuckBuild("//:some_binary#default").assertSuccess();
    BuckBuildLog buildLog = workspace.getBuildLog();
    buildLog.assertTargetHadMatchingRuleKey(findPchTarget().toString());
    buildLog.assertTargetBuiltLocally("//:some_library#default,static");
}
Also used : BuckBuildLog(com.facebook.buck.testutil.integration.BuckBuildLog) Test(org.junit.Test)

Example 35 with BuckBuildLog

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

the class PrecompiledHeaderIntegrationTest method changingPchReferencedHeaderFromSameTargetCausesLibraryToRecompile.

@Test
public void changingPchReferencedHeaderFromSameTargetCausesLibraryToRecompile() throws Exception {
    assumeTrue(Platform.detect() != Platform.WINDOWS);
    workspace.runBuckBuild("//:some_binary#default").assertSuccess();
    workspace.resetBuildLogFile();
    workspace.writeContentsToPath("#pragma once\n#define REFERENCED_BY_PREFIX_HEADER 3\n", "referenced_by_prefix_header.h");
    workspace.runBuckBuild("//:some_binary#default").assertSuccess();
    BuckBuildLog buildLog = workspace.getBuildLog();
    buildLog.assertTargetBuiltLocally(findPchTarget().toString());
    buildLog.assertTargetBuiltLocally("//:some_library#default,static");
}
Also used : BuckBuildLog(com.facebook.buck.testutil.integration.BuckBuildLog) Test(org.junit.Test)

Aggregations

BuckBuildLog (com.facebook.buck.testutil.integration.BuckBuildLog)88 Test (org.junit.Test)88 ProjectWorkspace (com.facebook.buck.testutil.integration.ProjectWorkspace)53 BuildTarget (com.facebook.buck.model.BuildTarget)32 OcamlRuleBuilder.createStaticLibraryBuildTarget (com.facebook.buck.ocaml.OcamlRuleBuilder.createStaticLibraryBuildTarget)10 ProcessExecutor (com.facebook.buck.util.ProcessExecutor)9 Path (java.nio.file.Path)8 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)7 ExecutableFinder (com.facebook.buck.io.ExecutableFinder)2 Sha1HashCode (com.facebook.buck.util.sha1.Sha1HashCode)2 ImmutableList (com.google.common.collect.ImmutableList)2 ImmutableSet (com.google.common.collect.ImmutableSet)2 ImmutableSortedSet (com.google.common.collect.ImmutableSortedSet)2 NSString (com.dd.plist.NSString)1 AssumeAndroidPlatform (com.facebook.buck.android.AssumeAndroidPlatform)1 ArtifactCache (com.facebook.buck.artifact_cache.ArtifactCache)1 FakeBuckConfig (com.facebook.buck.cli.FakeBuckConfig)1 CxxBuckConfig (com.facebook.buck.cxx.CxxBuckConfig)1 CxxFlavorSanitizer.sanitize (com.facebook.buck.cxx.CxxFlavorSanitizer.sanitize)1 CxxPlatform (com.facebook.buck.cxx.CxxPlatform)1