Search in sources :

Example 81 with BuckBuildLog

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

the class CxxPrecompiledHeaderRuleTest method deterministicHashesForSharedPCHs.

@Test
public void deterministicHashesForSharedPCHs() throws Exception {
    assumeTrue(platformOkForPCHTests());
    Sha1HashCode pchHashA = null;
    workspace.runBuckBuild("//determinism/a:main").assertSuccess();
    BuckBuildLog buildLogA = workspace.getBuildLog();
    for (BuildTarget target : buildLogA.getAllTargets()) {
        if (target.toString().startsWith("//determinism/lib:pch#default,pch-cxx-")) {
            pchHashA = buildLogA.getLogEntry(target).getRuleKey();
            System.err.println("A: " + pchHashA);
        }
    }
    assertNotNull(pchHashA);
    Sha1HashCode pchHashB = null;
    workspace.runBuckBuild("//determinism/b:main").assertSuccess();
    BuckBuildLog buildLogB = workspace.getBuildLog();
    for (BuildTarget target : buildLogB.getAllTargets()) {
        if (target.toString().startsWith("//determinism/lib:pch#default,pch-cxx-")) {
            pchHashB = buildLogB.getLogEntry(target).getRuleKey();
            System.err.println("B: " + pchHashB);
        }
    }
    assertNotNull(pchHashB);
    assertEquals(pchHashA, pchHashB);
    Sha1HashCode pchHashC = null;
    workspace.runBuckBuild("//determinism/c:main").assertSuccess();
    BuckBuildLog buildLogC = workspace.getBuildLog();
    for (BuildTarget target : buildLogC.getAllTargets()) {
        if (target.toString().startsWith("//determinism/lib:pch#default,pch-cxx-")) {
            pchHashC = buildLogC.getLogEntry(target).getRuleKey();
            System.err.println("C: " + pchHashC);
        }
    }
    assertNotNull(pchHashC);
    assertNotEquals(pchHashA, pchHashC);
}
Also used : Sha1HashCode(com.facebook.buck.util.sha1.Sha1HashCode) BuckBuildLog(com.facebook.buck.testutil.integration.BuckBuildLog) BuildTarget(com.facebook.buck.model.BuildTarget) Test(org.junit.Test)

Example 82 with BuckBuildLog

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

the class CxxSharedLibraryInterfaceIntegrationTest method sharedInterfaceLibraryPreventsRebuildAfterCodeChange.

@Test
public void sharedInterfaceLibraryPreventsRebuildAfterCodeChange() throws IOException {
    BuckBuildLog log;
    // First verify that *not* using shared library interfaces causes a rebuild even after making a
    // non-interface change.
    ImmutableList<String> args = ImmutableList.of("-c", "cxx.shared_library_interfaces=false", "-c", "cxx.objcopy=/usr/bin/objcopy", "-c", "cxx.platform=" + platform, sharedBinaryTarget.getFullyQualifiedName());
    String[] argv = args.toArray(new String[args.size()]);
    workspace.runBuckBuild(argv).assertSuccess();
    workspace.replaceFileContents("library.cpp", "bar1 = 0", "bar1 = 1");
    workspace.runBuckBuild(argv).assertSuccess();
    log = workspace.getBuildLog();
    if (sharedLibraryTarget.isPresent()) {
        log.assertTargetBuiltLocally(sharedLibraryTarget.get().toString());
    }
    log.assertTargetBuiltLocally(sharedBinaryBuiltTarget.toString());
    // Now verify that using shared library interfaces does not cause a rebuild after making a
    // non-interface change.
    ImmutableList<String> iArgs = ImmutableList.of("-c", "cxx.shared_library_interfaces=true", "-c", "cxx.objcopy=/usr/bin/objcopy", "-c", "cxx.platform=" + platform, sharedBinaryTarget.getFullyQualifiedName());
    String[] iArgv = iArgs.toArray(new String[iArgs.size()]);
    workspace.runBuckBuild(iArgv).assertSuccess();
    workspace.replaceFileContents("library.cpp", "bar1 = 1", "bar1 = 2");
    workspace.runBuckBuild(iArgv).assertSuccess();
    log = workspace.getBuildLog();
    if (sharedLibraryTarget.isPresent()) {
        log.assertTargetBuiltLocally(sharedLibraryTarget.get().toString());
    }
    log.assertTargetHadMatchingInputRuleKey(sharedBinaryBuiltTarget.toString());
}
Also used : BuckBuildLog(com.facebook.buck.testutil.integration.BuckBuildLog) Test(org.junit.Test)

Example 83 with BuckBuildLog

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

the class CxxSharedLibraryInterfaceIntegrationTest method sharedInterfaceLibraryPreventsRebuildAfterNonLocalVarNameChange.

