use of com.facebook.buck.util.HumanReadableException in project buck by facebook.
the class JavaBuckConfigTest method whenJavacJarDoesNotExistThenHumanReadableExceptionIsThrown.
@Test
public void whenJavacJarDoesNotExistThenHumanReadableExceptionIsThrown() throws IOException {
String invalidPath = temporaryFolder.getRoot().toAbsolutePath() + "DoesNotExist";
Reader reader = new StringReader(Joiner.on('\n').join("[tools]", " javac_jar = " + invalidPath.replace("\\", "\\\\")));
JavaBuckConfig config = createWithDefaultFilesystem(reader);
try {
config.getJavacJarPath();
fail("Should throw exception as javac file does not exist.");
} catch (HumanReadableException e) {
assertEquals("Overridden tools:javac_jar path not found: " + invalidPath, e.getHumanReadableErrorMessage());
}
}
use of com.facebook.buck.util.HumanReadableException in project buck by facebook.
the class ParserIntegrationTest method testBoundaryChecksAreEnforced.
@Test
public void testBoundaryChecksAreEnforced() throws IOException {
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "package_boundaries", temporaryFolder);
workspace.setUp();
try {
workspace.runBuckCommand("build", "//java:foo");
fail("Expected exception");
} catch (HumanReadableException e) {
assertThat(e.getMessage(), containsString("package boundary"));
}
workspace.addBuckConfigLocalOption("project", "check_package_boundary", "false");
workspace.runBuckCommand("build", "//java:foo").assertSuccess();
workspace.addBuckConfigLocalOption("project", "check_package_boundary", "true");
workspace.addBuckConfigLocalOption("project", "package_boundary_exceptions", "java");
workspace.runBuckCommand("build", "//java:foo").assertSuccess();
try {
workspace.runBuckCommand("build", "//java2:foo").assertSuccess();
fail("Expected exception");
} catch (HumanReadableException e) {
assertThat(e.getMessage(), containsString("package boundary"));
}
}
use of com.facebook.buck.util.HumanReadableException in project buck by facebook.
the class PythonPackageableComponentsTest method testDuplicateSourcesInComponentsThrowsException.
@Test
public void testDuplicateSourcesInComponentsThrowsException() {
BuildTarget me = BuildTargetFactory.newInstance("//:me");
BuildTarget them = BuildTargetFactory.newInstance("//:them");
Path dest = Paths.get("test");
PythonPackageComponents compA = PythonPackageComponents.of(ImmutableMap.of(dest, new FakeSourcePath("sourceA")), ImmutableMap.of(), ImmutableMap.of(), ImmutableSet.of(), Optional.empty());
PythonPackageComponents compB = PythonPackageComponents.of(ImmutableMap.of(dest, new FakeSourcePath("sourceB")), ImmutableMap.of(), ImmutableMap.of(), ImmutableSet.of(), Optional.empty());
PythonPackageComponents.Builder builder = new PythonPackageComponents.Builder(me);
builder.addComponent(compA, them);
try {
builder.addComponent(compB, them);
fail("expected to throw");
} catch (HumanReadableException e) {
assertTrue(e.getMessage().contains("duplicate entries"));
}
}
use of com.facebook.buck.util.HumanReadableException in project buck by facebook.
the class GenruleTest method testConstructingGenruleWithBadWorkerMacroThrows.
@Test
public void testConstructingGenruleWithBadWorkerMacroThrows() throws Exception {
BuildRuleResolver ruleResolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
GenruleBuilder genruleBuilder = createGenruleBuilderThatUsesWorkerMacro(ruleResolver);
try {
genruleBuilder.setBash("no worker macro here").build(ruleResolver);
} catch (HumanReadableException e) {
assertEquals(String.format("You cannot use a worker macro in one of the cmd, bash, or " + "cmd_exe properties and not in the others for genrule //:genrule_with_worker."), e.getHumanReadableErrorMessage());
}
}
use of com.facebook.buck.util.HumanReadableException in project buck by facebook.
the class WorkerProcessProtocolZeroTest method testReceiveHandshakeWithMalformedJSON.
@Test
public void testReceiveHandshakeWithMalformedJSON() throws IOException {
String malformedJson = "=^..^= meow";
WorkerProcessProtocol protocol = new WorkerProcessProtocolZero(fakeProcessExecutor, fakeLaunchedProcess, dummyJsonWriter, new JsonReader(new StringReader(malformedJson)), newTempFile());
try {
protocol.receiveHandshake(123);
} catch (HumanReadableException e) {
assertThat(e.getMessage(), Matchers.containsString("Error receiving handshake response"));
}
}
Aggregations