use of com.facebook.buck.testutil.integration.BuckBuildLog in project buck by facebook.
the class ProjectIntegrationTest method testGeneratingProjectWithGenruleResourceBuildsGenrule.
@Test
public void testGeneratingProjectWithGenruleResourceBuildsGenrule() throws IOException {
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "target_using_genrule_resource", temporaryFolder);
workspace.setUp();
workspace.runBuckCommand("project", "//app:TestApp");
BuckBuildLog buildLog = workspace.getBuildLog();
buildLog.assertTargetBuiltLocally("//app:GenResource");
}
use of com.facebook.buck.testutil.integration.BuckBuildLog in project buck by facebook.
the class ProjectIntegrationTest method testGeneratingProjectWithTargetUsingGenruleSourceBuildsGenrule.
@Test
public void testGeneratingProjectWithTargetUsingGenruleSourceBuildsGenrule() throws IOException {
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "target_using_genrule_source", temporaryFolder);
workspace.setUp();
workspace.runBuckCommand("project", "//lib:lib");
BuckBuildLog buildLog = workspace.getBuildLog();
buildLog.assertTargetBuiltLocally("//lib:gen");
}
use of com.facebook.buck.testutil.integration.BuckBuildLog in project buck by facebook.
the class FetchCommandIntegrationTest method shouldFetchARemoteResourceIfThatIsTheExactTargetRequested.
@Test
public void shouldFetchARemoteResourceIfThatIsTheExactTargetRequested() throws IOException, URISyntaxException {
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "fetch_concrete", temp);
workspace.setUp();
// We don't know the URL of the file beforehand. Fix that.
addRemoteFileTarget(workspace);
ProjectWorkspace.ProcessResult result = workspace.runBuckCommand("fetch", "//:remote");
result.assertSuccess();
BuckBuildLog log = workspace.getBuildLog();
ImmutableSet<BuildTarget> allTargets = log.getAllTargets();
assertTrue(allTargets.contains(BuildTargetFactory.newInstance(workspace.getDestPath(), "//:remote")));
}
use of com.facebook.buck.testutil.integration.BuckBuildLog in project buck by facebook.
the class FetchCommandIntegrationTest method shouldNotFetchARemoteResourceIfNotIncludedInTheSetOfTargetsToBuild.
@Test
public void shouldNotFetchARemoteResourceIfNotIncludedInTheSetOfTargetsToBuild() throws IOException, URISyntaxException {
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "fetch_concrete", temp);
workspace.setUp();
// We don't know the URL of the file beforehand. Fix that.
addRemoteFileTarget(workspace);
ProjectWorkspace.ProcessResult result = workspace.runBuckCommand("fetch", "//:no-download");
result.assertSuccess();
BuckBuildLog log = workspace.getBuildLog();
ImmutableSet<BuildTarget> allTargets = log.getAllTargets();
assertFalse(allTargets.contains(BuildTargetFactory.newInstance(workspace.getDestPath(), "//:remote")));
}
use of com.facebook.buck.testutil.integration.BuckBuildLog in project buck by facebook.
the class CxxBinaryIntegrationTest method testSimpleCxxBinaryBuilds.
@Test
public void testSimpleCxxBinaryBuilds() throws Exception {
Assume.assumeFalse("Test should be modified for sandboxing", sandboxSources);
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "simple", tmp);
workspace.setUp();
workspace.setupCxxSandboxing(sandboxSources);
CxxBuckConfig cxxBuckConfig = new CxxBuckConfig(workspace.asCell().getBuckConfig());
CxxPlatform cxxPlatform = CxxPlatformUtils.build(cxxBuckConfig);
BuildTarget target = BuildTargetFactory.newInstance(workspace.getDestPath(), "//foo:simple");
CxxSourceRuleFactory cxxSourceRuleFactory = CxxSourceRuleFactoryHelper.of(workspace.getDestPath(), target, cxxPlatform, cxxBuckConfig);
BuildTarget binaryTarget = CxxDescriptionEnhancer.createCxxLinkTarget(target, Optional.<LinkerMapMode>empty());
String sourceName = "simple.cpp";
String sourceFull = "foo/" + sourceName;
BuildTarget compileTarget = cxxSourceRuleFactory.createCompileBuildTarget(sourceName);
BuildTarget headerSymlinkTreeTarget = CxxDescriptionEnhancer.createHeaderSymlinkTreeTarget(target, HeaderVisibility.PRIVATE, cxxPlatform.getFlavor());
BuildTarget aggregatedDepsTarget = cxxSourceRuleFactory.createAggregatedPreprocessDepsBuildTarget();
// Do a clean build, verify that it succeeds, and check that all expected targets built
// successfully.
workspace.runBuckCommand("build", target.toString()).assertSuccess();
BuckBuildLog buildLog = workspace.getBuildLog();
assertEquals(ImmutableSet.<BuildTarget>builder().add(aggregatedDepsTarget, headerSymlinkTreeTarget, compileTarget, binaryTarget, target).build(), buildLog.getAllTargets());
buildLog.assertTargetBuiltLocally(aggregatedDepsTarget.toString());
buildLog.assertTargetBuiltLocally(headerSymlinkTreeTarget.toString());
buildLog.assertTargetBuiltLocally(compileTarget.toString());
buildLog.assertTargetBuiltLocally(binaryTarget.toString());
buildLog.assertTargetBuiltLocally(target.toString());
// Clear for new build.
workspace.resetBuildLogFile();
// Check that running a build again results in no builds since everything is up to
// date.
workspace.runBuckCommand("build", target.toString()).assertSuccess();
buildLog = workspace.getBuildLog();
assertEquals(ImmutableSet.of(target, binaryTarget), buildLog.getAllTargets());
buildLog.assertTargetHadMatchingRuleKey(binaryTarget.toString());
buildLog.assertTargetHadMatchingRuleKey(target.toString());
// Clear for new build.
workspace.resetBuildLogFile();
// Update the source file.
workspace.replaceFileContents(sourceFull, "{}", "{ return 0; }");
// Check that running a build again makes the source get recompiled and the binary
// re-linked, but does not cause the header rules to re-run.
workspace.runBuckCommand("build", target.toString()).assertSuccess();
buildLog = workspace.getBuildLog();
assertEquals(ImmutableSet.<BuildTarget>builder().add(aggregatedDepsTarget, compileTarget, binaryTarget, target).build(), buildLog.getAllTargets());
buildLog.assertTargetHadMatchingRuleKey(aggregatedDepsTarget.toString());
buildLog.assertTargetBuiltLocally(compileTarget.toString());
assertThat(buildLog.getLogEntry(binaryTarget).getSuccessType().get(), Matchers.not(Matchers.equalTo(BuildRuleSuccessType.MATCHING_RULE_KEY)));
// Clear for new build.
workspace.resetBuildLogFile();
// Update the source file.
workspace.replaceFileContents(sourceFull, "{ return 0; }", "won't compile");
// Check that running a build again makes the source get recompiled and the binary
// re-linked, but does not cause the header rules to re-run.
workspace.runBuckCommand("build", target.toString()).assertFailure();
buildLog = workspace.getBuildLog();
assertEquals(ImmutableSet.<BuildTarget>builder().add(aggregatedDepsTarget, compileTarget, binaryTarget, target).build(), buildLog.getAllTargets());
buildLog.assertTargetHadMatchingRuleKey(aggregatedDepsTarget.toString());
assertThat(buildLog.getLogEntry(binaryTarget).getStatus(), Matchers.equalTo(BuildRuleStatus.CANCELED));
assertThat(buildLog.getLogEntry(target).getStatus(), Matchers.equalTo(BuildRuleStatus.CANCELED));
}
Aggregations