Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
echebbi committed Apr 1, 2024
1 parent f579dd5 commit d6d0ba2
Show file tree
Hide file tree
Showing 14 changed files with 57 additions and 219 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ public enum Mutators {
REMOVE_INCREMENTS("Remove Increments", "Removes local variable increments"),
EXPERIMENTAL_ARGUMENT_PROPAGATION("Experimentation Argument Propagation", "Replaces method call with one of its parameters of matching type"),
EXPERIMENTAL_BIG_INTEGER("Experimental Big Integer", "Swaps big integer methods"),
EXPERIMENTAL_BIG_DECIMAL("Experimental Big Integer", "Swaps big decimal methods"),
EXPERIMENTAL_BIG_DECIMAL("Experimental Big Decimal", "Swaps big decimal methods"),
EXPERIMENTAL_NAKED_RECEIVER("Experimental Naked Receiver", "Replaces method call with a naked receiver"),
EXPERIMENTAL_MEMBER_VARIABLE("Experimental Member Variable", "Removes assignments to member variables. Can even remove assignments to final members. The members will be initialized with their Java Default Value"),
EXPERIMENTAL_SWITCH("Experimental Switch", "Finds the first label within a switch statement that differs from the default label. Mutates the switch statement by replacing the default label (wherever it is used) with this label. All the other labels are replaced by the default one"),
REMOVE_SWITCH("Remove Switch","Finds the first switch label that differs from the default label, then replaces the default label with this label, and all other labels are replaced with the default one");
REMOVE_SWITCH("Remove Switch", "Finds the first switch label that differs from the default label, then replaces the default label with this label, and all other labels are replaced with the default one");

/**
* Descriptor which is used to display the name of this mutator in a table
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
import java.util.Collection;
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 Down Expand Up @@ -50,7 +48,6 @@ public static ClassSummary from(ClassMutationResults results, int numberOfCodeLi
int survivedMutations = (int) mutations.stream()
.filter(m -> !m.getStatus().isDetected())
.count();
CoverageData data;
Coverage lineCoverage = Coverage.from(linesCovered, numberOfCodeLines);
Coverage mutationCoverage = Coverage.from(totalMutations - survivedMutations, totalMutations);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,12 @@ public void runStart() {
public void handleMutationResult(ClassMutationResults results) {
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
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-junit5-plugin
Bundle-SymbolicName: org.pitest.pitest-junit5-plugin
Bundle-Version: 1.2.1
Bundle-Version: 1.2.1.qualifier
Bundle-ClassPath: lib/pitest-junit5-plugin-sources.jar,
lib/pitest-junit5-plugin-javadoc.jar,
lib/pitest-junit5-plugin.jar,
Expand Down
2 changes: 1 addition & 1 deletion bundles/org.pitest.pitest-junit5-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</parent>

<artifactId>org.pitest.pitest-junit5-plugin</artifactId>
<version>1.2.1</version>
<version>1.2.1-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<description>Wraps Pitest JUnit 5 Plugin's JAR as an Eclipse plug-in</description>

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

private String getExpectedMutatorsAsString() {
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";
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";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.stream.IntStream;
import java.util.stream.Stream;

import org.pitest.classinfo.ClassName;
Expand Down Expand Up @@ -127,9 +128,9 @@ public ClassLines getCodeLinesForClass(ClassName clazz) {

@Override
public Set<ClassLine> getCoveredLines(ClassName clazz) {
Set<ClassLine> lines = new HashSet<>();
int expectedNbOfLinesCovered = classCoverage.getOrDefault(clazz, -1);

Set<ClassLine> lines = new HashSet<>();
for (int i = 0; i < expectedNbOfLinesCovered; ++i) {
lines.add(new ClassLine(clazz, i));
}
Expand All @@ -141,24 +142,6 @@ public Collection<TestInfo> getTestsForBlockLocation(BlockLocation location) {
throw new UnsupportedOperationException("the stub does not implement getTestsForBlockLocation");
}

// @Override
// public Collection<ClassInfo> getClassInfo(Collection<ClassName> classes) {
// return filter(transform(classes, classInfoLookup()), notNull());
// }
//
// @Override
// public int getNumberOfCoveredLines(Collection<ClassName> classes) {
// int total = 0;
// for (ClassName className : classes) {
// total += coverageFor(className);
// }
// return total;
// }

// private int coverageFor(ClassName className) {
// return classCoverage.getOrDefault(className, 0);
// }

@Override
public Collection<TestInfo> getTestsForClass(ClassName clazz) {
return ImmutableList.of();
Expand All @@ -174,14 +157,5 @@ public Collection<ClassLines> getClassesForFile(String sourceFile, String packag
return ImmutableList.of();
}

// private Function<ClassName, ClassInfo> classInfoLookup() {
// return new Function<ClassName, ClassInfo>() {
// @Override
// public ClassInfo apply(ClassName input) {
// return classInfo.get(input);
// }
// };
// }

}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,6 @@ public SWTBotView getView() {
SWTBotView mutationsView = bot.viewByTitle("PIT Mutations");
mutationsView.show();
mutationsView.setFocus();
//
// Make sure the 'PIT Mutations' view is opened
//
bot.waitUntil(new ViewOpenedCondition(bot, "PIT Mutations"));
return mutationsView;
}

Expand Down Expand Up @@ -158,13 +154,13 @@ private MutationsTree(ImmutableList<StatusTree> statuses) {
this.statuses = statuses;
}

public boolean select(PitMutation mutation) {
public void select(PitMutation mutation) {
String status = mutation.getStatus().toString();
for (StatusTree statusTree : statuses) {
if (status.equals(statusTree.statusName)) {
if (statusTree.select(mutation)) {
return true;
}
statusTree.select(mutation);
return;

}
}
throw new AssertionFailedError(
Expand All @@ -189,12 +185,14 @@ private StatusTree(String statusName, ImmutableList<ProjectTree> projects) {
this.projects = projects;
}

public boolean select(PitMutation mutation) {
/**
* @return
*/
public void select(PitMutation mutation) {
for (ProjectTree projectTree : projects) {
if (mutation.getProject().equals(projectTree.projectName)) {
if (projectTree.select(mutation)) {
return true;
}
projectTree.select(mutation);
return;
}
}
throw new AssertionFailedError(
Expand All @@ -221,12 +219,11 @@ private ProjectTree(String projectName, ImmutableList<PackageTree> packages) {
this.packages = packages;
}

public boolean select(PitMutation mutation) {
public void select(PitMutation mutation) {
for (PackageTree packageTree : packages) {
if (mutation.getPkg().equals(packageTree.packageName)) {
if (packageTree.select(mutation)) {
return true;
}
packageTree.select(mutation);
return;
}
}
throw new AssertionFailedError(
Expand All @@ -253,12 +250,11 @@ private PackageTree(String packageName, ImmutableList<ClassTree> classes) {
this.classes = classes;
}

public boolean select(PitMutation mutation) {
public void select(PitMutation mutation) {
for (ClassTree classTree : classes) {
if (mutation.getClassName().equals(classTree.className)) {
if (classTree.select(mutation)) {
return true;
}
classTree.select(mutation);
return;
}
}
throw new AssertionFailedError(
Expand All @@ -285,12 +281,15 @@ private ClassTree(String className, ImmutableList<MutationTree> projects) {
this.mutations = projects;
}

public boolean select(PitMutation mutation) {
/**
* @return
*/
public void select(PitMutation mutation) {
for (MutationTree mutationTree : mutations) {
if (mutation.getLineNumber() == mutationTree.lineNumber &&
mutation.getMutation().equals(mutationTree.mutation)) {
mutationTree.select();
return true;
return;
}
}
throw new AssertionFailedError(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ private void activateConfigurationTab(String configurationName, String name) {
}

public void createRunConfiguration(String configurationName, String projectName, String className) {
System.out.println("RunConfigurationSelector.createRunConfiguration()");
getPitConfigurationItem().contextMenu("New Configuration").click();
bot.textWithLabel("Name:").setText(configurationName);
PitRunConfiguration config = new Builder().withName(configurationName).withProjects(projectName)
Expand Down
Loading

0 comments on commit d6d0ba2

Please sign in to comment.