Skip to content

Commit

Permalink
Use flacoco's new API
Browse files Browse the repository at this point in the history
Signed-off-by: André Silva <[email protected]>
  • Loading branch information
andre15silva committed Aug 25, 2021
1 parent 8def263 commit 7d74a76
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import fr.inria.lille.localization.metric.Ochiai;
import fr.inria.lille.repair.common.config.NopolContext;
import fr.inria.lille.repair.nopol.SourceLocation;
import fr.spoonlabs.flacoco.api.result.Location;
import fr.spoonlabs.flacoco.core.config.FlacocoConfig;
import fr.spoonlabs.flacoco.core.coverage.CoverageMatrix;
import fr.spoonlabs.flacoco.core.coverage.CoverageRunner;
Expand Down Expand Up @@ -86,10 +87,10 @@ private void runFlacoco(NopolContext nopolContext, Metric metric) {
CoverageRunner coverageRunner = new CoverageRunner();
CoverageMatrix coverageMatrix = coverageRunner.getCoverageMatrix(new TestDetector().getTests());

for (String line : coverageMatrix.getResultExecution().keySet()) {
for (Location location : coverageMatrix.getResultExecution().keySet()) {
SourceLocation sourceLocation = new SourceLocation(
line.split("@-@")[0].replace("/", "."),
Integer.parseInt(line.split("@-@")[1])
location.getClassName(),
location.getLineNumber()
);
StatementSourceLocation statementSourceLocation = new StatementSourceLocation(metric, sourceLocation);
int ef = 0;
Expand All @@ -98,7 +99,7 @@ private void runFlacoco(NopolContext nopolContext, Metric metric) {
int np = 0;
for (TestMethod testMethod : coverageMatrix.getTests().keySet()) {
boolean iTestPassing = coverageMatrix.getTests().get(testMethod);
boolean nrExecuted = coverageMatrix.getResultExecution().get(line).contains(testMethod);
boolean nrExecuted = coverageMatrix.getResultExecution().get(location).contains(testMethod);
if (iTestPassing && nrExecuted) {
ep++;
} else if (!iTestPassing && nrExecuted) {
Expand All @@ -117,7 +118,7 @@ private void runFlacoco(NopolContext nopolContext, Metric metric) {
statementSourceLocations.add(statementSourceLocation);
testListPerStatement.put(
sourceLocation,
coverageMatrix.getResultExecution().get(line).stream()
coverageMatrix.getResultExecution().get(location).stream()
.map(x -> new TestResultImpl(TestCase.from(x.getFullyQualifiedMethodName()), coverageMatrix.getTests().get(x)))
.collect(Collectors.toList())
);
Expand Down

0 comments on commit 7d74a76

Please sign in to comment.