use of com.facebook.buck.testutil.integration.BuckBuildLog in project buck by facebook.
the class CxxBinaryIntegrationTest method testCxxBinaryDepfileBuildWithAddedHeader.
@Test
public void testCxxBinaryDepfileBuildWithAddedHeader() throws IOException {
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "cxx_binary_depfile_build_with_added_header", tmp);
workspace.setUp();
workspace.setupCxxSandboxing(sandboxSources);
ProjectWorkspace.ProcessResult result = workspace.runBuckCommand("build", "//:bin");
result.assertSuccess();
BuckBuildLog buildLog = workspace.getBuildLog();
buildLog.assertTargetBuiltLocally("//:bin#binary");
buildLog.assertTargetBuiltLocally("//:bin#compile-" + sanitize("bin.c.o") + ",default");
buildLog.assertTargetBuiltLocally("//:lib1#default,static");
workspace.resetBuildLogFile();
workspace.replaceFileContents("BUCK", "['lib1.h']", "['lib1.h', 'lib2.h']");
result = workspace.runBuckCommand("build", "//:bin");
result.assertSuccess();
buildLog = workspace.getBuildLog();
buildLog.assertTargetHadMatchingInputRuleKey("//:bin#binary");
buildLog.assertTargetHadMatchingDepfileRuleKey("//:bin#compile-" + sanitize("bin.c.o") + ",default");
buildLog.assertTargetHadMatchingInputRuleKey("//:lib1#default,static");
}
use of com.facebook.buck.testutil.integration.BuckBuildLog in project buck by facebook.
the class CxxBinaryIntegrationTest method testInferCxxBinaryDepsCaching.
@Test
public void testInferCxxBinaryDepsCaching() throws IOException, InterruptedException {
assumeTrue(Platform.detect() != Platform.WINDOWS);
ProjectWorkspace workspace = InferHelper.setupCxxInferWorkspace(this, tmp, Optional.empty());
workspace.enableDirCache();
workspace.setupCxxSandboxing(sandboxSources);
CxxBuckConfig cxxBuckConfig = new CxxBuckConfig(workspace.asCell().getBuckConfig());
CxxPlatform cxxPlatform = CxxPlatformUtils.build(cxxBuckConfig);
BuildTarget inputBuildTarget = BuildTargetFactory.newInstance("//foo:binary_with_deps");
String inputBuildTargetName = inputBuildTarget.withFlavors(CxxInferEnhancer.InferFlavors.INFER.get()).getFullyQualifiedName();
/*
* Build the given target and check that it succeeds.
*/
workspace.runBuckCommand("build", inputBuildTargetName).assertSuccess();
/*
* Check that building after clean will use the cache
*/
workspace.runBuckCommand("clean").assertSuccess();
workspace.runBuckCommand("build", inputBuildTargetName).assertSuccess();
BuckBuildLog buildLog = workspace.getBuildLog();
for (BuildTarget buildTarget : buildLog.getAllTargets()) {
buildLog.assertTargetWasFetchedFromCache(buildTarget.toString());
}
/*
* Check that if the file in the binary target changes, then all the deps will be fetched
* from the cache
*/
String sourceName = "src_with_deps.c";
workspace.replaceFileContents("foo/" + sourceName, "10", "30");
workspace.runBuckCommand("clean").assertSuccess();
workspace.runBuckCommand("build", inputBuildTargetName).assertSuccess();
buildLog = workspace.getBuildLog();
CxxSourceRuleFactory cxxSourceRuleFactory = CxxSourceRuleFactoryHelper.of(workspace.getDestPath(), inputBuildTarget, cxxPlatform, cxxBuckConfig);
BuildTarget captureBuildTarget = cxxSourceRuleFactory.createInferCaptureBuildTarget(sourceName);
// this is flavored, and denotes the analysis step (generates a local report)
BuildTarget inferAnalysisTarget = inputBuildTarget.withFlavors(CxxInferEnhancer.InferFlavors.INFER_ANALYZE.get());
// this is the flavored version of the top level target (the one give in input to buck)
BuildTarget inferReportTarget = inputBuildTarget.withFlavors(CxxInferEnhancer.InferFlavors.INFER.get());
BuildTarget aggregatedDepsTarget = cxxSourceRuleFactory.createAggregatedPreprocessDepsBuildTarget();
String bt;
for (BuildTarget buildTarget : buildLog.getAllTargets()) {
bt = buildTarget.toString();
if (buildTarget.getFlavors().contains(CxxDescriptionEnhancer.EXPORTED_HEADER_SYMLINK_TREE_FLAVOR) || buildTarget.getFlavors().contains(CxxDescriptionEnhancer.HEADER_SYMLINK_TREE_FLAVOR) || buildTarget.getFlavors().contains(CxxDescriptionEnhancer.SANDBOX_TREE_FLAVOR) || bt.equals(inferAnalysisTarget.toString()) || bt.equals(captureBuildTarget.toString()) || bt.equals(inferReportTarget.toString()) || bt.equals(aggregatedDepsTarget.toString())) {
buildLog.assertTargetBuiltLocally(bt);
} else {
buildLog.assertTargetWasFetchedFromCache(buildTarget.toString());
}
}
}
use of com.facebook.buck.testutil.integration.BuckBuildLog in project buck by facebook.
the class CxxSharedLibraryInterfaceIntegrationTest method sharedInterfaceLibraryDoesNotAffectStaticLinking.
@Test
public void sharedInterfaceLibraryDoesNotAffectStaticLinking() throws IOException {
BuckBuildLog log;
// Verify that using shared library interfaces does not affect static linking.
ImmutableList<String> iArgs = ImmutableList.of("-c", "cxx.shared_library_interfaces=true", "-c", "cxx.objcopy=/usr/bin/objcopy", "-c", "cxx.platform=" + platform, staticBinaryTarget.getFullyQualifiedName());
String[] iArgv = iArgs.toArray(new String[iArgs.size()]);
workspace.runBuckBuild(iArgv).assertSuccess();
workspace.replaceFileContents("library.cpp", "bar1", "bar2");
workspace.runBuckBuild(iArgv).assertSuccess();
log = workspace.getBuildLog();
log.assertTargetBuiltLocally(staticBinaryBuiltTarget.toString());
}
use of com.facebook.buck.testutil.integration.BuckBuildLog in project buck by facebook.
the class CxxSharedLibraryInterfaceIntegrationTest method sharedInterfaceLibraryPreventsRebuildAfterAddedCode.
@Test
public void sharedInterfaceLibraryPreventsRebuildAfterAddedCode() 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", "return bar1", "return bar1 += 15");
workspace.runBuckBuild(argv).assertSuccess();
log = workspace.getBuildLog();
if (sharedLibraryTarget.isPresent()) {
log.assertTargetBuiltLocally(sharedLibraryTarget.get().toString());
}
log.assertTargetBuiltLocally(sharedBinaryBuiltTarget.toString());
// Revert changes.
workspace.replaceFileContents("library.cpp", "return bar1 += 15", "return bar1");
// 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", "return bar1", "return bar1 += 15");
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 CxxPrecompiledHeaderRuleTest method changingPrecompilableHeaderCausesRecompile.
@Test
public void changingPrecompilableHeaderCausesRecompile() throws Exception {
assumeTrue(platformOkForPCHTests());
BuckBuildLog buildLog;
workspace.writeContentsToPath("#define TESTVALUE 42\n", "recompile_after_header_changed/header.h");
workspace.runBuckBuild("//recompile_after_header_changed:main#default").assertSuccess();
buildLog = workspace.getBuildLog();
assertThat(buildLog, reportedTargetSuccessType(findPchTarget(), BuildRuleSuccessType.BUILT_LOCALLY));
assertThat(buildLog, reportedTargetSuccessType(workspace.newBuildTarget("//recompile_after_header_changed:main#binary,default"), BuildRuleSuccessType.BUILT_LOCALLY));
assertEquals(42, runBuiltBinary("//recompile_after_header_changed:main#default"));
workspace.resetBuildLogFile();
workspace.writeContentsToPath("#define TESTVALUE 43\n", "recompile_after_header_changed/header.h");
workspace.runBuckBuild("//recompile_after_header_changed:main#default").assertSuccess();
buildLog = workspace.getBuildLog();
assertThat(buildLog, reportedTargetSuccessType(findPchTarget(), BuildRuleSuccessType.BUILT_LOCALLY));
assertThat(buildLog, reportedTargetSuccessType(workspace.newBuildTarget("//recompile_after_header_changed:main#binary,default"), BuildRuleSuccessType.BUILT_LOCALLY));
assertEquals(43, runBuiltBinary("//recompile_after_header_changed:main#default"));
}
Aggregations