-
Notifications
You must be signed in to change notification settings - Fork 250
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(progress-reporter): Create new progress reporter (#202)
* Rename current `'progress'` reporter to `'dots'` reporter * Add new fancy progress-reporter using a progress bar * chore(npm-start): Update npm start command
- Loading branch information
Showing
12 changed files
with
360 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import {Reporter, MutantResult, MutantStatus} from 'stryker-api/report'; | ||
import * as chalk from 'chalk'; | ||
import * as os from 'os'; | ||
|
||
export default class DotsReporter implements Reporter { | ||
onMutantTested(result: MutantResult) { | ||
let toLog: string; | ||
switch (result.status) { | ||
case MutantStatus.Killed: | ||
toLog = '.'; | ||
break; | ||
case MutantStatus.TimedOut: | ||
toLog = chalk.yellow('T'); | ||
break; | ||
case MutantStatus.Survived: | ||
toLog = chalk.bold.red('S'); | ||
break; | ||
case MutantStatus.Error: | ||
toLog = chalk.yellow('E'); | ||
break; | ||
default: | ||
toLog = ''; | ||
break; | ||
} | ||
process.stdout.write(toLog); | ||
} | ||
|
||
onAllMutantsTested(): void { | ||
process.stdout.write(os.EOL); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import ProgressBar = require('progress'); | ||
|
||
export default ProgressBar; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,69 @@ | ||
import {Reporter, MutantResult, MutantStatus} from 'stryker-api/report'; | ||
import { Reporter, MatchedMutant, MutantResult, MutantStatus } from 'stryker-api/report'; | ||
import ProgressBar from './ProgressBar'; | ||
import * as chalk from 'chalk'; | ||
import * as os from 'os'; | ||
|
||
export default class ProgressReporter implements Reporter { | ||
onMutantTested(result: MutantResult) { | ||
let toLog: string; | ||
private progressBar: ProgressBar; | ||
|
||
// tickValues contains Labels, because on initation of the ProgressBar the width is determined based on the amount of characters of the progressBarContent inclusive ASCII-codes for colors | ||
private tickValues = { | ||
error: 0, | ||
survived: 0, | ||
killed: 0, | ||
timeout: 0, | ||
noCoverage: 0, | ||
killedLabel: `${chalk.green.bold('killed')}`, | ||
survivedLabel: `${chalk.red.bold('survived')}`, | ||
noCoverageLabel: `${chalk.red.bold('no coverage')}`, | ||
timeoutLabel: `${chalk.yellow.bold('timeout')}`, | ||
errorLabel: `${chalk.yellow.bold('error')}` | ||
}; | ||
|
||
onAllMutantsMatchedWithTests(matchedMutants: ReadonlyArray<MatchedMutant>): void { | ||
let progressBarContent: string; | ||
|
||
progressBarContent = | ||
`Mutation testing [:bar] :percent (ETC :etas)` + | ||
`[:killed :killedLabel] ` + | ||
`[:survived :survivedLabel] ` + | ||
`[:noCoverage :noCoverageLabel] ` + | ||
`[:timeout :timeoutLabel] ` + | ||
`[:error :errorLabel]`; | ||
|
||
this.progressBar = new ProgressBar(progressBarContent, { | ||
width: 50, | ||
complete: '=', | ||
incomplete: ' ', | ||
total: matchedMutants.filter(m => m.scopedTestIds.length > 0).length | ||
}); | ||
} | ||
|
||
onMutantTested(result: MutantResult): void { | ||
switch (result.status) { | ||
case MutantStatus.Killed: | ||
toLog = '.'; | ||
case MutantStatus.NoCoverage: | ||
this.tickValues.noCoverage++; | ||
this.progressBar.render(this.tickValues); | ||
break; | ||
case MutantStatus.TimedOut: | ||
toLog = chalk.yellow('T'); | ||
case MutantStatus.Killed: | ||
this.tickValues.killed++; | ||
this.tick(); | ||
break; | ||
case MutantStatus.Survived: | ||
toLog = chalk.bold.red('S'); | ||
this.tickValues.survived++; | ||
this.tick(); | ||
break; | ||
case MutantStatus.Error: | ||
toLog = chalk.yellow('E'); | ||
case MutantStatus.TimedOut: | ||
this.tickValues.timeout++; | ||
this.tick(); | ||
break; | ||
default: | ||
toLog = ''; | ||
case MutantStatus.Error: | ||
this.tickValues.error++; | ||
this.tick(); | ||
break; | ||
} | ||
process.stdout.write(toLog); | ||
} | ||
|
||
onAllMutantsTested(): void { | ||
process.stdout.write(os.EOL); | ||
tick(): void { | ||
this.progressBar.tick(this.tickValues); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.