Search in sources :

Example 76 with BuckBuildLog

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

the class AndroidResourceFilterIntegrationTest method testModifyingImageRebuildsResourcesFilter.

@Test
public void testModifyingImageRebuildsResourcesFilter() throws IOException {
    String target = "//apps/sample:app_mdpi";
    ProjectWorkspace.ProcessResult result = workspace.runBuckBuild(target);
    result.assertSuccess();
    Path apkFile = workspace.getPath(BuildTargets.getGenPath(filesystem, BuildTargetFactory.newInstance(target), "%s.apk"));
    String iconPath = isBuildToolsNew ? "res/drawable-mdpi-v4/app_icon.png" : "res/drawable-mdpi/app_icon.png";
    long firstImageCrc = new ZipInspector(apkFile).getCrc(iconPath);
    workspace.copyFile("res/com/sample/base/res/drawable-hdpi/app_icon.png", "res/com/sample/base/res/drawable-mdpi/app_icon.png");
    workspace.resetBuildLogFile();
    result = workspace.runBuckBuild(target);
    result.assertSuccess();
    BuckBuildLog buildLog = workspace.getBuildLog();
    buildLog.assertTargetBuiltLocally(target);
    apkFile = workspace.getPath(BuildTargets.getGenPath(filesystem, BuildTargetFactory.newInstance(target), "%s.apk"));
    long secondImageCrc = new ZipInspector(apkFile).getCrc(iconPath);
    assertNotEquals(firstImageCrc, secondImageCrc);
}
Also used : Path(java.nio.file.Path) ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) BuckBuildLog(com.facebook.buck.testutil.integration.BuckBuildLog) ZipInspector(com.facebook.buck.testutil.integration.ZipInspector) Test(org.junit.Test)

Example 77 with BuckBuildLog

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

the class AndroidResourceLibraryDepIntegrationTest method testModifyingLibraryDependencyDoesNotCauseRebuilt.

@Test
public void testModifyingLibraryDependencyDoesNotCauseRebuilt() throws IOException {
    AssumeAndroidPlatform.assumeSdkIsAvailable();
    String appTarget = "//apps/sample:app_res_lib_dep";
    String resTarget = "//res/com/sample/base:base_with_lib_dep";
    String libTarget = "//java/com/sample/small:small";
    // Do the initial resource build.
    ProjectWorkspace.ProcessResult first = workspace.runBuckCommand("build", appTarget);
    first.assertSuccess();
    // Verify that the resource and library dependency were successfully built.
    BuckBuildLog firstBuildLog = workspace.getBuildLog();
    firstBuildLog.assertTargetBuiltLocally(appTarget);
    firstBuildLog.assertTargetBuiltLocally(resTarget);
    firstBuildLog.assertTargetBuiltLocally(libTarget);
    // Update the java library dependency, which will force it to be rebuilt.
    workspace.replaceFileContents("java/com/sample/small/Sample.java", "savedInstanceState", "savedInstanceState2");
    workspace.resetBuildLogFile();
    // Re-run the build, which should just rebuild the java library.
    ProjectWorkspace.ProcessResult second = workspace.runBuckCommand("build", appTarget);
    second.assertSuccess();
    // Now verify that just the library and top-level binary got rebuilt.
    BuckBuildLog secondBuildLog = workspace.getBuildLog();
    secondBuildLog.assertTargetBuiltLocally(appTarget);
    secondBuildLog.assertTargetHadMatchingRuleKey(resTarget);
    secondBuildLog.assertTargetBuiltLocally(libTarget);
}
Also used : ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) BuckBuildLog(com.facebook.buck.testutil.integration.BuckBuildLog) Test(org.junit.Test)

Example 78 with BuckBuildLog

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

the class FetchCommandIntegrationTest method shouldBuildNothingIfThereAreNoFetchableRules.

@Test
public void shouldBuildNothingIfThereAreNoFetchableRules() throws IOException {
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "fetch_nothing", temp);
    workspace.setUp();
    ProjectWorkspace.ProcessResult result = workspace.runBuckCommand("fetch", "//:example");
    result.assertSuccess();
    BuckBuildLog log = workspace.getBuildLog();
    ImmutableSet<BuildTarget> allTargets = log.getAllTargets();
    assertFalse(allTargets.contains(BuildTargetFactory.newInstance(workspace.getDestPath(), "//:example")));
}
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 79 with BuckBuildLog

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

the class FetchCommandIntegrationTest method shouldOnlyExecuteDownloadableTargets.

@Test
public void shouldOnlyExecuteDownloadableTargets() 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", "//:needs-download");
    result.assertSuccess();
    BuckBuildLog log = workspace.getBuildLog();
    ImmutableSet<BuildTarget> allTargets = log.getAllTargets();
    assertTrue(allTargets.contains(BuildTargetFactory.newInstance(workspace.getDestPath(), "//:remote")));
    assertFalse(allTargets.contains(BuildTargetFactory.newInstance(workspace.getDestPath(), "//:needs-download")));
}
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 80 with BuckBuildLog

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

the class CxxPrecompiledHeaderRuleTest method changingHeaderIncludedByPCHPrefixHeaderCausesRecompile.

@Test
public void changingHeaderIncludedByPCHPrefixHeaderCausesRecompile() throws Exception {
    assumeTrue(platformOkForPCHTests());
    BuckBuildLog buildLog;
    workspace.writeContentsToPath("#define TESTVALUE 50\n", "recompile_after_include_changed/included_by_pch.h");
    workspace.runBuckBuild("//recompile_after_include_changed:main#default").assertSuccess();
    buildLog = workspace.getBuildLog();
    assertThat(buildLog, reportedTargetSuccessType(findPchTarget(), BuildRuleSuccessType.BUILT_LOCALLY));
    assertThat(buildLog, reportedTargetSuccessType(workspace.newBuildTarget("//recompile_after_include_changed:main#binary,default"), BuildRuleSuccessType.BUILT_LOCALLY));
    assertEquals(workspace.runCommand(workspace.resolve(BuildTargets.getGenPath(filesystem, workspace.newBuildTarget("//recompile_after_include_changed:main#default"), "%s")).toString()).getExitCode(), 50);
    workspace.resetBuildLogFile();
    workspace.writeContentsToPath("#define TESTVALUE 51\n", "recompile_after_include_changed/included_by_pch.h");
    workspace.runBuckBuild("//recompile_after_include_changed:main#default").assertSuccess();
    buildLog = workspace.getBuildLog();
    assertThat(buildLog, reportedTargetSuccessType(findPchTarget(), BuildRuleSuccessType.BUILT_LOCALLY));
    assertThat(buildLog, reportedTargetSuccessType(workspace.newBuildTarget("//recompile_after_include_changed:main#binary,default"), BuildRuleSuccessType.BUILT_LOCALLY));
    assertEquals(workspace.runCommand(workspace.resolve(BuildTargets.getGenPath(filesystem, workspace.newBuildTarget("//recompile_after_include_changed:main#default"), "%s")).toString()).getExitCode(), 51);
}
Also used : 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