Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mutator configuration #152

Merged
merged 62 commits into from
Aug 21, 2021
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
66092ea
Improve current PIT launch tab
echebbi Mar 5, 2020
077377b
draft 'Mutators' page
echebbi Mar 5, 2020
47cbbae
Rename PitMutators as MutatorGroups
echebbi Mar 6, 2020
cc74e3b
Allow to disable checkstyle rules with SuppressWarnings annotation
echebbi Mar 6, 2020
c44b7f9
Create Mutators enum
echebbi Mar 6, 2020
1a23396
the table shows the mutators
echebbi Mar 11, 2020
b39f16c
[WIP] Show the description of mutators
echebbi Jun 23, 2020
d5a6a9c
Fixed failing tests
Jul 20, 2021
0d7daee
Added old defaults to groups
Jul 21, 2021
936377e
Working mutations tab
Jul 21, 2021
f687a7f
Unified Strings of preference page
Jul 21, 2021
87a67a3
First working prototype for a mutator tab
Jul 22, 2021
b1dfae3
Updated the defaults to match with pitest.org
Jul 22, 2021
4d98c71
Cosmetic changes
Jul 22, 2021
2e6e62c
Merge branch 'master' into Mutator_configuration
JKutscha Jul 22, 2021
08a7474
Show error message, if no mutator is selected
Jul 22, 2021
ec77a0c
Merge branch 'master' into Mutator_configuration
JKutscha Jul 22, 2021
0e1fc3a
Added options test for old defaults
Jul 23, 2021
8c5b21f
Merge branch 'Mutator_configuration' of github.com:JKutscha/pitclipse…
Jul 23, 2021
e20d11d
Merge branch 'master' into Mutator_configuration
JKutscha Jul 24, 2021
ca0e8b4
First tests for mutations tab in launch config
Jul 26, 2021
651cda4
Removed unused LambdaLabelProvider
Jul 26, 2021
376d200
Merge branch 'Mutator_configuration' of github.com:JKutscha/pitclipse…
Jul 26, 2021
bac44f5
Sevaral fixes after code review for mutator tab
JKutscha Jul 26, 2021
0ed7dec
Delete test run config after class
JKutscha Jul 26, 2021
2b81853
Merge branch 'master' into Mutator_configuration
JKutscha Jul 26, 2021
4872593
Clean console after tests in MutationTabTest
JKutscha Jul 27, 2021
ae49ecc
Merge branch 'master' into Mutator_configuration
JKutscha Jul 27, 2021
b05572d
Use now implemented PIT API to get mutator ids
JKutscha Jul 27, 2021
436bcf9
Dispose SWT widgets properly for the mutants tab
JKutscha Jul 29, 2021
5ee9205
Merge branch 'master' into Mutator_configuration
JKutscha Aug 3, 2021
5992576
Update existing tests to use resturctured tests and fixes
JKutscha Aug 3, 2021
74d46b9
Reworked selection mechanism for tests
JKutscha Aug 4, 2021
6095bd3
Added missing import
JKutscha Aug 4, 2021
6fc64e8
Merge remote-tracking branch 'origin/master' into Mutator_configuration
Aug 4, 2021
e608884
Added image registry for icons
Aug 4, 2021
891acc7
Added all missing mutatot descriptions
JKutscha Aug 4, 2021
39af722
Merge branch 'Mutator_configuration' of github.com:JKutscha/pitclipse…
JKutscha Aug 4, 2021
1a9e20b
Added deletted launch config back
Aug 5, 2021
ad26cff
Merge branch 'Mutator_configuration' of github.com:JKutscha/pitclipse…
Aug 5, 2021
1bde0fd
Added // NOSONAR and added check for mutator changes
Aug 5, 2021
8978c28
Added test class for pit api and not use other class
JKutscha Aug 5, 2021
d3227e4
Fine tuned conditions and reached coverage goal
JKutscha Aug 5, 2021
25c6715
Use correct dependency for Mutator class
JKutscha Aug 5, 2021
e971a00
Removed whitespaces and small fixes
JKutscha Aug 5, 2021
9cf7454
Change mutators from ImmutableList to String
JKutscha Aug 5, 2021
9430da3
Use safley dispose for composite in mutators tab
JKutscha Aug 5, 2021
6af8093
code review fixes for comments by lorenzoBettini
JKutscha Aug 5, 2021
d3d9991
Fix problems regarding Stream.of()
JKutscha Aug 5, 2021
1745a16
Revert input organisation
Aug 6, 2021
13e8e9e
slightly changed API test
LorenzoBettini Aug 6, 2021
3f985d6
Removed worng comment
Aug 6, 2021
1d0aa89
Constants name change and trim mutators before equals
JKutscha Aug 7, 2021
ba059e8
Added comment for custom radip button data
JKutscha Aug 7, 2021
7f3ea06
Use mutator group and individual mutators across the board
JKutscha Aug 7, 2021
06aa5d8
getDefaultMutatorGroup and setDefaultMutatorGroup for consistency
JKutscha Aug 7, 2021
bd60277
Moved the image registery to own activator class
JKutscha Aug 7, 2021
615e3f9
Remove icons folder from build of core
JKutscha Aug 7, 2021
a2011bc
Merge branch 'master' into Mutator_configuration
JKutscha Aug 9, 2021
2002c64
try to make UI tests less flaky in KDE
LorenzoBettini Aug 9, 2021
5e961cb
Created link selection adapter to exclude from code coverage
Aug 10, 2021
3002ac3
Removed cast to String, but was not needed
Aug 10, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/*******************************************************************************
* Copyright 2012-2021 Phil Glover and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy
* of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
******************************************************************************/

