use of com.facebook.buck.util.HumanReadableException in project buck by facebook.
the class MainIntegrationTest method testConfigRemoval.
@Test
public void testConfigRemoval() throws IOException, InterruptedException {
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "includes_removals", tmp);
workspace.setUp();
// It should produce exception as we want explicit ide setting.
try {
workspace.runBuckCommand("project", "--config", "project.ide=");
} catch (HumanReadableException e) {
assertThat(e.getHumanReadableErrorMessage(), Matchers.stringContainsInOrder("Please specify ide using --ide option " + "or set ide in .buckconfig"));
} catch (Exception e) {
// other exceptions are not expected
throw e;
}
}
use of com.facebook.buck.util.HumanReadableException in project buck by facebook.
the class AbstractPrebuiltCxxLibraryGroupDescription method getStaticLinkArgs.
/**
* @return the link args formed from the user-provided static link line after resolving library
* macro references.
*/
private Iterable<Arg> getStaticLinkArgs(BuildTarget target, ImmutableList<SourcePath> libs, ImmutableList<String> args) {
ImmutableList.Builder<Arg> builder = ImmutableList.builder();
for (String arg : args) {
Optional<Pair<String, String>> libRef = getLibRef(ImmutableSet.of(LIB_MACRO), arg);
if (libRef.isPresent()) {
int index;
try {
index = Integer.parseInt(libRef.get().getSecond());
} catch (NumberFormatException e) {
throw new HumanReadableException("%s: ", target);
}
if (index < 0 || index >= libs.size()) {
throw new HumanReadableException("%s: ", target);
}
builder.add(SourcePathArg.of(libs.get(index)));
} else {
builder.add(StringArg.of(arg));
}
}
return builder.build();
}
use of com.facebook.buck.util.HumanReadableException in project buck by facebook.
the class TargetsCommand method getDependentNodes.
/**
* @param graph A graph used to resolve dependencies between targets.
* @param nodes A set of nodes.
* @param detectTestChanges If true, tests are considered to be dependencies of the targets they
* are testing.
* @return A set of all nodes that transitively depend on {@code nodes}
* (a superset of {@code nodes}).
*/
private static ImmutableSet<TargetNode<?, ?>> getDependentNodes(final TargetGraph graph, ImmutableSet<TargetNode<?, ?>> nodes, boolean detectTestChanges) {
ImmutableMultimap.Builder<TargetNode<?, ?>, TargetNode<?, ?>> extraEdgesBuilder = ImmutableMultimap.builder();
if (detectTestChanges) {
for (TargetNode<?, ?> node : graph.getNodes()) {
if (node.getConstructorArg() instanceof HasTests) {
ImmutableSortedSet<BuildTarget> tests = ((HasTests) node.getConstructorArg()).getTests();
for (BuildTarget testTarget : tests) {
Optional<TargetNode<?, ?>> testNode = graph.getOptional(testTarget);
if (!testNode.isPresent()) {
throw new HumanReadableException("'%s' (test of '%s') is not in the target graph.", testTarget, node);
}
extraEdgesBuilder.put(testNode.get(), node);
}
}
}
}
final ImmutableMultimap<TargetNode<?, ?>, TargetNode<?, ?>> extraEdges = extraEdgesBuilder.build();
final ImmutableSet.Builder<TargetNode<?, ?>> builder = ImmutableSet.builder();
AbstractBreadthFirstTraversal<TargetNode<?, ?>> traversal = new AbstractBreadthFirstTraversal<TargetNode<?, ?>>(nodes) {
@Override
public ImmutableSet<TargetNode<?, ?>> visit(TargetNode<?, ?> targetNode) {
builder.add(targetNode);
return FluentIterable.from(graph.getIncomingNodesFor(targetNode)).append(extraEdges.get(targetNode)).toSet();
}
};
traversal.start();
return builder.build();
}
use of com.facebook.buck.util.HumanReadableException in project buck by facebook.
the class HaskellBuckConfig method getCompiler.
@Override
public ToolProvider getCompiler() {
Optional<ToolProvider> configuredCompiler = delegate.getToolProvider(SECTION, "compiler");
if (configuredCompiler.isPresent()) {
return configuredCompiler.get();
}
Optional<Path> systemCompiler = getSystemCompiler();
if (systemCompiler.isPresent()) {
return new ConstantToolProvider(new HashedFileTool(systemCompiler.get()));
}
throw new HumanReadableException("No Haskell compiler found in .buckconfig (%s.compiler) or on system", SECTION);
}
use of com.facebook.buck.util.HumanReadableException in project buck by facebook.
the class GoDescriptors method makeSymlinkTree.
private static SymlinkTree makeSymlinkTree(BuildRuleParams params, SourcePathResolver pathResolver, SourcePathRuleFinder ruleFinder, ImmutableSet<GoLinkable> linkables) {
ImmutableMap.Builder<Path, SourcePath> treeMapBuilder = ImmutableMap.builder();
for (GoLinkable linkable : linkables) {
for (Map.Entry<Path, SourcePath> linkInput : linkable.getGoLinkInput().entrySet()) {
treeMapBuilder.put(getPathInSymlinkTree(pathResolver, linkInput.getKey(), linkInput.getValue()), linkInput.getValue());
}
}
ImmutableMap<Path, SourcePath> treeMap;
try {
treeMap = treeMapBuilder.build();
} catch (IllegalArgumentException ex) {
throw new HumanReadableException(ex, "Multiple go targets have the same package name when compiling %s", params.getBuildTarget().getFullyQualifiedName());
}
Path root = BuildTargets.getScratchPath(params.getProjectFilesystem(), params.getBuildTarget(), "__%s__tree");
return new SymlinkTree(params.getBuildTarget(), params.getProjectFilesystem(), root, treeMap, ruleFinder);
}
Aggregations