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);
}
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());
}
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());
}
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);
}
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());
}
Aggregations