package org.pitest.pitclipse.core;

import java.util.ArrayList;

import org.pitest.mutationtest.engine.gregor.config.Mutator;
JKutscha marked this conversation as resolved.
Show resolved Hide resolved

/**
* Enum which holds information about the mutators of pit.<br>
* The name of new values <b>must</b> be the exact String, which is used by PIT
* in the class {@link Mutator}.
*/
@SuppressWarnings("checkstyle:LineLength")
public enum Mutators {
OLD_DEFAULTS("Old defaults", "&Old default Mutators"),
DEFAULTS("Defaults", "&Default Mutators"),
STRONGER("Stronger defaults", "&Stronger Mutators"),
ALL("All", "&All Mutators"),
CONDITIONALS_BOUNDARY("Conditionals Boundary", "Replaces the relational operators <, <=, >, >=", true),
INCREMENTS("Increments", "Mutates increments, decrements and assignment increments and decrements of local variables (stack variables). Replaces increments with decrements and vice versa", true),
INVERT_NEGS("Invert Negatives", "Inverts negation of integer and floating point numbers", true),
MATH("Math", "Replaces binary arithmetic operations for either integer or floating-point arithmetic with another operation", true),
NEGATE_CONDITIONALS("Negate Conditionals", "Mutates all conditionals found", true),
RETURN_VALS("Return Values", "Mutates the return values of method calls. Depending on the return type of the method another mutation is used"),
VOID_METHOD_CALLS("Void Method Call", "Removes method calls to void methods", true),
CONSTRUCTOR_CALLS("Constructor Call", "Replaces constructor calls with null values"),
EMPTY_RETURNS("Empty Returns", "Replaces return values with an 'empty' value", true),
FALSE_RETURNS("False Returns", "Replaces primitive and boxed boolean return values with false", true),
TRUE_RETURNS("True Returns", "Replaces primitive and boxed boolean return values with true", true),
INLINE_CONSTS("Inline Constant", "Mutates inline constants. An inline constant is a literal value assigned to a non-final variable"),
NULL_RETURNS("Null Returns", "Replaces return values with null. Method that can be mutated by the EMPTY_RETURNS mutator or that are directly annotated with NotNull are not mutated", true),
NON_VOID_METHOD_CALLS("Non Void Method Call", "Removes method calls to non void methods. Their return value is replaced by the Java Default Value for that specific type"),
PRIMITIVE_RETURNS("Primite Returns", "Replaces int, short, long, char, float and double return values with 0", true),
REMOVE_CONDITIONALS("Remove Conditionals", "Removes all conditionals statements such that the guarded statements always execute"),
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_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"),
ABS("Negation", "Replaces any use of a numeric variable (local variable, field, array cell) with its negation"),
AOR("Arithmetic Operator Replacement", "Like the Math mutator, replaces binary arithmetic operations for either integer or floating-point arithmetic with another operation"),
AOD("Arithmetic Operator Deletion", "Replaces an arithmetic operation with one of its members"),
CRCR("Constant Replacement", "Like the Inline Constant mutator, mutates inline constant"),
OBBN("Bitwise Operator", "Mutates bitwise and (&) and or (|)"),
ROR("Relational Operator Replacement", "Replaces a relational operator with another one"),
UOI("Unary Operator Insertion", "Inserts a unary operator (increment or decrement) to a variable call. Affects local variables, array variables, fields and parameters");

/**
* Descriptor which is used to display the name of this mutator in a table
*/
private final String descriptor;
/**
* Description of this mutator
*/
private final String description;
/**
* true, if this mutator is contained in the DEFAULTS group of PIT
*/
private final boolean activeByDefault;

private Mutators(String descriptor, String description) {
this(descriptor, description, false);
}

private Mutators(String descriptor, String description, boolean activeByDefault) {
this.descriptor = descriptor;
this.description = description;
this.activeByDefault = activeByDefault;
}

public String getDescriptor() {
return descriptor;
}

public String getDescription() {
return description;
}

public boolean isActiveByDefault() {
return activeByDefault;
}

public static ArrayList<Mutators> getMainGroup() {
final ArrayList<Mutators> mainGroup = new ArrayList<Mutators>();
mainGroup.add(DEFAULTS);
mainGroup.add(STRONGER);
mainGroup.add(ALL);
mainGroup.add(OLD_DEFAULTS);
return mainGroup;
}

public static ArrayList<String> getDefaultMutators() {
ArrayList<String> defaultMutators = new ArrayList<String>();
for (Mutators m : values()) {
if (m.isActiveByDefault()) {
defaultMutators.add(m.name());
}
}
return defaultMutators;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
package org.pitest.pitclipse.core;

import static org.eclipse.core.runtime.FileLocator.getBundleFile;
import static org.pitest.pitclipse.core.preferences.PitPreferences.AVOID_CALLS_TO;
import static org.pitest.pitclipse.core.preferences.PitPreferences.AVOID_CALLS;
import static org.pitest.pitclipse.core.preferences.PitPreferences.EXCLUDED_CLASSES;
import static org.pitest.pitclipse.core.preferences.PitPreferences.EXCLUDED_METHODS;
import static org.pitest.pitclipse.core.preferences.PitPreferences.EXCLUDE_METHODS;
import static org.pitest.pitclipse.core.preferences.PitPreferences.INCREMENTAL_ANALYSIS;
import static org.pitest.pitclipse.core.preferences.PitPreferences.PIT_EXECUTION_MODE;
import static org.pitest.pitclipse.core.preferences.PitPreferences.PIT_MUTATORS;
import static org.pitest.pitclipse.core.preferences.PitPreferences.EXECUTION_SCOPE;
import static org.pitest.pitclipse.core.preferences.PitPreferences.MUTATORS;
import static org.pitest.pitclipse.core.preferences.PitPreferences.RUN_IN_PARALLEL;
import static org.pitest.pitclipse.core.preferences.PitPreferences.TIMEOUT;
import static org.pitest.pitclipse.core.preferences.PitPreferences.TIMEOUT_FACTOR;
Expand Down Expand Up @@ -267,13 +267,13 @@ public File getHistoryFile() {

public PitConfiguration getConfiguration() {
IPreferenceStore preferenceStore = getPreferenceStore();
String executionMode = preferenceStore.getString(PIT_EXECUTION_MODE);
String mutators = preferenceStore.getString(PIT_MUTATORS);
String executionMode = preferenceStore.getString(EXECUTION_SCOPE);
String mutators = preferenceStore.getString(MUTATORS);
boolean parallelRun = preferenceStore.getBoolean(RUN_IN_PARALLEL);
boolean incrementalAnalysis = preferenceStore.getBoolean(INCREMENTAL_ANALYSIS);
String excludedClasses = preferenceStore.getString(EXCLUDED_CLASSES);
String excludedMethods = preferenceStore.getString(EXCLUDED_METHODS);
String avoidCallsTo = preferenceStore.getString(AVOID_CALLS_TO);
String excludedMethods = preferenceStore.getString(EXCLUDE_METHODS);
String avoidCallsTo = preferenceStore.getString(AVOID_CALLS);
String timeout = preferenceStore.getString(TIMEOUT);
String timeoutFactor = preferenceStore.getString(TIMEOUT_FACTOR);
PitConfiguration.Builder builder = PitConfiguration.builder().withParallelExecution(parallelRun)
Expand All @@ -292,8 +292,8 @@ public PitConfiguration getConfiguration() {
break;
}
}
for (PitMutators mutatorMode : PitMutators.values()) {
if (mutatorMode.getId().equals(mutators)) {
for (Mutators mutatorMode : Mutators.values()) {
if (mutatorMode.name().equals(mutators)) {
builder.withMutators(mutatorMode.toString());
break;
}
Expand All @@ -302,10 +302,14 @@ public PitConfiguration getConfiguration() {
}

public void setExecutionMode(PitExecutionMode pitExecutionMode) {
getPreferenceStore().setValue(PIT_EXECUTION_MODE, pitExecutionMode.getId());
getPreferenceStore().setValue(EXECUTION_SCOPE, pitExecutionMode.getId());
}

public void setMutators(PitMutators mutators) {
getPreferenceStore().setValue(PIT_MUTATORS, mutators.getId());
public void setMutators(Mutators mutators) {
getPreferenceStore().setValue(MUTATORS, mutators.name());
}

public String getDefaultMutators() {
echebbi marked this conversation as resolved.
Show resolved Hide resolved
return getPreferenceStore().getString(MUTATORS);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,39 @@
* Constants used to deal with Pitclipse's preferences.
*/
public final class PitPreferences {
public static final String MUTATORS_LABEL = "Mutators";
public static final String MUTATORS = "pitMutators";

public static final String INDIVIDUAL_MUTATORS = "pitIndividualMutators";

public static final String PIT_MUTATORS = "pitMutators";

public static final String USE_INCREMENTAL_ANALYSIS = "Use &incremental analysis";
public static final String EXCLUDE_CLASSES_FROM_PIT = "E&xcluded classes (e.g.*IntTest)";
public static final String MUTATION_TESTS_RUN_IN_PARALLEL = "Mutation tests run in para&llel";
public static final String EXCLUDE_METHODS_FROM_PIT = "Excluded &methods (e.g.*toString*)";
public static final String AVOID_CALLS_FROM_PIT = "&Avoid calls to";
public static final String PIT_TIMEOUT = "Pit Ti&meout";
public static final String PIT_TIMEOUT_FACTOR = "Timeout &Factor";
public static final String EXCLUDED_METHODS = "excludedMethods";
public static final String AVOID_CALLS_TO = "avoidCallsTo";
public static final String EXCLUDED_CLASSES = "excludedClasses";
public static final String INCREMENTAL_ANALYSIS_LABEL = "Use &incremental analysis";
public static final String INCREMENTAL_ANALYSIS = "incrementalAnalysis";
public static final String PIT_EXECUTION_MODE = "pitExecutionMode";

public static final String EXCLUDE_CLASSES_LABEL = "E&xcluded classes (e.g.*IntTest)";
public static final String EXCLUDED_CLASSES = "excludedClasses";

public static final String RUN_IN_PARALLEL_LABEL = "Mutation tests run in para&llel";
public static final String RUN_IN_PARALLEL = "runInParallel";

public static final String EXCLUDE_METHODS_LABEL = "Excluded &methods (e.g.*toString*)";
public static final String EXCLUDE_METHODS = "excludedMethods";

public static final String AVOID_CALLS_LABEL = "&Avoid calls to";
public static final String AVOID_CALLS = "avoidCallsTo";
JKutscha marked this conversation as resolved.
Show resolved Hide resolved

public static final String TIMEOUT_LABEL = "Pit Ti&meout";
public static final String TIMEOUT = "pitTimeout";

public static final String TIMEOUT_FACTOR_LABEL = "Timeout &Factor";
public static final String TIMEOUT_FACTOR = "pitTimeoutFactor";


public static final String EXECUTION_SCOPE_LABEL = "Pit execution scope";
public static final String EXECUTION_SCOPE = "pitExecutionMode";
JKutscha marked this conversation as resolved.
Show resolved Hide resolved

public static final String PREFERENCE_DESCRIPTION_LABEL = "Pitclipse Preferences";
public static final String MUTATORS_DESCRIPTION_LABEL = "Mutator Preferences";

JKutscha marked this conversation as resolved.
Show resolved Hide resolved
private PitPreferences() {
// utility class should not be instantiated
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
import org.pitest.pitclipse.core.PitCoreActivator;
import org.pitest.pitclipse.runner.config.PitConfiguration;

import static org.pitest.pitclipse.core.preferences.PitPreferences.AVOID_CALLS_TO;
import static org.pitest.pitclipse.core.preferences.PitPreferences.AVOID_CALLS;
import static org.pitest.pitclipse.core.preferences.PitPreferences.EXCLUDED_CLASSES;
import static org.pitest.pitclipse.core.preferences.PitPreferences.INCREMENTAL_ANALYSIS;
import static org.pitest.pitclipse.core.preferences.PitPreferences.PIT_EXECUTION_MODE;
import static org.pitest.pitclipse.core.preferences.PitPreferences.EXECUTION_SCOPE;
import static org.pitest.pitclipse.core.preferences.PitPreferences.RUN_IN_PARALLEL;
import static org.pitest.pitclipse.core.preferences.PitPreferences.TIMEOUT;
import static org.pitest.pitclipse.core.preferences.PitPreferences.TIMEOUT_FACTOR;
Expand All @@ -47,10 +47,10 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer {
@Override
public void initializeDefaultPreferences() {
IPreferenceStore store = PitCoreActivator.getDefault().getPreferenceStore();
store.setDefault(PIT_EXECUTION_MODE, "containingProject");
store.setDefault(EXECUTION_SCOPE, "containingProject");
store.setDefault(RUN_IN_PARALLEL, true);
store.setDefault(INCREMENTAL_ANALYSIS, false);
store.setDefault(AVOID_CALLS_TO, DEFAULT_AVOID_CALLS_TO_LIST);
store.setDefault(AVOID_CALLS, DEFAULT_AVOID_CALLS_TO_LIST);
store.setDefault(DEFAULT_MUTATORS, "defaultMutators");
store.setDefault(TIMEOUT, DEFAULT_TIMEOUT);
store.setDefault(TIMEOUT_FACTOR, DEFAULT_TIMEOUT_FACTOR.toString());
Expand Down
3 changes: 2 additions & 1 deletion bundles/org.pitest.pitclipse.launch.ui/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.11.1,4.0.0)",
org.pitest.pitclipse.launch,
org.eclipse.jface;bundle-version="[3.11.1,4.0.0)",
org.eclipse.ui.workbench;bundle-version="[3.107.1,4.0.0)",
org.eclipse.jdt.debug.ui;bundle-version="[3.7.101,4.0.0)"
org.eclipse.jdt.debug.ui;bundle-version="[3.7.101,4.0.0)",
org.pitest;bundle-version="1.6.7"
JKutscha marked this conversation as resolved.
Show resolved Hide resolved
JKutscha marked this conversation as resolved.
Show resolved Hide resolved
Import-Package: com.google.common.collect;version="21.0.0"
Export-Package: org.pitest.pitclipse.launch.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package org.pitest.pitclipse.launch.ui;

import org.eclipse.jface.viewers.ColumnLabelProvider;

import java.util.function.Function;

class LambdaLabelProvider<T> extends ColumnLabelProvider {

private final Function<T, String> labelProvider;

public LambdaLabelProvider(Function<T, String> labelProvider) {
super();
this.labelProvider = labelProvider;
}

@Override
@SuppressWarnings("unchecked")
public String getText(Object element) {
try {
return labelProvider.apply((T) element);
}
catch (ClassCastException e) {
return "";
}
}

}
Loading