@Test
public void sharedInterfaceLibraryPreventsRebuildAfterNonLocalVarNameChange() throws IOException {
    BuckBuildLog log;
    // First verify that *not* using shared library interfaces causes a rebuild even after making a
    // non-interface change.
    ImmutableList<String> args = ImmutableList.of("-c", "cxx.shared_library_interfaces=false", "-c", "cxx.objcopy=/usr/bin/objcopy", "-c", "cxx.platform=" + platform, sharedBinaryTarget.getFullyQualifiedName());
    String[] argv = args.toArray(new String[args.size()]);
    workspace.runBuckBuild(argv).assertSuccess();
    workspace.replaceFileContents("library.cpp", "bar1", "bar2");
    workspace.runBuckBuild(argv).assertSuccess();
    log = workspace.getBuildLog();
    if (sharedLibraryTarget.isPresent()) {
        log.assertTargetBuiltLocally(sharedLibraryTarget.get().toString());
    }
    log.assertTargetBuiltLocally(sharedBinaryBuiltTarget.toString());
    // Now verify that using shared library interfaces does not cause a rebuild after making a
    // non-interface change.
    ImmutableList<String> iArgs = ImmutableList.of("-c", "cxx.shared_library_interfaces=true", "-c", "cxx.objcopy=/usr/bin/objcopy", "-c", "cxx.platform=" + platform, sharedBinaryTarget.getFullyQualifiedName());
    String[] iArgv = iArgs.toArray(new String[iArgs.size()]);
    workspace.runBuckBuild(iArgv).assertSuccess();
    workspace.replaceFileContents("library.cpp", "bar2", "bar3");
    workspace.runBuckBuild(iArgv).assertSuccess();
    log = workspace.getBuildLog();
    if (sharedLibraryTarget.isPresent()) {
        log.assertTargetBuiltLocally(sharedLibraryTarget.get().toString());
    }
    log.assertTargetHadMatchingInputRuleKey(sharedBinaryBuiltTarget.toString());
}
Also used : BuckBuildLog(com.facebook.buck.testutil.integration.BuckBuildLog) Test(org.junit.Test)

Example 84 with BuckBuildLog

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

the class PrebuiltJarIntegrationTest method testAbiKeyIsHashOfFileContents.

@Test
public void testAbiKeyIsHashOfFileContents() throws IOException, InterruptedException {
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "prebuilt", temp);
    workspace.setUp();
    BuildTarget target = BuildTargetFactory.newInstance("//:jar");
    ProjectWorkspace.ProcessResult result = workspace.runBuckBuild(target.getFullyQualifiedName());
    result.assertSuccess();
    BuckBuildLog buildLog = workspace.getBuildLog();
    buildLog.assertTargetBuiltLocally(target.getFullyQualifiedName());
    result = workspace.runBuckBuild("//:jar");
    result.assertSuccess();
    buildLog = workspace.getBuildLog();
    buildLog.assertTargetHadMatchingRuleKey(target.getFullyQualifiedName());
    // We expect the binary jar to have a different hash to the stub jar.
    Path binaryJar = workspace.getPath("junit.jar");
    HashCode originalHash = MorePaths.asByteSource(binaryJar).hash(Hashing.sha1());
    Path expectedOut = BuildTargets.getGenPath(new ProjectFilesystem(workspace.getDestPath()), target, "%s-abi.jar");
    Path abiJar = workspace.getPath(expectedOut.toString());
    HashCode abiHash = MorePaths.asByteSource(abiJar).hash(Hashing.sha1());
    assertTrue(Files.exists(abiJar));
    assertNotEquals(originalHash, abiHash);
}
Also used : Path(java.nio.file.Path) ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) HashCode(com.google.common.hash.HashCode) BuildTarget(com.facebook.buck.model.BuildTarget) BuckBuildLog(com.facebook.buck.testutil.integration.BuckBuildLog) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) Test(org.junit.Test)

Example 85 with BuckBuildLog

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

the class GoBinaryIntegrationTest method simpleBinary.

@Test
public void simpleBinary() throws IOException, InterruptedException {
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "simple_binary", tmp);
    workspace.setUp();
    workspace.runBuckBuild("//:xyzzy").assertSuccess();
    BuckBuildLog buildLog = workspace.getBuildLog();
    buildLog.assertTargetBuiltLocally("//:xyzzy");
    workspace.resetBuildLogFile();
    ProcessExecutor.Result result = workspace.runCommand(workspace.resolve("buck-out/gen/xyzzy/xyzzy").toString());
    assertThat(result.getExitCode(), Matchers.equalTo(0));
    assertThat(result.getStdout().get(), Matchers.containsString("Hello, world!"));
    assertThat(result.getStderr().get(), Matchers.blankString());
}
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)

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