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();
}
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"));
}
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"));
}
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));
}
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");
}
Aggregations