Search in sources :

Example 91 with ProjectWorkspace

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

the class BuildCommandIntegrationTest method buckBuildAndCopyOutputFileWithBuildTargetThatSupportsIt.

@Test
public void buckBuildAndCopyOutputFileWithBuildTargetThatSupportsIt() throws IOException {
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "build_into", tmp);
    workspace.setUp();
    Path externalOutputs = tmp.newFolder("into-output");
    Path output = externalOutputs.resolve("the_example.jar");
    assertFalse(output.toFile().exists());
    workspace.runBuckBuild("//:example", "--out", output.toString()).assertSuccess();
    assertTrue(output.toFile().exists());
    ZipInspector zipInspector = new ZipInspector(output);
    zipInspector.assertFileExists("com/example/Example.class");
}
Also used : Path(java.nio.file.Path) ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) ZipInspector(com.facebook.buck.testutil.integration.ZipInspector) Test(org.junit.Test)

Example 92 with ProjectWorkspace

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

the class AuditAliasCommandIntegrationTest method testBuckAliasList.

@Test
public void testBuckAliasList() throws IOException {
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "alias", tmp);
    workspace.setUp();
    ProcessResult result = workspace.runBuckCommand("audit", "alias", "--list");
    result.assertSuccess();
    // Remove trailing newline from stdout before passing to Splitter.
    String stdout = result.getStdout();
    assertTrue(stdout.endsWith("\n"));
    stdout = stdout.substring(0, stdout.length() - 1);
    List<String> aliases = Splitter.on('\n').splitToList(stdout);
    assertEquals("Aliases that appear in both .buckconfig and .buckconfig.local should appear only once.", 3, aliases.size());
    assertEquals(ImmutableSet.of("foo", "bar", "bar_ex"), ImmutableSet.copyOf(aliases));
}
Also used : ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) ProcessResult(com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult) Test(org.junit.Test)

Example 93 with ProjectWorkspace

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

the class AuditConfigCommandIntegrationTest method testConfigJsonUIWithWholeSection.

@Test
public void testConfigJsonUIWithWholeSection() throws IOException {
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "audit_config", tmp);
    workspace.setUp();
    ProjectWorkspace.ProcessResult result = workspace.runBuckCommand("audit", "config", "--json", "missing_section.badvalue", "ignored_section");
    result.assertSuccess();
    assertEquals(workspace.getFileContents("stdout-config.json").trim(), result.getStdout());
}
Also used : ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) Test(org.junit.Test)

Example 94 with ProjectWorkspace

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

the class AuditConfigCommandIntegrationTest method testErrorOnBothTabAndJson.

@Test
public void testErrorOnBothTabAndJson() throws IOException {
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "audit_config", tmp);
    workspace.setUp();
    ProjectWorkspace.ProcessResult result = workspace.runBuckCommand("audit", "config", "--tab", "--json", "missing_section.badvalue", "ignored_section", "ignored_section.dotted.value", "second_section.some_property", "ignored_section.short_value", "ignored_section.long_value");
    result.assertFailure();
    assertThat(result.getStderr(), containsString("--json and --tab cannot both be specified"));
}
Also used : ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) Test(org.junit.Test)

Example 95 with ProjectWorkspace

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

the class AuditConfigCommandIntegrationTest method testTabbedUI.

@Test
public void testTabbedUI() throws IOException {
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "audit_config", tmp);
    workspace.setUp();
    ProjectWorkspace.ProcessResult result = workspace.runBuckCommand("audit", "config", "--tab", "missing_section.badvalue", "ignored_section.dotted.value", "ignored_section.short_value", "ignored_section.long_value");
    result.assertSuccess();
    assertEquals(workspace.getFileContents("stdout-config"), result.getStdout());
}
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