Skip to content

Commit

Permalink
[WIP] compilation OK but tests NOK
Browse files Browse the repository at this point in the history
  • Loading branch information
echebbi committed Mar 23, 2024
1 parent 0b1f292 commit dafd5b2
Show file tree
Hide file tree
Showing 8 changed files with 184 additions and 148 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void handleMutationResult(ClassMutationResults results) {
result.getKillingTest().ifPresent(mutation::setKillingTest);
mutation.setLineNumber(BigInteger.valueOf(details.getLineNumber()));
mutation.setMutatedClass(details.getClassName().asJavaName());
mutation.setMutatedMethod(details.getMethod().name());
mutation.setMutatedMethod(details.getMethod());
mutation.setMutator(details.getMutator());
mutation.setSourceFile(details.getFilename());
mutation.setStatus(DetectionStatusCoverter.convert(result.getStatus()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.Objects;

import org.pitest.classinfo.ClassInfo;
import org.pitest.coverage.CoverageData;
import org.pitest.mutationtest.ClassMutationResults;
import org.pitest.mutationtest.MutationResult;

Expand All @@ -43,13 +44,14 @@ private ClassSummary(String className, Coverage lineCoverage, Coverage mutationC
this.mutationCoverage = mutationCoverage;
}

public static ClassSummary from(ClassMutationResults results, ClassInfo classInfo, int linesCovered) {
public static ClassSummary from(ClassMutationResults results, int numberOfCodeLines, int linesCovered) {
Collection<MutationResult> mutations = results.getMutations();
int totalMutations = mutations.size();
int survivedMutations = (int) mutations.stream()
.filter(m -> !m.getStatus().isDetected())
.count();
Coverage lineCoverage = Coverage.from(linesCovered, classInfo.getNumberOfCodeLines());
CoverageData data;
Coverage lineCoverage = Coverage.from(linesCovered, numberOfCodeLines);
Coverage mutationCoverage = Coverage.from(totalMutations - survivedMutations, totalMutations);

return from(results.getMutatedClass().asJavaName(), lineCoverage, mutationCoverage);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@
import java.util.Collections;
import java.util.List;

import org.pitest.classinfo.ClassInfo;
import org.pitest.classinfo.ClassName;
import org.pitest.coverage.CoverageDatabase;
import org.pitest.coverage.ReportCoverage;
import org.pitest.mutationtest.ClassMutationResults;
import org.pitest.mutationtest.MutationResultListener;
import org.pitest.pitclipse.runner.results.Dispatcher;
Expand All @@ -37,7 +36,7 @@ public class SummaryResultListener implements MutationResultListener {

private SummaryResult result = SummaryResult.EMPTY;
private final Dispatcher<SummaryResult> dispatcher;
private final CoverageDatabase coverage;
private final ReportCoverage coverage;

/**
* Creates a new listener that will compute a summary of the whole PIT analysis.
Expand All @@ -47,7 +46,7 @@ public class SummaryResultListener implements MutationResultListener {
* @param coverage
* The coverage computed from the tests.
*/
public SummaryResultListener(Dispatcher<SummaryResult> dispatcher, CoverageDatabase coverage) {
public SummaryResultListener(Dispatcher<SummaryResult> dispatcher, ReportCoverage coverage) {
this.dispatcher = dispatcher;
this.coverage = coverage;
}
Expand All @@ -59,12 +58,20 @@ public void runStart() {

@Override
public void handleMutationResult(ClassMutationResults results) {
List<ClassName> classUnderTest = Collections.singletonList(results.getMutatedClass());
int coveredLines = coverage.getNumberOfCoveredLines(classUnderTest);
for (ClassInfo info : coverage.getClassInfo(classUnderTest)) {
ClassSummary classSummary = ClassSummary.from(results, info, coveredLines);
result = result.update(classSummary);
}
List<ClassName> classesUnderTest = Collections.singletonList(results.getMutatedClass());

// long totalNumberOfCoveredLines = classesUnderTest.stream().map(coverage::getCoveredLines).flatMap(Collection::stream).count();

// int coveredLines = coverage.getNumberOfCoveredLines(classUnderTest);
for (ClassName classUnderTest : classesUnderTest) {
int numberOfCoveredLines = coverage.getCoveredLines(classUnderTest).size();
int numberOfLines = coverage.getCodeLinesForClass(classUnderTest).getNumberOfCodeLines();
ClassSummary classSummary = ClassSummary.from(results, numberOfLines, numberOfCoveredLines);
result = result.update(classSummary);
}
// for (ClassInfo info : coverage.getClassInfo(classesUnderTest)) {
// ClassSummary classSummary = ClassSummary.from(results, info, totalNumberOfCoveredLines);
// }
}

@Override
Expand Down
5 changes: 1 addition & 4 deletions bundles/org.pitest/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Pitest
Bundle-SymbolicName: org.pitest
Bundle-Version: 1.6.8.qualifier
Bundle-Version: 1.15.8.qualifier
Bundle-ClassPath: lib/pitest-command-line-javadoc.jar,
lib/pitest-command-line-sources.jar,
lib/pitest-command-line.jar,
Expand Down Expand Up @@ -34,7 +34,6 @@ Export-Package: joptsimple,
org.pitest.coverage.analysis,
org.pitest.coverage.execute,
org.pitest.coverage.export,
org.pitest.dependency,
org.pitest.extension.common,
org.pitest.functional,
org.pitest.functional.predicate,
Expand All @@ -60,7 +59,6 @@ Export-Package: joptsimple,
org.pitest.mutationtest.engine.gregor.config,
org.pitest.mutationtest.engine.gregor.mutators,
org.pitest.mutationtest.engine.gregor.mutators.experimental,
org.pitest.mutationtest.engine.gregor.mutators.rv,
org.pitest.mutationtest.execute,
org.pitest.mutationtest.filter,
org.pitest.mutationtest.incremental,
Expand Down Expand Up @@ -98,7 +96,6 @@ Export-Package: joptsimple,
org.pitest.testapi,
org.pitest.testapi.execute,
org.pitest.testapi.execute.containers,
org.pitest.testng,
org.pitest.util,
sun.pitest
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Expand Down
4 changes: 2 additions & 2 deletions bundles/org.pitest/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
</parent>

<artifactId>org.pitest</artifactId>
<version>1.6.8-SNAPSHOT</version>
<version>1.15.8-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<description>Wraps Pitest JAR as an Eclipse plug-in</description>

<properties>
<pitclipse-version>1.6.8</pitclipse-version>
<pitclipse-version>1.15.8</pitclipse-version>
</properties>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,68 +41,100 @@ private String getPitMutatorsAsString() {
}

private String getExpectedMutatorsAsString() {
return "INVERT_NEGS\n"
+ "RETURN_VALS\n"
+ "INLINE_CONSTS\n"
+ "MATH\n"
+ "VOID_METHOD_CALLS\n"
+ "NEGATE_CONDITIONALS\n"
+ "CONDITIONALS_BOUNDARY\n"
+ "INCREMENTS\n"
+ "REMOVE_INCREMENTS\n"
+ "NON_VOID_METHOD_CALLS\n"
+ "CONSTRUCTOR_CALLS\n"
+ "REMOVE_CONDITIONALS_EQ_IF\n"
+ "REMOVE_CONDITIONALS_EQ_ELSE\n"
+ "REMOVE_CONDITIONALS_ORD_IF\n"
+ "REMOVE_CONDITIONALS_ORD_ELSE\n"
+ "REMOVE_CONDITIONALS\n"
+ "TRUE_RETURNS\n"
+ "FALSE_RETURNS\n"
+ "PRIMITIVE_RETURNS\n"
+ "EMPTY_RETURNS\n"
+ "NULL_RETURNS\n"
+ "RETURNS\n"
+ "EXPERIMENTAL_MEMBER_VARIABLE\n"
+ "EXPERIMENTAL_SWITCH\n"
+ "EXPERIMENTAL_ARGUMENT_PROPAGATION\n"
+ "EXPERIMENTAL_NAKED_RECEIVER\n"
+ "EXPERIMENTAL_BIG_INTEGER\n"
+ "AOR_1\n"
+ "AOR_2\n"
+ "AOR_3\n"
+ "AOR_4\n"
+ "ABS\n"
+ "AOD1\n"
+ "AOD2\n"
+ "CRCR1\n"
+ "CRCR2\n"
+ "CRCR3\n"
+ "CRCR4\n"
+ "CRCR5\n"
+ "CRCR6\n"
+ "OBBN1\n"
+ "OBBN2\n"
+ "OBBN3\n"
+ "ROR1\n"
+ "ROR2\n"
+ "ROR3\n"
+ "ROR4\n"
+ "ROR5\n"
+ "UOI1\n"
+ "UOI2\n"
+ "UOI3\n"
+ "UOI4\n"
+ "REMOVE_SWITCH\n"
+ "OLD_DEFAULTS\n"
+ "STRONGER\n"
+ "ALL\n"
+ "DEFAULTS\n"
+ "AOR\n"
+ "AOD\n"
+ "CRCR\n"
+ "OBBN\n"
+ "ROR\n"
+ "UOI\n";
return "REMOVE_CONDITIONALS_ORDER_IF\n" +
"REMOVE_CONDITIONALS\n" +
"REMOVE_CONDITIONALS_EQUAL_IF\n" +
"TRUE_RETURNS\n" +
"REMOVE_CONDITIONALS_EQUAL_ELSE\n" +
"VOID_METHOD_CALLS\n" +
"PRIMITIVE_RETURNS\n" +
"FALSE_RETURNS\n" +
"NON_VOID_METHOD_CALLS\n" +
"INVERT_NEGS\n" +
"CONDITIONALS_BOUNDARY\n" +
"REMOVE_CONDITIONALS_ORDER_ELSE\n" +
"DEFAULTS\n" +
"EXPERIMENTAL_SWITCH\n" +
"RETURNS\n" +
"EXPERIMENTAL_MEMBER_VARIABLE\n" +
"NULL_RETURNS\n" +
"EXPERIMENTAL_BIG_DECIMAL\n" +
"MATH\n" +
"EXPERIMENTAL_BIG_INTEGER\n" +
"INCREMENTS\n" +
"EXPERIMENTAL_ARGUMENT_PROPAGATION\n" +
"EXPERIMENTAL_NAKED_RECEIVER\n" +
"CONSTRUCTOR_CALLS\n" +
"REMOVE_SWITCH\n" +
"INLINE_CONSTS\n" +
"STRONGER\n" +
"REMOVE_INCREMENTS\n" +
"NEGATE_CONDITIONALS\n" +
"EMPTY_RETURNS\n";


// return "INVERT_NEGS\n"
// + "RETURN_VALS\n"
// + "INLINE_CONSTS\n"
// + "MATH\n"
// + "VOID_METHOD_CALLS\n"
// + "NEGATE_CONDITIONALS\n"
// + "CONDITIONALS_BOUNDARY\n"
// + "INCREMENTS\n"
// + "REMOVE_INCREMENTS\n"
// + "NON_VOID_METHOD_CALLS\n"
// + "CONSTRUCTOR_CALLS\n"
// + "REMOVE_CONDITIONALS_EQ_IF\n"
// + "REMOVE_CONDITIONALS_EQ_ELSE\n"
// + "REMOVE_CONDITIONALS_ORD_IF\n"
// + "REMOVE_CONDITIONALS_ORD_ELSE\n"
// + "REMOVE_CONDITIONALS\n"
// + "TRUE_RETURNS\n"
// + "FALSE_RETURNS\n"
// + "PRIMITIVE_RETURNS\n"
// + "EMPTY_RETURNS\n"
// + "NULL_RETURNS\n"
// + "RETURNS\n"
// + "EXPERIMENTAL_MEMBER_VARIABLE\n"
// + "EXPERIMENTAL_SWITCH\n"
// + "EXPERIMENTAL_ARGUMENT_PROPAGATION\n"
// + "EXPERIMENTAL_NAKED_RECEIVER\n"
// + "EXPERIMENTAL_BIG_INTEGER\n"
// + "AOR_1\n"
// + "AOR_2\n"
// + "AOR_3\n"
// + "AOR_4\n"
// + "ABS\n"
// + "AOD1\n"
// + "AOD2\n"
// + "CRCR1\n"
// + "CRCR2\n"
// + "CRCR3\n"
// + "CRCR4\n"
// + "CRCR5\n"
// + "CRCR6\n"
// + "OBBN1\n"
// + "OBBN2\n"
// + "OBBN3\n"
// + "ROR1\n"
// + "ROR2\n"
// + "ROR3\n"
// + "ROR4\n"
// + "ROR5\n"
// + "UOI1\n"
// + "UOI2\n"
// + "UOI3\n"
// + "UOI4\n"
// + "REMOVE_SWITCH\n"
// + "OLD_DEFAULTS\n"
// + "STRONGER\n"
// + "ALL\n"
// + "DEFAULTS\n"
// + "AOR\n"
// + "AOD\n"
// + "CRCR\n"
// + "OBBN\n"
// + "ROR\n"
// + "UOI\n";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.pitest.mutationtest.MutationResult;
import org.pitest.mutationtest.MutationStatusTestPair;
import org.pitest.mutationtest.engine.Location;
import org.pitest.mutationtest.engine.MethodName;
import org.pitest.mutationtest.engine.MutationDetails;
import org.pitest.mutationtest.engine.MutationIdentifier;
import org.pitest.pitclipse.example.Foo;
Expand All @@ -48,7 +47,7 @@ class ListenerTestFixture {
private static final ObjectFactory JAXB_OBJECT_FACTORY = new ObjectFactory();

public static ClassMutationResults aClassMutationResult() {
Location location = new Location(ClassName.fromClass(Foo.class), MethodName.fromString("doFoo"), "doFoo");
Location location = new Location(ClassName.fromClass(Foo.class), "doFoo", "doFoo");
MutationIdentifier id = new MutationIdentifier(location, 1, "SomeMutator");
MutationDetails md = new MutationDetails(id, "org/pitest/pitclipse/example/Foo.java", TEST_FACTORY.aString(),
20, TEST_FACTORY.aRandomInt());
Expand Down
Loading

0 comments on commit dafd5b2

Please sign in to comment.