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

fix(core): report failed check results only once #3472

Merged
merged 1 commit into from
Mar 30, 2022
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
6 changes: 4 additions & 2 deletions packages/core/src/process/4-mutation-test-executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,10 @@ export class MutationTestExecutor {
let passedMutant$ = input$;
for (const checkerName of this.options.checkers) {
// Use this checker
const [checkFailedResult$, checkPassedResult$] = partition(this.executeSingleChecker(checkerName, passedMutant$), isEarlyResult);
const [checkFailedResult$, checkPassedResult$] = partition(
this.executeSingleChecker(checkerName, passedMutant$).pipe(shareReplay()),
isEarlyResult
);

// Prepare for the next one
passedMutant$ = checkPassedResult$;
Expand Down Expand Up @@ -150,7 +153,6 @@ export class MutationTestExecutor {
.schedule(group$, (checker, group) => checker.check(checkerName, group))
.pipe(
mergeMap((mutantGroupResults) => mutantGroupResults),
shareReplay(),
map(([mutantRunPlan, checkResult]) =>
checkResult.status === CheckStatus.Passed
? mutantRunPlan
Expand Down
19 changes: 19 additions & 0 deletions packages/core/test/unit/process/4-mutation-test-executor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,25 @@ describe(MutationTestExecutor.name, () => {
sinon.assert.calledWithExactly(checker.check, 'foo', [plan2]);
});

it('should report failed check mutants only once (#3461)', async () => {
// Arrange
const plan1 = mutantRunPlan({ id: '1' });
const plan2 = mutantRunPlan({ id: '2' });
const failedCheckResult = factory.failedCheckResult();
arrangeScenario({ checkResult: failedCheckResult });
checker.group.resolves([[plan1], [plan2]]);
mutantTestPlans.push(plan1);
mutantTestPlans.push(plan2);

// Act
await sut.execute();

// Assert
expect(mutationTestReportHelperMock.reportCheckFailed).calledTwice;
sinon.assert.calledWithExactly(mutationTestReportHelperMock.reportCheckFailed, plan1.mutant, failedCheckResult);
sinon.assert.calledWithExactly(mutationTestReportHelperMock.reportCheckFailed, plan1.mutant, failedCheckResult);
});

it('should free checker resources after checking stage is complete', async () => {
// Arrange
const plan = mutantRunPlan({ id: '1' });
Expand Down