Search in sources :

Example 16 with ProcessResult

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

the class AuditDependenciesCommandIntegrationTest method testRunningWithNoParameterCausesBuildError.

@Test
public void testRunningWithNoParameterCausesBuildError() throws IOException {
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "audit_dependencies", tmp);
    workspace.setUp();
    // Print all of the inputs to the rule.
    ProcessResult result = workspace.runBuckCommand("audit", "dependencies");
    result.assertFailure();
    assertThat(result.getStderr(), containsString("Must specify at least one build target.\n"));
}
Also used : ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) ProcessResult(com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult) Test(org.junit.Test)

Example 17 with ProcessResult

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

the class AuditDependenciesCommandIntegrationTest method testTransitiveDependencies.

@Test
public void testTransitiveDependencies() throws IOException {
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "audit_dependencies", tmp);
    workspace.setUp();
    // Print all of the inputs to the rule.
    ProcessResult result = workspace.runBuckCommand("audit", "dependencies", "--transitive", "//example:one");
    result.assertSuccess();
    assertEquals(workspace.getFileContents("stdout-one-transitive"), result.getStdout());
}
Also used : ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) ProcessResult(com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult) Test(org.junit.Test)

Example 18 with ProcessResult

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

the class AuditInputCommandIntegrationTest method testBuckAuditInputJsonAppleResourceDirs.

@Test
public void testBuckAuditInputJsonAppleResourceDirs() throws IOException {
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "audit_input", tmp);
    workspace.setUp();
    // Print all of the inputs to the rule in JSON format.
    ProcessResult result = workspace.runBuckCommand("audit", "input", "//example:foo", "--json");
    result.assertSuccess();
    assertEquals(workspace.getFileContents(expectedStdoutJson), result.getStdout());
}
Also used : ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) ProcessResult(com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult) Test(org.junit.Test)

Example 19 with ProcessResult

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

the class AuditInputCommandIntegrationTest method testBuckAuditInputAppleResourceDirs.

@Test
public void testBuckAuditInputAppleResourceDirs() throws IOException {
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "audit_input", tmp);
    workspace.setUp();
    // Print all of the inputs to the rule.
    ProcessResult result = workspace.runBuckCommand("audit", "input", "//example:foo");
    result.assertSuccess();
    assertEquals(workspace.getFileContents(expectedStdout), result.getStdout());
}
Also used : ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) ProcessResult(com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult) Test(org.junit.Test)

Example 20 with ProcessResult

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

the class DaemonIntegrationTest method whenCrossCellSourceInvalidatedThenRebuildFails.

@Test
public void whenCrossCellSourceInvalidatedThenRebuildFails() throws IOException, InterruptedException {
    final ProjectWorkspace primary = TestDataHelper.createProjectWorkspaceForScenario(this, "crosscell_file_watching/primary", tmp.newFolder());
    primary.setUp();
    final ProjectWorkspace secondary = TestDataHelper.createProjectWorkspaceForScenario(this, "crosscell_file_watching/secondary", tmp.newFolder());
    secondary.setUp();
    TestDataHelper.overrideBuckconfig(primary, ImmutableMap.of("repositories", ImmutableMap.of("secondary", secondary.getPath(".").normalize().toString())));
    primary.runBuckdCommand("build", "//:cxxbinary").assertSuccess();
    ProcessResult result = primary.runBuckdCommand("run", "//:cxxbinary");
    result.assertSuccess();
    String fileName = "sum.cpp";
    Files.write(secondary.getPath(fileName), "#error Failure".getBytes(Charsets.UTF_8));
    result = primary.runBuckdCommand("build", "//:cxxbinary");
    assertThat("Failure should be due to compilation error.", result.getStderr(), containsString("#error Failure"));
    result.assertFailure();
    // Make the file valid again, but change the output
    Files.write(secondary.getPath(fileName), "#include \"sum.hpp\"\nint sum(int a, int b) {return a;}".getBytes(Charsets.UTF_8));
    primary.runBuckdCommand("build", "//:cxxbinary").assertSuccess();
    result = primary.runBuckdCommand("run", "//:cxxbinary");
    result.assertFailure();
}
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)

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