Search in sources :

Example 1 with ProcessResult

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

the class AndroidPrebuiltAarIntegrationTest method testExtraDepsDontResultInWarning.

@Test
public void testExtraDepsDontResultInWarning() throws IOException {
    ProcessResult result = workspace.runBuckBuild("//:app-extra-res-entry").assertSuccess();
    String buildOutput = result.getStderr();
    assertThat("No warnings are shown", buildOutput, not(containsString("Cannot find resource")));
}
Also used : ProcessResult(com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 2 with ProcessResult

use of com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult 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 3 with ProcessResult

use of com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult 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 4 with ProcessResult

use of com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult 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 5 with ProcessResult

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

the class DaemonIntegrationTest method whenClientDisconnectionDetectedThenBuildIsInterrupted.

/**
   * This verifies that a client timeout will be detected by a Nailgun
   * NGInputStream reading from an empty heartbeat stream and that the generated
   * InterruptedException will cause command execution to fail after timeout.
   */
@Test
public void whenClientDisconnectionDetectedThenBuildIsInterrupted() throws InterruptedException, IOException {
    // Sub process interruption not supported on Windows.
    assumeTrue(Platform.detect() != Platform.WINDOWS);
    // Stream timeout > test timeout.
    final long timeoutMillis = 2000;
    // Disconnect before test timeout.
    final long disconnectMillis = 100;
    final ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "exclusive_execution", tmp);
    workspace.setUp();
    // Build an NGContext connected to an NGInputStream reading from stream that will timeout.
    try (TestContext context = new TestContext(ImmutableMap.copyOf(System.getenv()), TestContext.createDisconnectionStream(disconnectMillis), timeoutMillis)) {
        ProcessResult result = workspace.runBuckdCommand(context, "build", "//:sleep");
        result.assertFailure();
        assertThat(result.getStderr(), containsString("InterruptedException"));
    }
}
Also used : ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) TestContext(com.facebook.buck.testutil.integration.TestContext) 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