use of com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult in project buck by facebook.
the class TargetsCommandIntegrationTest method testTargetHashChangesAfterModifyingSourceFile.
@Test
public void testTargetHashChangesAfterModifyingSourceFile() 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();
String hash = parseAndVerifyTargetAndHash(result.getStdout(), "//workspace:workspace");
String fileName = "test/Test.m";
Files.write(workspace.getPath(fileName), "// This is not a test\n".getBytes(UTF_8));
ProcessResult result2 = workspace.runBuckCommand("targets", "--show-target-hash", "--detect-test-changes", "//workspace:workspace");
result2.assertSuccess();
String hash2 = parseAndVerifyTargetAndHash(result2.getStdout(), "//workspace:workspace");
assertNotEquals(hash, hash2);
}
use of com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult in project buck by facebook.
the class TargetsCommandIntegrationTest method testValidateBuildTargetForNonAliasTarget.
@Test
public void testValidateBuildTargetForNonAliasTarget() throws IOException {
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "target_validation", tmp);
workspace.setUp();
ProcessResult result = workspace.runBuckCommand("targets", "--resolve-alias", "//:test-library");
assertTrue(result.getStdout(), result.getStdout().contains("//:test-library"));
try {
workspace.runBuckCommand("targets", "--resolve-alias", "//:");
} catch (HumanReadableException e) {
assertEquals("//: cannot end with a colon", e.getMessage());
}
try {
workspace.runBuckCommand("targets", "--resolve-alias", "//:test-libarry");
} catch (HumanReadableException e) {
assertEquals("//:test-libarry is not a valid target.", e.getMessage());
}
try {
workspace.runBuckCommand("targets", "--resolve-alias", "//blah/foo");
} catch (HumanReadableException e) {
assertEquals("//blah/foo must contain exactly one colon (found 0)", e.getMessage());
}
}
use of com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult in project buck by facebook.
the class TargetsCommandIntegrationTest method testJsonOutputWithShowOptions.
@Test
public void testJsonOutputWithShowOptions() throws IOException {
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "output_path", tmp);
workspace.setUp();
ProcessResult result = workspace.runBuckCommand("targets", "--json", "--show-output", "//:test");
ObjectMapper objectMapper = ObjectMappers.newDefaultInstance();
// Parse the observed JSON.
JsonNode observed = objectMapper.readTree(objectMapper.getFactory().createParser(result.getStdout()));
System.out.println(observed.toString());
String expectedJson = workspace.getFileContents("output_path_json.js");
JsonNode expected = objectMapper.readTree(objectMapper.getFactory().createParser(normalizeNewlines(expectedJson)));
MatcherAssert.assertThat("Output from targets command should match expected JSON.", observed, equalTo(expected));
}
use of com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult in project buck by facebook.
the class TargetsCommandIntegrationTest method testShowAllTargets.
@Test
public void testShowAllTargets() throws IOException {
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "xcode_workspace_with_tests", tmp);
workspace.setUp();
ProcessResult result = workspace.runBuckCommand("targets");
result.assertSuccess();
assertEquals(ImmutableSet.of("//bin:bin", "//bin:genrule", "//lib:lib", "//test:test", "//workspace:workspace"), ImmutableSet.copyOf(Splitter.on('\n').omitEmptyStrings().split(result.getStdout())));
}
use of com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult in project buck by facebook.
the class TargetsCommandIntegrationTest method testBuckTargetsReferencedFileWithNonExistentFile.
@Test
public void testBuckTargetsReferencedFileWithNonExistentFile() 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();
String pathToNonExistentFile = "modules/dep1/dep2/hello.txt";
assertFalse(Files.exists(workspace.getPath(pathToNonExistentFile)));
ProcessResult result = workspace.runBuckCommand("targets", "--referenced-file", pathToNonExistentFile);
result.assertSuccess("Even though the file does not exist, buck targets` should succeed.");
assertEquals("Because no targets match, stdout should be empty.", "", result.getStdout());
}
Aggregations