use of com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.CrosstoolRelease in project bazel by bazelbuild.
the class AndroidNdkCrosstoolsTest method testCrosstoolTriples.
/**
* Tests that each (cpu, compiler, glibc) triple in each crosstool is unique in that crosstool.
*/
@Test
public void testCrosstoolTriples() {
StringBuilder errorBuilder = new StringBuilder();
for (CrosstoolRelease crosstool : crosstoolReleases) {
// Create a map of (cpu, compiler, glibc) triples -> toolchain.
ImmutableMultimap.Builder<String, CToolchain> triples = ImmutableMultimap.builder();
for (CToolchain toolchain : crosstool.getToolchainList()) {
String triple = "(" + Joiner.on(", ").join(toolchain.getTargetCpu(), toolchain.getCompiler(), toolchain.getTargetLibc()) + ")";
triples.put(triple, toolchain);
}
// Collect all the duplicate triples.
for (Entry<String, Collection<CToolchain>> entry : triples.build().asMap().entrySet()) {
if (entry.getValue().size() > 1) {
errorBuilder.append(entry.getKey() + ": " + Joiner.on(", ").join(Collections2.transform(entry.getValue(), new Function<CToolchain, String>() {
@Override
public String apply(CToolchain toolchain) {
return toolchain.getToolchainIdentifier();
}
})));
errorBuilder.append("\n");
}
}
errorBuilder.append("\n");
}
// This is a rather awkward condition to test on, but collecting all the duplicates first is
// the only way to make a useful error message rather than finding the errors one by one.
String error = errorBuilder.toString().trim();
if (!error.isEmpty()) {
fail("Toolchains contain duplicate (cpu, compiler, glibc) triples:\n" + error);
}
}
Aggregations