use of com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult in project buck by facebook.
the class TargetsCommandIntegrationTest method testRuleKeyWithoutTarget.
@Test
public void testRuleKeyWithoutTarget() throws IOException {
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "output_path", tmp);
workspace.setUp();
ProcessResult result = workspace.runBuckCommand("targets", "--show-rulekey");
result.assertSuccess();
assertThat(result.getStdout().trim(), Matchers.matchesPattern("//:another-test [a-f0-9]{40}\n//:test [a-f0-9]{40}"));
}
use of com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult in project buck by facebook.
the class TargetsCommandIntegrationTest method testTargetHashXcodeWorkspaceWithTests.
@Test
public void testTargetHashXcodeWorkspaceWithTests() throws IOException {
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "xcode_workspace_with_tests", tmp);
workspace.setUp();
ProcessResult result = workspace.runBuckCommand("targets", "--show-target-hash", "--detect-test-changes", "//workspace:workspace");
result.assertSuccess();
parseAndVerifyTargetAndHash(result.getStdout(), "//workspace:workspace");
}
use of com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult in project buck by facebook.
the class TargetsCommandIntegrationTest method testJsonOutputWithShowFullOutput.
@Test
public void testJsonOutputWithShowFullOutput() throws IOException {
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "output_path", tmp);
workspace.setUp();
ProcessResult result = workspace.runBuckCommand("targets", "--json", "--show-full-output", "//:test");
ObjectMapper objectMapper = ObjectMappers.newDefaultInstance();
// Parse the observed JSON.
JsonNode observed = objectMapper.readTree(objectMapper.getFactory().createParser(result.getStdout()));
assertTrue(observed.isArray());
JsonNode targetNode = observed.get(0);
assertTrue(targetNode.isObject());
JsonNode cellPath = targetNode.get("buck.outputPath");
assertNotNull(cellPath);
Path expectedPath = tmp.getRoot().resolve("buck-out/gen/test/test-output");
String expectedRootPath = MorePaths.pathWithPlatformSeparators(expectedPath);
assertEquals(expectedRootPath, cellPath.asText());
}
use of com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult in project buck by facebook.
the class CachedTestIntegrationTest method testRunningTestAfterBuildingWithCacheHitDoesNotReportStaleTests.
/**
* This is similar to {@link #testPullingJarFromCacheDoesNotResultInReportingStaleTestResults()}
* but this first builds the test and then runs it. It catches the corner case where the test run
* may have the jar read from disk, but the test results are still stale.
*/
@Test
public void testRunningTestAfterBuildingWithCacheHitDoesNotReportStaleTests() throws IOException {
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "cached_test", tmp);
workspace.setUp();
CachedTestUtil testUtil = new CachedTestUtil(workspace);
// The test should pass out of the box.
ProcessResult result = workspace.runBuckCommand("test", "//:test");
result.assertSuccess();
// Edit the test so it should fail and then make sure that it fails.
testUtil.makeTestFail();
workspace.runBuckCommand("build", "//:test").assertSuccess("The test should build successfully, but will fail when executed.");
ProcessResult result2 = workspace.runBuckCommand("test", "//:test");
result2.assertTestFailure();
assertThat("`buck test` should fail because testBasicAssertion() failed.", result2.getStderr(), containsString("FAILURE com.example.LameTest testBasicAssertion"));
// Restore the file to its previous state.
testUtil.makeTestSucceed();
workspace.runBuckCommand("build", "//:test").assertSuccess("The test should build successfully.");
ProcessResult result3 = workspace.runBuckCommand("test", "//:test");
result3.assertSuccess();
// Put the file back in the broken state and make sure the test fails.
testUtil.makeTestFail();
workspace.runBuckCommand("build", "//:test").assertSuccess("The test should build successfully, but will fail when executed.");
ProcessResult result4 = workspace.runBuckCommand("test", "//:test");
result4.assertTestFailure();
assertThat("`buck test` should fail because testBasicAssertion() failed.", result4.getStderr(), containsString("FAILURE com.example.LameTest testBasicAssertion"));
}
use of com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult in project buck by facebook.
the class DefaultJavaLibraryIntegrationTest method updatingAResourceWhichIsJavaLibraryCausesAJavaLibraryToBeRepacked.
@Test
public void updatingAResourceWhichIsJavaLibraryCausesAJavaLibraryToBeRepacked() throws IOException {
workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "resource_change_causes_repack", tmp);
workspace.setUp();
// Run `buck build`.
ProcessResult buildResult = workspace.runBuckCommand("build", "//:lib");
buildResult.assertSuccess("Successful build should exit with 0.");
workspace.copyFile("ResClass.java.new", "ResClass.java");
workspace.resetBuildLogFile();
// The copied file changed the contents but not the ABI of :lib. Because :lib is included as a
// resource of :res, it's expected that both :lib and :res are rebuilt (:lib because of a code
// change, :res in order to repack the resource)
buildResult = workspace.runBuckCommand("build", "//:lib");
buildResult.assertSuccess("Successful build should exit with 0.");
workspace.getBuildLog().assertTargetBuiltLocally("//:res");
workspace.getBuildLog().assertTargetBuiltLocally("//:lib");
}
Aggregations