Search in sources :

Example 66 with ProcessResult

use of com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult in project buck by facebook.

the class DefaultJavaLibraryIntegrationTest method testAnnotationProcessorDepChangeThatDoesNotModifyAbiCausesRebuild.

@Test
public void testAnnotationProcessorDepChangeThatDoesNotModifyAbiCausesRebuild() throws IOException {
    workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "annotation_processors", tmp);
    workspace.setUp();
    // Run `buck build` to create the dep file
    BuildTarget mainTarget = BuildTargetFactory.newInstance("//:main");
    // Warm the used classes file
    ProcessResult buildResult = workspace.runBuckCommand("build", mainTarget.getFullyQualifiedName());
    buildResult.assertSuccess("Successful build should exit with 0.");
    workspace.getBuildLog().assertTargetBuiltLocally("//:main");
    workspace.getBuildLog().assertTargetBuiltLocally("//:annotation_processor");
    workspace.getBuildLog().assertTargetBuiltLocally("//:util");
    // Edit a dependency of the annotation processor in a way that doesn't change the ABI
    workspace.replaceFileContents("Util.java", "false", "true");
    // Run `buck build` again.
    ProcessResult buildResult2 = workspace.runBuckCommand("build", "//:main");
    buildResult2.assertSuccess("Successful build should exit with 0.");
    // If all goes well, we'll see //:annotation_processor's dep file on disk and not rebuild it,
    // but still rebuild //:main because the code of the annotation processor has changed
    workspace.getBuildLog().assertTargetBuiltLocally("//:util");
    workspace.getBuildLog().assertTargetBuiltLocally("//:main");
    workspace.getBuildLog().assertTargetHadMatchingInputRuleKey("//:annotation_processor_lib");
    workspace.getBuildLog().assertTargetBuiltLocally("//:annotation_processor");
}
Also used : BuildTarget(com.facebook.buck.model.BuildTarget) ProcessResult(com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult) Test(org.junit.Test)

Example 67 with ProcessResult

use of com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult in project buck by facebook.

the class ProjectIntegrationTest method testBuckProjectSliceWithTestsDryRunShowsNoTests.

