use of com.facebook.buck.jvm.java.GenerateCodeCoverageReportStep in project buck by facebook.
the class TestRunning method getReportCommand.
/**
* Returns the ShellCommand object that is supposed to generate a code coverage report from data
* obtained during the test run. This method will also generate a set of source paths to the class
* files tested during the test run.
*/
private static Step getReportCommand(ImmutableSet<JavaLibrary> rulesUnderTest, DefaultJavaPackageFinder defaultJavaPackageFinder, JavaRuntimeLauncher javaRuntimeLauncher, ProjectFilesystem filesystem, SourcePathResolver sourcePathResolver, SourcePathRuleFinder ruleFinder, Path outputDirectory, CoverageReportFormat format, String title, boolean useIntermediateClassesDir, Optional<String> coverageIncludes, Optional<String> coverageExcludes) {
ImmutableSet.Builder<String> srcDirectories = ImmutableSet.builder();
ImmutableSet.Builder<Path> pathsToJars = ImmutableSet.builder();
// Add all source directories of java libraries that we are testing to -sourcepath.
for (JavaLibrary rule : rulesUnderTest) {
ImmutableSet<String> sourceFolderPath = getPathToSourceFolders(rule, sourcePathResolver, ruleFinder, defaultJavaPackageFinder);
if (!sourceFolderPath.isEmpty()) {
srcDirectories.addAll(sourceFolderPath);
}
Path classesItem = null;
if (useIntermediateClassesDir) {
classesItem = DefaultJavaLibrary.getClassesDir(rule.getBuildTarget(), filesystem);
} else {
SourcePath path = rule.getSourcePathToOutput();
if (path != null) {
classesItem = sourcePathResolver.getRelativePath(path);
}
}
if (classesItem == null) {
continue;
}
pathsToJars.add(classesItem);
}
return new GenerateCodeCoverageReportStep(javaRuntimeLauncher, filesystem, srcDirectories.build(), pathsToJars.build(), outputDirectory, format, title, coverageIncludes, coverageExcludes);
}
Aggregations