Search in sources :

Example 81 with ProjectWorkspace

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

the class ProjectIntegrationTest method testGeneratesWorkspaceFromBinary.

@Test
public void testGeneratesWorkspaceFromBinary() throws IOException {
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "project_implicit_workspace_generation", temporaryFolder);
    workspace.setUp();
    ProjectWorkspace.ProcessResult result = workspace.runBuckCommand("project", "//bin:bin");
    result.assertSuccess();
    Files.exists(workspace.resolve("bin/bin.xcworkspace/contents.xcworkspacedata"));
    Files.exists(workspace.resolve("bin/bin.xcodeproj/project.pbxproj"));
}
Also used : ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) Test(org.junit.Test)

Example 82 with ProjectWorkspace

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

the class BuildKeepGoingIntegrationTest method testVariousSuccessTypesInReport.

@Test
public void testVariousSuccessTypesInReport() throws IOException {
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "keep_going", tmp).setUp();
    workspace.enableDirCache();
    ProcessResult result1 = buildTwoGoodRulesAndAssertSuccess(workspace);
    String expectedReport1 = "OK   //:rule_with_output BUILT_LOCALLY " + GENRULE_OUTPUT_PATH + "\n" + "OK   //:rule_without_output BUILT_LOCALLY\n";
    assertThat(result1.getStderr(), containsString(expectedReport1));
    ProcessResult result2 = buildTwoGoodRulesAndAssertSuccess(workspace);
    String expectedReport2 = "OK   //:rule_with_output MATCHING_RULE_KEY " + GENRULE_OUTPUT_PATH + "\n" + "OK   //:rule_without_output MATCHING_RULE_KEY\n";
    assertThat(result2.getStderr(), containsString(expectedReport2));
    workspace.runBuckCommand("clean").assertSuccess();
    ProcessResult result3 = buildTwoGoodRulesAndAssertSuccess(workspace);
    String expectedReport3 = "OK   //:rule_with_output FETCHED_FROM_CACHE " + GENRULE_OUTPUT_PATH + "\n" + "OK   //:rule_without_output BUILT_LOCALLY\n";
    assertThat(result3.getStderr(), containsString(expectedReport3));
}
Also used : ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) ProcessResult(com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 83 with ProjectWorkspace

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

the class BuildKeepGoingIntegrationTest method testKeepGoingWithMultipleSuccessfulTargets.

@Test
public void testKeepGoingWithMultipleSuccessfulTargets() throws IOException {
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "keep_going", tmp).setUp();
    ProcessResult result = buildTwoGoodRulesAndAssertSuccess(workspace);
    String expectedReport = "OK   //:rule_with_output BUILT_LOCALLY " + GENRULE_OUTPUT_PATH + "\n" + "OK   //:rule_without_output BUILT_LOCALLY\n";
    assertThat(result.getStderr(), containsString(expectedReport));
}
Also used : ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) ProcessResult(com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 84 with ProjectWorkspace

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

the class BuildWithNoTargetSpecifiedIntegrationTest method testBuckBuildWithoutTargetWithUnderTenAliasesConfigured.

/**
   * Ensure that if there are multiple aliases (but less than ten) they
   * are all displayed as targets in the order specified in .buckconfig.
   */
@Test
public void testBuckBuildWithoutTargetWithUnderTenAliasesConfigured() throws IOException {
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "project_with_five_aliases", temporaryFolder);
    workspace.setUp();
    ProcessResult result = workspace.runBuckCommand("build");
    result.assertFailure("buck build should exit with an error.");
    assertThat(Joiner.on(' ').join("`buck build` should suggest the five aliases found in .buckconfig", "(in the order in which they are listed in) as targets."), result.getStderr(), containsString(Joiner.on('\n').join("BUILD FAILED: Must specify at least one build target.", "Try building one of the following targets:", "myapp my_app mi_app mon_app mein_app") + '\n'));
}
Also used : ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) ProcessResult(com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult) Test(org.junit.Test)

Example 85 with ProjectWorkspace

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

the class CommandLineTargetNodeSpecParserIntegrationTest method trailingColonTargets.

@Test
public void trailingColonTargets() throws IOException {
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "command_line_parser", tmp);
    workspace.setUp();
    // First check for correct usage.
    ProjectWorkspace.ProcessResult result = workspace.runBuckCommand("targets", "//simple:").assertSuccess();
    assertEquals(ImmutableSet.of("//simple:simple"), ImmutableSet.copyOf(Splitter.on('\n').omitEmptyStrings().split(result.getStdout())));
    result = workspace.runBuckCommand("targets", "//simple:.");
    result.assertFailure("No rule found when resolving target //simple:. in build file //simple/BUCK");
}
Also used : ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) Test(org.junit.Test)

Aggregations

ProjectWorkspace (com.facebook.buck.testutil.integration.ProjectWorkspace)747 Test (org.junit.Test)726 Path (java.nio.file.Path)219 BuildTarget (com.facebook.buck.model.BuildTarget)177 ProcessResult (com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult)127 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)89 Matchers.containsString (org.hamcrest.Matchers.containsString)50 BuckBuildLog (com.facebook.buck.testutil.integration.BuckBuildLog)47 ProcessExecutor (com.facebook.buck.util.ProcessExecutor)35 ZipInspector (com.facebook.buck.testutil.integration.ZipInspector)21 HumanReadableException (com.facebook.buck.util.HumanReadableException)14 OcamlRuleBuilder.createStaticLibraryBuildTarget (com.facebook.buck.ocaml.OcamlRuleBuilder.createStaticLibraryBuildTarget)13 TestConsole (com.facebook.buck.testutil.TestConsole)12 FakeProjectFilesystem (com.facebook.buck.testutil.FakeProjectFilesystem)10 DefaultProcessExecutor (com.facebook.buck.util.DefaultProcessExecutor)10 Cell (com.facebook.buck.rules.Cell)9 TestContext (com.facebook.buck.testutil.integration.TestContext)9 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)9 MappedByteBuffer (java.nio.MappedByteBuffer)9 FileChannel (java.nio.channels.FileChannel)9