Search in sources :

Example 81 with ProcessResult

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

the class PythonTestIntegrationTest method testPythonTestEnv.

@Test
public void testPythonTestEnv() throws IOException {
    // Test if setting environment during test execution works
    ProcessResult result = workspace.runBuckCommand("test", "//:test-env");
    result.assertSuccess();
}
Also used : ProcessResult(com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult) Test(org.junit.Test)

Example 82 with ProcessResult

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

the class PythonTestIntegrationTest method testRunPythonTest.

@Test
public void testRunPythonTest() throws IOException {
    ProcessResult result = workspace.runBuckCommand("run", "//:test-success");
    result.assertSuccess();
    assertThat(result.getStderr(), containsString("test_that_passes (test_success.Test) ... ok"));
}
Also used : ProcessResult(com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult) Test(org.junit.Test)

Example 83 with ProcessResult

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

the class ShBinaryRuleIntegrationTest method testShBinaryCannotOverwriteResource.

@Test
public void testShBinaryCannotOverwriteResource() throws IOException {
    // sh_binary is not available on Windows. Ignore this test on Windows.
    assumeTrue(Platform.detect() != Platform.WINDOWS);
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "sh_binary_with_overwrite_violation", temporaryFolder);
    workspace.setUp();
    ProcessResult buildResult = workspace.runBuckCommand("build", "//:overwrite");
    buildResult.assertFailure();
    assertThat(buildResult.getStderr(), containsString("/overwrite.sh: Permission denied"));
}
Also used : ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) ProcessResult(com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult) Test(org.junit.Test)

Example 84 with ProcessResult

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

the class GenruleIntegrationTest method testIfCommandExitsZeroThenGenruleFails.

@Test
public void testIfCommandExitsZeroThenGenruleFails() throws IOException {
    assumeTrue("This genrule uses the 'bash' argument, which is not supported on Windows. ", Platform.detect() != Platform.WINDOWS);
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "genrule_failing_command", temporaryFolder);
    workspace.setUp();
    ProcessResult buildResult = workspace.runBuckCommand("build", "//:fail", "--verbose", "10");
    buildResult.assertFailure();
    /* We want to make sure we failed for the right reason. The expected should contain something
     * like the following:
     *
     * BUILD FAILED: //:fail failed with exit code 1:
     * (cd /tmp/junit12345/buck-out/gen/fail__srcs && /bin/bash -e -c 'false; echo >&2 hi')
     *
     * We should match all that, except for the specific temp dir.
     */
    // "(?s)" enables multiline matching for ".*". Parens have to be escaped.
    String outputPattern = "(?s).*BUILD FAILED: //:fail failed with exit code 1:(?s).*" + "\\(cd .*/buck-out/gen/fail__srcs && " + "/bin/bash -e .*/buck-out/tmp/genrule-[0-9]*\\.sh\\)(?s).*";
    assertTrue("Unexpected output:\n" + quoteOutput(buildResult.getStderr()), buildResult.getStderr().matches(outputPattern));
}
Also used : ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) ProcessResult(com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult) Test(org.junit.Test)

Example 85 with ProcessResult

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

the class DefaultJavaLibraryIntegrationTest method testAnnotationProcessorFileChangeThatDoesNotModifyCodeDoesNotCauseRebuild.

@Test
public void testAnnotationProcessorFileChangeThatDoesNotModifyCodeDoesNotCauseRebuild() 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 source file in the annotation processor in a way that doesn't change the ABI
    workspace.replaceFileContents("AnnotationProcessor.java", "false", "false /* false */");
    // Run `buck build` again.
    ProcessResult buildResult2 = workspace.runBuckCommand("build", "//:main");
    buildResult2.assertSuccess("Successful build should exit with 0.");
    // If all goes well, we'll rebuild //:annotation_processor because of the source change,
    // and then rebuild //:main because the code of the annotation processor has changed
    workspace.getBuildLog().assertTargetHadMatchingRuleKey("//:util");
    workspace.getBuildLog().assertTargetHadMatchingInputRuleKey("//:main");
    workspace.getBuildLog().assertTargetHadMatchingInputRuleKey("//:annotation_processor");
    workspace.getBuildLog().assertTargetBuiltLocally("//:annotation_processor_lib");
}
Also used : BuildTarget(com.facebook.buck.model.BuildTarget) 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