use of com.facebook.buck.jvm.java.JavaLibraryWithTests in project buck by facebook.
the class TestRunning method getRulesUnderTest.
/**
* Generates the set of Java library rules under test.
*/
private static ImmutableSet<JavaLibrary> getRulesUnderTest(Iterable<TestRule> tests) {
ImmutableSet.Builder<JavaLibrary> rulesUnderTest = ImmutableSet.builder();
// Gathering all rules whose source will be under test.
for (TestRule test : tests) {
if (test instanceof JavaTest) {
// Look at the transitive dependencies for `tests` attribute that refers to this test.
JavaTest javaTest = (JavaTest) test;
ImmutableSet<JavaLibrary> transitiveDeps = javaTest.getCompiledTestsLibrary().getTransitiveClasspathDeps();
for (JavaLibrary dep : transitiveDeps) {
if (dep instanceof JavaLibraryWithTests) {
ImmutableSortedSet<BuildTarget> depTests = ((JavaLibraryWithTests) dep).getTests();
if (depTests.contains(test.getBuildTarget())) {
rulesUnderTest.add(dep);
}
}
}
}
}
return rulesUnderTest.build();
}
Aggregations