-
Notifications
You must be signed in to change notification settings - Fork 251
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,8 +6,7 @@ | |
"typings": "src/Stryker.d.ts", | ||
"scripts": { | ||
"test": "grunt test", | ||
"start": "concurrently \"npm run tsc:w\" \"grunt serve\"", | ||
"tsc:w": "tsc -w", | ||
"start": "tsc -w", | ||
"sample": "node src/stryker-cli.js --configFile testResources/sampleProject/stryker.conf.js", | ||
"preversion": "grunt" | ||
}, | ||
|
@@ -34,7 +33,8 @@ | |
"Nico Stapelbroek <[email protected]>", | ||
"Jeremy Nagel <[email protected]>", | ||
"Michael Williamson <[email protected]>", | ||
"Philipp Weissenbacher <[email protected]>" | ||
"Philipp Weissenbacher <[email protected]>", | ||
"Alex van Assem <[email protected]" | ||
], | ||
"license": "Apache-2.0", | ||
"bin": { | ||
|
@@ -51,6 +51,7 @@ | |
"lodash": "^3.10.1", | ||
"log4js": "^0.6.33", | ||
"mkdirp": "^0.5.1", | ||
"progress": "^1.1.8", | ||
"serialize-javascript": "^1.3.0" | ||
}, | ||
"devDependencies": { | ||
|
@@ -66,6 +67,7 @@ | |
"@types/log4js": "0.0.32", | ||
"@types/mkdirp": "^0.3.28", | ||
"@types/mocha": "^2.2.34", | ||
"@types/progress": "^1.1.28", | ||
"@types/sinon": "^1.16.33", | ||
"@types/sinon-as-promised": "^4.0.5", | ||
"@types/sinon-chai": "^2.7.27", | ||
|
@@ -93,11 +95,11 @@ | |
"sinon": "^1.17.2", | ||
"sinon-as-promised": "^4.0.2", | ||
"sinon-chai": "^2.8.0", | ||
"stryker-api": "^0.4.1", | ||
"stryker-api": "^0.4.2-rc1", | ||
"tslint": "^3.15.1", | ||
"typescript": "^2.1.4" | ||
}, | ||
"peerDependencies": { | ||
"stryker-api": "^0.4.0" | ||
"stryker-api": "^0.4.2-rc1" | ||
} | ||
} |
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.