Skip to content

Commit

Permalink
Merge pull request #29006 from ballerina-platform/revert-28956-cov-fi…
Browse files Browse the repository at this point in the history
…lter-fix

Revert "Separate filtering for testerina coverage and codecov coverage"
  • Loading branch information
Dilhasha authored Mar 4, 2021
2 parents 575ca79 + 0adfaff commit 9492cfb
Showing 1 changed file with 15 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,29 +110,8 @@ public void generateReport(JarResolver jarResolver, Map<String, ModuleCoverage>
}

if (!filteredPathList.isEmpty()) {
addCompiledSources(filteredPathList, orgName, packageName, version);
execFileLoader.load(executionDataFile.toFile());
final CoverageBuilder coverageBuilder = analyzeStructure();
// Create testerina coverage report
createReport(coverageBuilder.getBundle(title), moduleCoverageMap);
// Add additional dependency jars for Coverage XML
addCompiledSources(getDependencyJarList(jBallerinaBackend), orgName, packageName, version);
execFileLoader.load(executionDataFile.toFile());
final CoverageBuilder xmlCoverageBuilder = analyzeStructure();
// Create XML coverage report for Codecov
createXMLReport(getPartialCoverageModifiedBundle(xmlCoverageBuilder));
CodeCoverageUtils.deleteDirectory(coverageDir.resolve(BIN_DIR).toFile());
} else {
String msg = "Unable to generate code coverage for the module " + packageName + ". Jar files dont exist.";
throw new NoSuchFileException(msg);
}
}

private void addCompiledSources(List<Path> pathList, String orgName, String packageName, String version) throws
IOException {
if (!pathList.isEmpty()) {
// For each jar file found, we unzip it for this particular module
for (Path jarPath : pathList) {
for (Path jarPath : filteredPathList) {
try {
// Creates coverage folder with each class per module
CodeCoverageUtils.unzipCompiledSource(jarPath, coverageDir, orgName, packageName, version);
Expand All @@ -143,6 +122,15 @@ private void addCompiledSources(List<Path> pathList, String orgName, String pack
return;
}
}

execFileLoader.load(executionDataFile.toFile());
final CoverageBuilder coverageBuilder = analyzeStructure();
createReport(coverageBuilder.getBundle(title), moduleCoverageMap);
createXMLReport(getPartialCoverageModifiedBundle(coverageBuilder));
CodeCoverageUtils.deleteDirectory(coverageDir.resolve(BIN_DIR).toFile());
} else {
String msg = "Unable to generate code coverage for the module " + packageName + ". Jar files dont exist.";
throw new NoSuchFileException(msg);
}
}

Expand Down Expand Up @@ -313,14 +301,6 @@ private Document getDocumentFromModule(Module moduleInstance, String sourceFileN

private List<Path> getExclusionJarList(JBallerinaBackend jBallerinaBackend) {
List<Path> exclusionPathList = new ArrayList<>();
exclusionPathList.addAll(getDependencyJarList(jBallerinaBackend));
exclusionPathList.add(jBallerinaBackend.runtimeLibrary().path());
exclusionPathList.addAll(ProjectUtils.testDependencies());
return exclusionPathList;
}

private List<Path> getDependencyJarList(JBallerinaBackend jBallerinaBackend) {
List<Path> dependencyPathList = new ArrayList<>();
module.packageInstance().getResolution().allDependencies()
.stream()
.map(ResolvedPackageDependency::packageInstance)
Expand All @@ -329,15 +309,17 @@ private List<Path> getDependencyJarList(JBallerinaBackend jBallerinaBackend) {
Module dependencyModule = pkg.module(dependencyModuleId);
PlatformLibrary generatedJarLibrary = jBallerinaBackend.codeGeneratedLibrary(
pkg.packageId(), dependencyModule.moduleName());
dependencyPathList.add(generatedJarLibrary.path());
exclusionPathList.add(generatedJarLibrary.path());
}
Collection<PlatformLibrary> otherJarDependencies = jBallerinaBackend.platformLibraryDependencies(
pkg.packageId(), PlatformLibraryScope.DEFAULT);
for (PlatformLibrary otherJarDependency : otherJarDependencies) {
dependencyPathList.add(otherJarDependency.path());
exclusionPathList.add(otherJarDependency.path());
}
});
return dependencyPathList;
exclusionPathList.add(jBallerinaBackend.runtimeLibrary().path());
exclusionPathList.addAll(ProjectUtils.testDependencies());
return exclusionPathList;
}

private Collection<ISourceFileCoverage> modifySourceFiles(Collection<ISourceFileCoverage> sourcefiles) {
Expand Down

0 comments on commit 9492cfb

Please sign in to comment.