use of org.apache.beam.vendor.calcite.v1_28_0.com.google.common.annotations.VisibleForTesting in project buck by facebook.
the class CxxLinkableEnhancer method frameworksToLinkerArg.
@VisibleForTesting
static Arg frameworksToLinkerArg(ImmutableSortedSet<FrameworkPath> frameworkPaths) {
return new FrameworkPathArg(frameworkPaths) {
@Override
public void appendToCommandLine(ImmutableCollection.Builder<String> builder, SourcePathResolver pathResolver) {
for (FrameworkPath frameworkPath : frameworkPaths) {
builder.add("-framework");
builder.add(frameworkPath.getName(pathResolver::getAbsolutePath));
}
}
};
}
use of org.apache.beam.vendor.calcite.v1_28_0.com.google.common.annotations.VisibleForTesting in project buck by facebook.
the class BuckDeps method maybeAddDepToTarget.
/**
* Given the contents of a BUCK file, try to modify the
* contents to add the given dependency to the given
* target.
*/
@VisibleForTesting
static String maybeAddDepToTarget(String buckContents, String dependency, String target) {
int[] targetOffset = findTargetInBuckFileContents(buckContents, target);
if (targetOffset == null) {
LOG.warn("Couldn't find target definition for " + target);
// TODO(ideabuck): make this a better parser
return buckContents;
}
String targetDef = buckContents.substring(targetOffset[0], targetOffset[1]);
if (autodepsPattern.matcher(targetDef).find()) {
// TODO(ideabuck): Once 'buck autodeps' stabilizes, should we invoke it here?
return buckContents;
}
Matcher exportedDepsMatcher = exportedDepsPattern.matcher(targetDef);
if (exportedDepsMatcher.find()) {
String exportedDeps = exportedDepsMatcher.group(1);
if (exportedDeps.contains(dependency)) {
// If it already appears in the exported_deps section, nothing to do
return buckContents;
}
}
Matcher depsMatcher = depsPattern.matcher(targetDef);
if (!depsMatcher.find()) {
LOG.warn("Couldn't figure out where to add new dependency on " + dependency + " in definition for " + target);
return buckContents;
}
if (depsMatcher.group(1).contains(dependency)) {
// already have dep in the deps section
return buckContents;
}
int offset = targetOffset[0] + depsMatcher.start(1);
return buckContents.substring(0, offset) + "\n\t\t'" + dependency + "'," + buckContents.substring(offset);
}
use of org.apache.beam.vendor.calcite.v1_28_0.com.google.common.annotations.VisibleForTesting in project buck by facebook.
the class BuckDeps method maybeAddVisibilityToTarget.
@VisibleForTesting
static String maybeAddVisibilityToTarget(String buckContents, String visibility, String target) {
int[] targetOffset = findTargetInBuckFileContents(buckContents, target);
if (targetOffset == null) {
LOG.warn("Couldn't find target definition for " + target);
// TODO(ideabuck): make this a better parser
return buckContents;
}
String targetDef = buckContents.substring(targetOffset[0], targetOffset[1]);
Matcher visibilityMatcher = visibilityPattern.matcher(targetDef);
if (!visibilityMatcher.find()) {
LOG.warn("Couldn't figure out where to increase visibility for " + target + " to include " + visibility);
// TODO(ideabuck): try harder to figure out where to add the visibility
return buckContents;
}
if (visibilityMatcher.group(1).contains(visibility)) {
// already visibile to this caller
return buckContents;
}
int offset = targetOffset[0] + visibilityMatcher.start(1);
buckContents = buckContents.substring(0, offset) + "\n\t\t'" + visibility + "'," + buckContents.substring(offset);
return buckContents;
}
use of org.apache.beam.vendor.calcite.v1_28_0.com.google.common.annotations.VisibleForTesting in project buck by facebook.
the class JavacStep method findFailedImports.
@VisibleForTesting
static ImmutableSet<String> findFailedImports(String output) {
Iterable<String> lines = Splitter.on(LINE_SEPARATOR).split(output);
ImmutableSortedSet.Builder<String> failedImports = ImmutableSortedSet.naturalOrder();
for (String line : lines) {
if (IS_WARNING.matcher(line).find()) {
continue;
}
for (Pattern missingImportPattern : MISSING_IMPORT_PATTERNS) {
Matcher lineMatch = missingImportPattern.matcher(line);
if (lineMatch.matches()) {
failedImports.add(lineMatch.group(1));
break;
}
}
}
return failedImports.build();
}
use of org.apache.beam.vendor.calcite.v1_28_0.com.google.common.annotations.VisibleForTesting in project buck by facebook.
the class BlockingHttpEndpoint method send.
@VisibleForTesting
HttpResponse send(final HttpURLConnection connection, final String content) throws IOException {
try (DataOutputStream out = new DataOutputStream(connection.getOutputStream())) {
out.writeBytes(content);
out.flush();
out.close();
InputStream inputStream = connection.getInputStream();
String response = CharStreams.toString(new InputStreamReader(inputStream, Charsets.UTF_8));
return new HttpResponse(response);
} finally {
connection.disconnect();
}
}
Aggregations