use of org.apache.beam.vendor.calcite.v1_28_0.com.google.common.annotations.VisibleForTesting in project buck by facebook.
the class ExopackageInstaller method filterLibrariesForAbi.
@VisibleForTesting
static ImmutableMap<String, Path> filterLibrariesForAbi(Path nativeLibsDir, ImmutableMultimap<String, Path> allLibraries, String abi, ImmutableSet<String> ignoreLibraries) {
ImmutableMap.Builder<String, Path> filteredLibraries = ImmutableMap.builder();
for (Map.Entry<String, Path> entry : allLibraries.entries()) {
Path relativePath = nativeLibsDir.relativize(entry.getValue());
// relativePath is of the form libs/x86/foo.so, or assetLibs/x86/foo.so etc.
Preconditions.checkState(relativePath.getNameCount() == 3);
Preconditions.checkState(relativePath.getName(0).toString().equals("libs") || relativePath.getName(0).toString().equals("assetLibs"));
String libAbi = relativePath.getParent().getFileName().toString();
String libName = relativePath.getFileName().toString();
if (libAbi.equals(abi) && !ignoreLibraries.contains(libName)) {
filteredLibraries.put(entry);
}
}
return filteredLibraries.build();
}
use of org.apache.beam.vendor.calcite.v1_28_0.com.google.common.annotations.VisibleForTesting in project buck by facebook.
the class CompileStringsStep method groupFilesByLocale.
/**
* Groups a list of strings.xml files by locale.
* String files with no resource qualifier (eg. values/strings.xml) are mapped to the "en" locale
*
* eg. given the following list:
*
* ImmutableList.of(
* Paths.get("one/res/values-es/strings.xml"),
* Paths.get("two/res/values-es/strings.xml"),
* Paths.get("three/res/values-pt-rBR/strings.xml"),
* Paths.get("four/res/values-pt-rPT/strings.xml"),
* Paths.get("five/res/values/strings.xml"));
*
* returns:
*
* ImmutableMap.of(
* "es", ImmutableList.of(Paths.get("one/res/values-es/strings.xml"),
* Paths.get("two/res/values-es/strings.xml")),
* "pt_BR", ImmutableList.of(Paths.get("three/res/values-pt-rBR/strings.xml'),
* "pt_PT", ImmutableList.of(Paths.get("four/res/values-pt-rPT/strings.xml"),
* "en", ImmutableList.of(Paths.get("five/res/values/strings.xml")));
*/
@VisibleForTesting
ImmutableMultimap<String, Path> groupFilesByLocale(ImmutableList<Path> files) {
ImmutableMultimap.Builder<String, Path> localeToFiles = ImmutableMultimap.builder();
for (Path filepath : files) {
String path = MorePaths.pathWithUnixSeparators(filepath);
Matcher matcher = NON_ENGLISH_STRING_FILE_PATTERN.matcher(path);
if (matcher.matches()) {
String baseLocale = matcher.group(1);
String country = matcher.group(2);
String locale = country == null ? baseLocale : baseLocale + "_" + country;
if (country != null && !regionSpecificToBaseLocaleMap.containsKey(locale)) {
regionSpecificToBaseLocaleMap.put(locale, baseLocale);
}
localeToFiles.put(locale, filepath);
} else {
Preconditions.checkState(path.endsWith(ENGLISH_STRING_PATH_SUFFIX), "Invalid path passed to compile strings: " + path);
localeToFiles.put(ENGLISH_LOCALE, filepath);
}
}
return localeToFiles.build();
}
use of org.apache.beam.vendor.calcite.v1_28_0.com.google.common.annotations.VisibleForTesting in project buck by facebook.
the class RuleUtils method createGroupsFromEntryMaps.
@VisibleForTesting
static ImmutableList<GroupedSource> createGroupsFromEntryMaps(Multimap<Path, String> subgroups, Multimap<Path, GroupedSource> entries, Comparator<GroupedSource> comparator, Path rootGroupPath, Path groupPath) {
ImmutableList.Builder<GroupedSource> groupBuilder = ImmutableList.builder();
for (String subgroupName : ImmutableSortedSet.copyOf(subgroups.get(groupPath))) {
Path subgroupPath = groupPath.resolve(subgroupName);
groupBuilder.add(GroupedSource.ofSourceGroup(subgroupName, subgroupPath.subpath(rootGroupPath.getNameCount(), subgroupPath.getNameCount()), createGroupsFromEntryMaps(subgroups, entries, comparator, rootGroupPath, subgroupPath)));
}
SortedSet<GroupedSource> sortedEntries = ImmutableSortedSet.copyOf(comparator, entries.get(groupPath));
for (GroupedSource groupedSource : sortedEntries) {
groupBuilder.add(groupedSource);
}
return groupBuilder.build().asList();
}
use of org.apache.beam.vendor.calcite.v1_28_0.com.google.common.annotations.VisibleForTesting in project buck by facebook.
the class CxxDescriptionEnhancer method getNonDefaultSharedLibrarySoname.
@VisibleForTesting
static String getNonDefaultSharedLibrarySoname(String declared, String sharedLibraryExtension, String sharedLibraryVersionedExtensionFormat) {
Matcher match = SONAME_EXT_MACRO_PATTERN.matcher(declared);
if (!match.find()) {
return declared;
}
String version = match.group(1);
if (version == null) {
return match.replaceFirst(sharedLibraryExtension);
}
return match.replaceFirst(String.format(sharedLibraryVersionedExtensionFormat, version));
}
use of org.apache.beam.vendor.calcite.v1_28_0.com.google.common.annotations.VisibleForTesting in project buck by facebook.
the class TestCommand method filterTestRules.
@VisibleForTesting
Iterable<TestRule> filterTestRules(BuckConfig buckConfig, ImmutableSet<BuildTarget> explicitBuildTargets, Iterable<TestRule> testRules) {
ImmutableSortedSet.Builder<TestRule> builder = ImmutableSortedSet.orderedBy(Comparator.comparing(TestRule::getFullyQualifiedName));
for (TestRule rule : testRules) {
boolean explicitArgument = explicitBuildTargets.contains(rule.getBuildTarget());
boolean matchesLabel = isMatchedByLabelOptions(buckConfig, rule.getLabels());
// want to.
if (shouldExcludeWin() && !matchesLabel) {
continue;
}
// filter those out if such is the user's will.
if (shouldExcludeTransitiveTests() && !explicitArgument) {
continue;
}
// were explicitly specified by the user.
if (explicitArgument || matchesLabel) {
builder.add(rule);
}
}
return builder.build();
}
Aggregations