From dfede952f2592c3990a0d4a236db6b0e0dcf889c Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Tue, 5 Nov 2019 22:00:19 -0500 Subject: [PATCH 1/2] update progress reporters to show timed out count --- packages/core/src/reporters/ProgressAppendOnlyReporter.ts | 2 +- packages/core/src/reporters/ProgressKeeper.ts | 4 ++++ packages/core/src/reporters/ProgressReporter.ts | 2 +- .../unit/reporters/ProgressAppendOnlyReporter.spec.ts | 8 ++++---- .../core/test/unit/reporters/ProgressReporter.spec.ts | 2 +- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/packages/core/src/reporters/ProgressAppendOnlyReporter.ts b/packages/core/src/reporters/ProgressAppendOnlyReporter.ts index 1a10a1c7b1..329cceeedf 100644 --- a/packages/core/src/reporters/ProgressAppendOnlyReporter.ts +++ b/packages/core/src/reporters/ProgressAppendOnlyReporter.ts @@ -19,7 +19,7 @@ export default class ProgressAppendOnlyReporter extends ProgressKeeper { private render() { process.stdout.write( `Mutation testing ${this.getPercentDone()} (ETC ${this.getEtc()}) ` + - `${this.progress.tested}/${this.progress.total} tested (${this.progress.survived} survived)` + + `${this.progress.tested}/${this.progress.total} tested (${this.progress.survived} survived, ${this.progress.timedOut} timed out)` + os.EOL ); } diff --git a/packages/core/src/reporters/ProgressKeeper.ts b/packages/core/src/reporters/ProgressKeeper.ts index 7d24fb3b2e..2dd6d4468b 100644 --- a/packages/core/src/reporters/ProgressKeeper.ts +++ b/packages/core/src/reporters/ProgressKeeper.ts @@ -6,6 +6,7 @@ abstract class ProgressKeeper implements Reporter { private timer: Timer; protected progress = { survived: 0, + timedOut: 0, tested: 0, total: 0 }; @@ -25,6 +26,9 @@ abstract class ProgressKeeper implements Reporter { if (result.status === MutantStatus.Survived) { this.progress.survived++; } + if (result.status === MutantStatus.TimedOut) { + this.progress.timedOut++; + } } protected getEtc() { diff --git a/packages/core/src/reporters/ProgressReporter.ts b/packages/core/src/reporters/ProgressReporter.ts index cfa18ea07c..ee61347d14 100644 --- a/packages/core/src/reporters/ProgressReporter.ts +++ b/packages/core/src/reporters/ProgressReporter.ts @@ -7,7 +7,7 @@ export default class ProgressBarReporter extends ProgressKeeper { public onAllMutantsMatchedWithTests(matchedMutants: readonly MatchedMutant[]): void { super.onAllMutantsMatchedWithTests(matchedMutants); - const progressBarContent = 'Mutation testing [:bar] :percent (ETC :etc) :tested/:total tested (:survived survived)'; + const progressBarContent = 'Mutation testing [:bar] :percent (ETC :etc) :tested/:total tested (:survived survived, :timedOut timed out)'; this.progressBar = new ProgressBar(progressBarContent, { complete: '=', diff --git a/packages/core/test/unit/reporters/ProgressAppendOnlyReporter.spec.ts b/packages/core/test/unit/reporters/ProgressAppendOnlyReporter.spec.ts index aa75793e10..296b79eb37 100644 --- a/packages/core/test/unit/reporters/ProgressAppendOnlyReporter.spec.ts +++ b/packages/core/test/unit/reporters/ProgressAppendOnlyReporter.spec.ts @@ -30,28 +30,28 @@ describe('ProgressAppendOnlyReporter', () => { it('should log zero progress after ten seconds without completed tests', () => { sinon.clock.tick(TEN_SECONDS); - expect(process.stdout.write).to.have.been.calledWith('Mutation testing 0% (ETC n/a) ' + `0/2 tested (0 survived)${os.EOL}`); + expect(process.stdout.write).to.have.been.calledWith('Mutation testing 0% (ETC n/a) ' + `0/2 tested (0 survived, 0 timed out)${os.EOL}`); }); it('should log 50% with 10s ETC after ten seconds with 1 completed test', () => { sut.onMutantTested(mutantResult({ status: MutantStatus.Killed })); expect(process.stdout.write).to.not.have.been.called; sinon.clock.tick(TEN_SECONDS); - expect(process.stdout.write).to.have.been.calledWith(`Mutation testing 50% (ETC 10s) 1/2 tested (0 survived)${os.EOL}`); + expect(process.stdout.write).to.have.been.calledWith(`Mutation testing 50% (ETC 10s) 1/2 tested (0 survived, 0 timed out)${os.EOL}`); }); it('should log 50% with "1m, 40s" ETC after hundred seconds with 1 completed test', () => { sut.onMutantTested(mutantResult({ status: MutantStatus.Killed })); expect(process.stdout.write).to.not.have.been.called; sinon.clock.tick(HUNDRED_SECONDS); - expect(process.stdout.write).to.have.been.calledWith(`Mutation testing 50% (ETC 1m, 40s) 1/2 tested (0 survived)${os.EOL}`); + expect(process.stdout.write).to.have.been.calledWith(`Mutation testing 50% (ETC 1m, 40s) 1/2 tested (0 survived, 0 timed out)${os.EOL}`); }); it('should log 50% with "2h, 46m, 40s" ETC after ten tousand seconds with 1 completed test', () => { sut.onMutantTested(mutantResult({ status: MutantStatus.Killed })); expect(process.stdout.write).to.not.have.been.called; sinon.clock.tick(TEN_THOUSAND_SECONDS); - expect(process.stdout.write).to.have.been.calledWith(`Mutation testing 50% (ETC 2h, 46m, 40s) 1/2 tested (0 survived)${os.EOL}`); + expect(process.stdout.write).to.have.been.calledWith(`Mutation testing 50% (ETC 2h, 46m, 40s) 1/2 tested (0 survived, 0 timed out)${os.EOL}`); }); }); }); diff --git a/packages/core/test/unit/reporters/ProgressReporter.spec.ts b/packages/core/test/unit/reporters/ProgressReporter.spec.ts index bf3a50d295..d3a4889d2a 100644 --- a/packages/core/test/unit/reporters/ProgressReporter.spec.ts +++ b/packages/core/test/unit/reporters/ProgressReporter.spec.ts @@ -17,7 +17,7 @@ describe('ProgressReporter', () => { let sut: ProgressReporter; let matchedMutants: MatchedMutant[]; let progressBar: Mock; - const progressBarContent = 'Mutation testing [:bar] :percent (ETC :etc) :tested/:total tested (:survived survived)'; + const progressBarContent = 'Mutation testing [:bar] :percent (ETC :etc) :tested/:total tested (:survived survived, :timedOut timed out)'; beforeEach(() => { sinon.useFakeTimers(); From 2b3a0ed201aea17e7c77c14465eedeebeec782ec Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Wed, 6 Nov 2019 14:55:27 -0500 Subject: [PATCH 2/2] add test with timed out mutant to ProgressAppendOnlyReporter.spec.ts and update the killed mutant test to use thousand second mock timeout --- .../reporters/ProgressAppendOnlyReporter.spec.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/core/test/unit/reporters/ProgressAppendOnlyReporter.spec.ts b/packages/core/test/unit/reporters/ProgressAppendOnlyReporter.spec.ts index 296b79eb37..a0f9c62dcf 100644 --- a/packages/core/test/unit/reporters/ProgressAppendOnlyReporter.spec.ts +++ b/packages/core/test/unit/reporters/ProgressAppendOnlyReporter.spec.ts @@ -8,6 +8,7 @@ import ProgressAppendOnlyReporter from '../../../src/reporters/ProgressAppendOnl const SECOND = 1000; const TEN_SECONDS = SECOND * 10; const HUNDRED_SECONDS = SECOND * 100; +const THOUSAND_SECONDS = SECOND * 1000; const TEN_THOUSAND_SECONDS = SECOND * 10000; describe('ProgressAppendOnlyReporter', () => { @@ -47,11 +48,18 @@ describe('ProgressAppendOnlyReporter', () => { expect(process.stdout.write).to.have.been.calledWith(`Mutation testing 50% (ETC 1m, 40s) 1/2 tested (0 survived, 0 timed out)${os.EOL}`); }); - it('should log 50% with "2h, 46m, 40s" ETC after ten tousand seconds with 1 completed test', () => { + it('should log 50% with "10m, 40s" ETC after thousand seconds with 1 completed test', () => { sut.onMutantTested(mutantResult({ status: MutantStatus.Killed })); expect(process.stdout.write).to.not.have.been.called; + sinon.clock.tick(THOUSAND_SECONDS); + expect(process.stdout.write).to.have.been.calledWith(`Mutation testing 50% (ETC 10m, 40s) 1/2 tested (0 survived, 0 timed out)${os.EOL}`); + }); + + it('should log 50% with "2h, 46m, 40s" ETC after ten thousand seconds with 1 completed test', () => { + sut.onMutantTested(mutantResult({ status: MutantStatus.TimedOut })); + expect(process.stdout.write).to.not.have.been.called; sinon.clock.tick(TEN_THOUSAND_SECONDS); - expect(process.stdout.write).to.have.been.calledWith(`Mutation testing 50% (ETC 2h, 46m, 40s) 1/2 tested (0 survived, 0 timed out)${os.EOL}`); + expect(process.stdout.write).to.have.been.calledWith(`Mutation testing 50% (ETC 2h, 46m, 40s) 1/2 tested (0 survived, 1 timed out)${os.EOL}`); }); }); });