@Test
public void testBuckProjectSliceWithTestsDryRunShowsNoTests() throws IOException {
    ProcessResult result = runBuckProjectWithoutVerification("project_slice_with_tests", "--deprecated-ij-generation", "--dry-run", "--without-tests", "//modules/dep1:dep1", "-v", "5");
    ImmutableSortedSet<String> expectedResult = ImmutableSortedSet.of("//libs:guava", "//libs:jsr305", "//libs:junit", "//modules/dep1:dep1", "//modules/dep1:project_config", "//modules/dep1:test");
    ImmutableSortedSet<String> actualResult = ImmutableSortedSet.copyOf(Splitter.on('\n').omitEmptyStrings().split(result.getStdout()));
    assertEquals("`buck project --dry-run` should print the list of targets that would be included.", expectedResult, actualResult);
}
Also used : ProcessResult(com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 68 with ProcessResult

use of com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult in project buck by facebook.

the class ProjectIntegrationTest method testBuckProjectWithAndroidBinary.

@Test
public void testBuckProjectWithAndroidBinary() throws IOException {
    ProcessResult result = runBuckProjectAndVerify("project_with_android_binary", "--deprecated-ij-generation", "-v", "5");
    assertEquals("`buck project` should report the files it modified.", Joiner.on('\n').join("MODIFIED FILES:", ".idea/compiler.xml", ".idea/misc.xml", ".idea/modules.xml", ".idea/runConfigurations/Debug_Buck_test.xml", "apps/sample/module_apps_sample.iml", "java/com/sample/lib/module_java_com_sample_lib.iml", "res/com/sample/asset_only/module_res_com_sample_asset_only.iml", "res/com/sample/base/module_res_com_sample_base.iml", "res/com/sample/title/module_res_com_sample_title.iml", "res/com/sample/top/module_res_com_sample_top.iml") + '\n', result.getStdout());
}
Also used : ProcessResult(com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult) Test(org.junit.Test)

Example 69 with ProcessResult

use of com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult in project buck by facebook.

the class ProjectIntegrationTest method testBuckProjectSlice.

/**
   * Verify that if we build a project by specifying a target, the resulting project only contains
   * the transitive deps of that target.  In this example, that means everything except
   * //modules/tip and //tests/tests.
   */
@Test
public void testBuckProjectSlice() throws IOException {
    ProcessResult result = runBuckProjectAndVerify("project_slice", "--deprecated-ij-generation", "--without-tests", "//modules/dep1:dep1", "//:root", "-v", "5");
    assertEquals("`buck project` should report the files it modified.", Joiner.on('\n').join("MODIFIED FILES:", ".idea/compiler.xml", ".idea/libraries/buck_out_gen_libs___guava___guava_jar.xml", ".idea/libraries/buck_out_gen_libs___jsr305___jsr305_jar.xml", ".idea/libraries/buck_out_gen_libs___junit___junit_jar.xml", ".idea/misc.xml", ".idea/modules.xml", ".idea/runConfigurations/Debug_Buck_test.xml", "module_.iml", "modules/dep1/module_modules_dep1.iml") + '\n', result.getStdout());
    assertThat("`buck project` should contain warning to synchronize IntelliJ.", result.getStderr(), containsString("  ::  Please resynchronize IntelliJ via File->Synchronize " + "or Cmd-Opt-Y (Mac) or Ctrl-Alt-Y (PC/Linux)"));
}
Also used : ProcessResult(com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult) Test(org.junit.Test)

Example 70 with ProcessResult

use of com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult in project buck by facebook.

the class ProjectIntegrationTest method testBuckProjectSliceWithAndroidBinary.

@Test
public void testBuckProjectSliceWithAndroidBinary() throws IOException {
    ProcessResult result = runBuckProjectAndVerify("project_with_android_binary", "--deprecated-ij-generation", "-v", "5", "//apps/sample:app");
    assertEquals("`buck project` should report the files it modified.", Joiner.on('\n').join("MODIFIED FILES:", ".idea/compiler.xml", ".idea/misc.xml", ".idea/modules.xml", ".idea/runConfigurations/Debug_Buck_test.xml", "apps/sample/module_apps_sample.iml", "java/com/sample/lib/module_java_com_sample_lib.iml", "res/com/sample/asset_only/module_res_com_sample_asset_only.iml", "res/com/sample/base/module_res_com_sample_base.iml", "res/com/sample/title/module_res_com_sample_title.iml", "res/com/sample/top/module_res_com_sample_top.iml") + '\n', result.getStdout());
}
Also used : ProcessResult(com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult) Test(org.junit.Test)

Aggregations

ProcessResult (com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult)175 Test (org.junit.Test)174 ProjectWorkspace (com.facebook.buck.testutil.integration.ProjectWorkspace)127 Path (java.nio.file.Path)21 Matchers.containsString (org.hamcrest.Matchers.containsString)20 BuildTarget (com.facebook.buck.model.BuildTarget)17 JsonNode (com.fasterxml.jackson.databind.JsonNode)8 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)8 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)6 TestContext (com.facebook.buck.testutil.integration.TestContext)4 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)3 ZipInspector (com.facebook.buck.testutil.integration.ZipInspector)3 ZipFile (java.util.zip.ZipFile)3 FakeProjectFilesystem (com.facebook.buck.testutil.FakeProjectFilesystem)2 DelegatingInputStream (com.facebook.buck.testutil.integration.DelegatingInputStream)2 CapturingPrintStream (com.facebook.buck.util.CapturingPrintStream)2 File (java.io.File)2 Charset (java.nio.charset.Charset)2 FileTime (java.nio.file.attribute.FileTime)2 ArtifactCache (com.facebook.buck.artifact_cache.ArtifactCache)1