Skip to content

Commit

Permalink
refactor: have the choice to run the enhanced mode or not
Browse files Browse the repository at this point in the history
  • Loading branch information
danglotb committed Dec 21, 2020
1 parent ba21a7b commit 659f9b1
Showing 1 changed file with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,29 @@ public static void main(String[] args) {
}

public static void run(Configuration configuration) {
final Map<String, Set<String>> selectedTests;
if (configuration.enhanced) {
LOGGER.info("Running in enhanced mode...");
selectedTests = enhancedRun(configuration);
} else {
LOGGER.info("Running...");
selectedTests = _run(configuration);
}
output(configuration, new Coverage(), selectedTests); // TODO
}

public static Map<String, Set<String>> _run(Configuration configuration) {
final Map<String, Map<String, Map<String, List<Integer>>>> coverage = getCoverage(configuration.pathToFirstVersion);
final DiffTestSelection diffTestSelection = new DiffTestSelection(configuration, coverage);
final Map<String, Set<String>> selectedTests = diffTestSelection.getTestThatExecuteChanges();
return diffTestSelection.getTestThatExecuteChanges();
}

private static void enhancedRun(Configuration configuration) {
private static Map<String, Set<String>> enhancedRun(Configuration configuration) {
final Map<String, Map<String, Map<String, List<Integer>>>> coverageV1 =
getCoverage(configuration.pathToFirstVersion);
final Map<String, Map<String, Map<String, List<Integer>>>> coverageV2 =
getCoverage(configuration.pathToSecondVersion);
new EnhancedDiffTestSelection(
return new EnhancedDiffTestSelection(
configuration.pathToFirstVersion,
configuration.pathToSecondVersion,
coverageV1,
Expand All @@ -54,7 +66,7 @@ private static void output(Configuration configuration, Coverage coverage, Map<S

private static Map<String, Map<String, Map<String, List<Integer>>>> getCoverage(final String pathToFirstVersion) {
LOGGER.info("Computing coverage for " + pathToFirstVersion);
new CloverExecutor().instrumentAndRunTest(pathToFirstVersion);
// new CloverExecutor().instrumentAndRunTest(pathToFirstVersion);
return new CloverReader().read(pathToFirstVersion);
}
}

0 comments on commit 659f9b1

Please sign in to comment.