Search in sources :

Example 16 with BuckBuildLog

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");
}
Also used : ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) BuckBuildLog(com.facebook.buck.testutil.integration.BuckBuildLog) Test(org.junit.Test)

Example 17 with BuckBuildLog

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");
}
Also used : ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) BuckBuildLog(com.facebook.buck.testutil.integration.BuckBuildLog) Test(org.junit.Test)

Example 18 with BuckBuildLog

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")));
}
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 19 with BuckBuildLog

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")));
}
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 20 with BuckBuildLog

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));
}
Also used : ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) BuildTarget(com.facebook.buck.model.BuildTarget) 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