use of com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult in project buck by facebook.
the class TargetsCommandIntegrationTest method testBuckTargetsReferencedFileWithFileOutsideOfProject.
@Test
public void testBuckTargetsReferencedFileWithFileOutsideOfProject() throws IOException {
// The contents of the project are not relevant for this test. We just want a non-empty project
// to prevent against a regression where all of the build rules are printed.
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "project_slice", tmp);
workspace.setUp();
ProcessResult result = workspace.runBuckCommand("targets", "--referenced-file", ABSOLUTE_PATH_TO_FILE_OUTSIDE_THE_PROJECT_THAT_EXISTS_ON_THE_FS);
result.assertSuccess("Even though the file is outside the project, " + "`buck targets` should succeed.");
assertEquals("Because no targets match, stdout should be empty.", "", result.getStdout());
}
use of com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult in project buck by facebook.
the class TargetsCommandIntegrationTest method testRuleKeyWithReferencedFilesAndDetectTestChanges.
@Test
public void testRuleKeyWithReferencedFilesAndDetectTestChanges() throws IOException {
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "java_library_with_tests", tmp);
workspace.setUp();
ProcessResult result = workspace.runBuckCommand("targets", "--show-rulekey", "--detect-test-changes", "--referenced-file", "Test.java");
result.assertSuccess();
parseAndVerifyTargetsAndHashes(result.getStdout(), "//:lib", "//:test");
}
use of com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult in project buck by facebook.
the class TargetsCommandIntegrationTest method testRuleKey.
@Test
public void testRuleKey() throws IOException {
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "output_path", tmp);
workspace.setUp();
ProcessResult result = workspace.runBuckCommand("targets", "--show-rulekey", "//:test", "//:another-test");
result.assertSuccess();
parseAndVerifyTargetsAndHashes(result.getStdout(), "//:another-test", "//:test");
}
use of com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult in project buck by facebook.
the class TargetsCommandIntegrationTest method testJsonOutputWithShowCellPath.
@Test
public void testJsonOutputWithShowCellPath() throws IOException {
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "output_path", tmp);
workspace.setUp();
ProcessResult result = workspace.runBuckCommand("targets", "--json", "--show-cell-path", "//: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.cell_path");
assertNotNull(cellPath);
assertEquals(cellPath.asText(), MorePaths.pathWithPlatformSeparators(tmp.getRoot().toRealPath()));
}
use of com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult in project buck by facebook.
the class TargetsCommandTest method testJsonOutputWithDirectDependencies.
@Test
public void testJsonOutputWithDirectDependencies() throws IOException {
// Run Buck targets command on a case where the deps and direct_dependencies differ
ProcessResult result = workspace.runBuckCommand("targets", "--json", "//:B");
// Parse the observed JSON.
JsonNode observed = objectMapper.readTree(objectMapper.getFactory().createParser(result.getStdout()).enable(Feature.ALLOW_COMMENTS));
// Parse the expected JSON.
String expectedJson = workspace.getFileContents("TargetsCommandTestBuckJson2.js");
JsonNode expected = objectMapper.readTree(objectMapper.getFactory().createParser(expectedJson).enable(Feature.ALLOW_COMMENTS));
assertThat("Output from targets command should match expected JSON.", observed, is(equalTo(expected)));
assertThat("Nothing should be printed to stderr.", console.getTextWrittenToStdErr(), is(equalTo("")));
}
Aggregations