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

prevent logging of incremental analysis during dummy first scan #1245

Merged
merged 1 commit into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Expand Up @@ -30,10 +30,16 @@ public class IncrementalAnalyser implements MutationAnalyser {
private final CoverageDatabase coverage;
private final Map<DetectionStatus, Long> preAnalysed = new EnumMap<>(DetectionStatus.class);

public IncrementalAnalyser(final CodeHistory history,
final CoverageDatabase coverage) {
private final boolean enableLog;

public IncrementalAnalyser(CodeHistory history, CoverageDatabase coverage) {
this(history, coverage, true);
}

public IncrementalAnalyser(CodeHistory history, CoverageDatabase coverage, boolean enableLog) {
this.history = history;
this.coverage = coverage;
this.enableLog = enableLog;
}

@Override
Expand All @@ -52,7 +58,9 @@ public Collection<MutationResult> analyse(
}
}

logTotals();
if (enableLog) {
logTotals();
}

return mrs;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,9 @@ private List<MutationAnalysisUnit> buildMutationTests(CoverageDatabase coverageD

final MutationSource source = new MutationSource(mutationConfig, testPrioritiser, bas, interceptor);

final MutationAnalyser analyser = new IncrementalAnalyser(
new DefaultCodeHistory(this.code, history), coverageData);
final MutationAnalyser analyser = new IncrementalAnalyser(new DefaultCodeHistory(this.code, history),
coverageData,
enableIncrementalAnalysisLogging(history));

final WorkerFactory wf = new WorkerFactory(this.baseDir, coverage()
.getConfiguration(), mutationConfig, args,
Expand All @@ -394,6 +395,13 @@ private List<MutationAnalysisUnit> buildMutationTests(CoverageDatabase coverageD
return builder.createMutationTestUnits(this.code.getCodeUnderTestNames());
}

private boolean enableIncrementalAnalysisLogging(HistoryStore history) {
// Horrible hack to prevent logging during pre scan phase. This would
// cause confusion as if only part of the log is read it appears that
// incremental analysis has affected no mutants
return !(history instanceof NullHistoryStore);
}

private void checkMutationsFound(final List<MutationAnalysisUnit> tus) {
if (tus.isEmpty()) {
if (this.data.shouldFailWhenNoMutations()) {
Expand Down