use of com.facebook.buck.util.HumanReadableException 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.util.HumanReadableException in project buck by facebook.
the class IntraCellIntegrationTest method shouldTreatCellBoundariesAsVisibilityBoundariesToo.
@SuppressWarnings("PMD.EmptyCatchBlock")
@Test
public void shouldTreatCellBoundariesAsVisibilityBoundariesToo() throws IOException, InterruptedException, BuildFileParseException, BuildTargetException {
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "intracell/visibility", tmp);
workspace.setUp();
// We don't need to do a build. It's enough to just parse these things.
Cell cell = workspace.asCell();
TypeCoercerFactory coercerFactory = new DefaultTypeCoercerFactory(ObjectMappers.newDefaultInstance());
Parser parser = new Parser(new BroadcastEventListener(), cell.getBuckConfig().getView(ParserConfig.class), coercerFactory, new ConstructorArgMarshaller(coercerFactory));
// This parses cleanly
parser.buildTargetGraph(BuckEventBusFactory.newInstance(), cell, false, MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor()), ImmutableSet.of(BuildTargetFactory.newInstance(cell.getFilesystem(), "//just-a-directory:rule")));
Cell childCell = cell.getCell(BuildTargetFactory.newInstance(workspace.getDestPath().resolve("child-repo"), "//:child-target"));
try {
// Whereas, because visibility is limited to the same cell, this won't.
parser.buildTargetGraph(BuckEventBusFactory.newInstance(), childCell, false, MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor()), ImmutableSet.of(BuildTargetFactory.newInstance(childCell.getFilesystem(), "//:child-target")));
fail("Didn't expect parsing to work because of visibility");
} catch (HumanReadableException e) {
// This is expected
}
}
use of com.facebook.buck.util.HumanReadableException in project buck by facebook.
the class GoAssumptions method assumeGoCompilerAvailable.
public static void assumeGoCompilerAvailable() throws InterruptedException, IOException {
Throwable exception = null;
try {
ProcessExecutor executor = new DefaultProcessExecutor(new TestConsole());
FakeBuckConfig.Builder baseConfig = FakeBuckConfig.builder();
String goRoot = System.getenv("GOROOT");
if (goRoot != null) {
baseConfig.setSections("[go]", " root = " + goRoot);
// This should really act like some kind of readonly bind-mount onto the real filesystem.
// But this is currently enough to check whether Go seems to be installed, so we'll live...
FakeProjectFilesystem fs = new FakeProjectFilesystem();
fs.mkdirs(fs.getPath(goRoot));
baseConfig.setFilesystem(fs);
}
new GoBuckConfig(baseConfig.build(), executor, FlavorDomain.from("Cxx", ImmutableSet.of())).getCompiler();
} catch (HumanReadableException e) {
exception = e;
}
assumeNoException(exception);
}
use of com.facebook.buck.util.HumanReadableException in project buck by facebook.
the class MavenUrlDecoderTest method optionalServerUrlMustBeHttpOrHttps.
@Test
@SuppressWarnings("PMD.EmptyCatchBlock")
public void optionalServerUrlMustBeHttpOrHttps() throws URISyntaxException {
Optional<String> repo = Optional.of("http://foo.bar");
MavenUrlDecoder.toHttpUrl(repo, new URI("mvn:http://example.org/:org.seleniumhq.selenium:selenium-java:jar:2.42.2"));
MavenUrlDecoder.toHttpUrl(repo, new URI("mvn:https://example.org/:org.seleniumhq.selenium:selenium-java:jar:2.42.2"));
try {
MavenUrlDecoder.toHttpUrl(repo, new URI("mvn:mvn://custom.org/:org.seleniumhq.selenium:selenium-java:jar:2.42.2"));
fail();
} catch (HumanReadableException expected) {
// Ignored
}
}
use of com.facebook.buck.util.HumanReadableException in project buck by facebook.
the class JavaBuckConfigTest method whenJavacIsNotExecutableThenHumanReadableExeceptionIsThrown.
@Test
public void whenJavacIsNotExecutableThenHumanReadableExeceptionIsThrown() throws IOException {
assumeThat("Files on Windows are executable by default.", Platform.detect(), is(not(Platform.WINDOWS)));
Path javac = temporaryFolder.newFile();
Reader reader = new StringReader(Joiner.on('\n').join("[tools]", " javac = " + javac.toString()));
JavaBuckConfig config = createWithDefaultFilesystem(reader);
try {
config.getJavacPath();
fail("Should throw exception as javac file is not executable.");
} catch (HumanReadableException e) {
assertEquals(e.getHumanReadableErrorMessage(), "javac is not executable: " + javac);
}
}
Aggregations