1 | import os from 'os';
|
2 |
|
3 | import { MutationTestingPlanReadyEvent } from '@stryker-mutator/api/src/report';
|
4 |
|
5 | import { ProgressKeeper } from './progress-keeper.js';
|
6 |
|
7 | export class ProgressAppendOnlyReporter extends ProgressKeeper {
|
8 | private intervalReference?: NodeJS.Timer;
|
9 |
|
10 | public onMutationTestingPlanReady(event: MutationTestingPlanReadyEvent): void {
|
11 | super.onMutationTestingPlanReady(event);
|
12 | if (event.mutantPlans.length) {
|
13 | this.intervalReference = setInterval(() => this.render(), 10000);
|
14 | }
|
15 | }
|
16 |
|
17 | public onAllMutantsTested(): void {
|
18 | if (this.intervalReference) {
|
19 | clearInterval(this.intervalReference);
|
20 | }
|
21 | }
|
22 |
|
23 | private render() {
|
24 | process.stdout.write(
|
25 | `Mutation testing ${this.getPercentDone()} (elapsed: ${this.getElapsedTime()}, remaining: ${this.getEtc()}) ` +
|
26 | `${this.progress.tested}/${this.progress.mutants} tested (${this.progress.survived} survived, ${this.progress.timedOut} timed out)` +
|
27 | os.EOL
|
28 | );
|
29 | }
|
30 |
|
31 | private getPercentDone() {
|
32 | return `${Math.floor((this.progress.ticks / this.progress.total) * 100)}%`;
|
33 | }
|
34 | }
|