Skip to content

Commit

Permalink
refactor: the example is now done as a normal configuration to avoid …
Browse files Browse the repository at this point in the history
…redundant code
  • Loading branch information
danglotb committed May 28, 2019
1 parent e05ea09 commit cc4efca
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 28 deletions.
3 changes: 0 additions & 3 deletions dspot-maven/src/main/java/eu/stamp_project/DSpotMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -317,9 +317,6 @@ public void execute() {
} catch (Exception e) {
throw new RuntimeException(e);
}
// global report handling
Main.GLOBAL_REPORT.output();
Main.GLOBAL_REPORT.reset();
}

// visible for testing...
Expand Down
22 changes: 2 additions & 20 deletions dspot/src/main/java/eu/stamp_project/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,8 @@ public static void main(String[] args) {
} catch (Exception ignored) {

}
final boolean shouldRunExample = JSAPOptions.parse(args);
if (shouldRunExample) {
Main.runExample();
} else {
run();
}
JSAPOptions.parse(args);
run();x
// global report handling
Main.GLOBAL_REPORT.output();
Main.GLOBAL_REPORT.reset();
Expand Down Expand Up @@ -83,18 +79,4 @@ public static void createOutputDirectories() {
}
}

static void runExample() {
try {
InputConfiguration.get().initialize("src/test/resources/test-projects/test-projects.properties");
DSpot dSpot = new DSpot(1,
Collections.singletonList(new TestDataMutator()),
new JacocoCoverageSelector(),
BudgetizerEnum.RandomBudgetizer
);
dSpot.amplifyTestClassesTestMethods(Collections.singletonList("example.TestSuiteExample"), Collections.emptyList());
} catch (Exception e) {
throw new RuntimeException(e);
}
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package eu.stamp_project.utils.options;

import eu.stamp_project.dspot.amplifier.TestDataMutator;
import eu.stamp_project.dspot.selector.JacocoCoverageSelector;
import eu.stamp_project.dspot.selector.PitMutantScoreSelector;
import eu.stamp_project.dspot.selector.TestSelector;
import eu.stamp_project.utils.options.check.Checker;
Expand All @@ -9,6 +11,7 @@

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
import java.util.Properties;

Expand All @@ -21,6 +24,21 @@ public class Configuration {

private static final Logger LOGGER = LoggerFactory.getLogger(Configuration.class);

static void configureExample() {
try {

InputConfiguration.get().initialize("src/test/resources/test-projects/test-projects.properties");
InputConfiguration.get().setNbIteration(1);
InputConfiguration.get().setAmplifiers(Collections.singletonList(new TestDataMutator()));
InputConfiguration.get().setSelector(new JacocoCoverageSelector());
InputConfiguration.get().setBudgetizer(BudgetizerEnum.RandomBudgetizer);
InputConfiguration.get().setTestClasses(Collections.singletonList("example.TestSuiteExample"));
InputConfiguration.get().setTestClasses(Collections.emptyList());
} catch (Exception e) {
throw new RuntimeException(e);
}
}

public static void configure(final String pathToPropertiesFile,
final List<String> amplifiers,
final String selector,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,9 @@ public class JSAPOptions {
* parse the command line argument
*
* @param args command line arguments. Refer to the README on the github page or use --help command line option to display all the accepted arguments.
* @return true if --example is pass through the command line. It will run DSpot with a small example to make a demonstration of the usage of DSpot.
* Otherwise, it returns false and DSpot will run normally, using the properties and the command line options.
*/
public static boolean parse(String[] args) {
public static void parse(String[] args) {
JSAPResult jsapConfig = options.parse(args);
if (!jsapConfig.success() || jsapConfig.getBoolean("help")) {
System.err.println();
Expand All @@ -48,7 +47,8 @@ public static boolean parse(String[] args) {
}
showUsage();
} else if (jsapConfig.getBoolean("example")) {
return true;
Configuration.configureExample();
return;
}

// getting first all the values of the command line.
Expand Down Expand Up @@ -109,8 +109,6 @@ public static boolean parse(String[] args) {
testClasses,
testCases
);

return false;
}

private static String helpForEnums(Class<?> enumClass) {
Expand Down

0 comments on commit cc4efca

Please sign in to comment.