From 7d74a76b3d7ac807be64a17626d8ba3ef02a6984 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Silva?= Date: Wed, 25 Aug 2021 16:54:05 +0200 Subject: [PATCH] Use flacoco's new API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: André Silva --- .../lille/localization/FlacocoFaultLocalizer.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/nopol/src/main/java/fr/inria/lille/localization/FlacocoFaultLocalizer.java b/nopol/src/main/java/fr/inria/lille/localization/FlacocoFaultLocalizer.java index 72f91a0c..0687cbab 100644 --- a/nopol/src/main/java/fr/inria/lille/localization/FlacocoFaultLocalizer.java +++ b/nopol/src/main/java/fr/inria/lille/localization/FlacocoFaultLocalizer.java @@ -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; @@ -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; @@ -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) { @@ -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()) );