Skip to content

Commit

Permalink
feat(error debugging): add remark to run again with loglevel trace (#…
Browse files Browse the repository at this point in the history
…1231)

Fixes #1205
  • Loading branch information
bharaninb authored and simondel committed Nov 8, 2018
1 parent ff0073a commit c9e3d97
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/stryker/src/Stryker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ export default class Stryker {
await this.logDone();
await LogConfigurator.shutdown();
return mutantResults;
} else {
this.logRemark();
}
}
return Promise.resolve([]);
Expand Down Expand Up @@ -152,6 +154,12 @@ export default class Stryker {
this.log.info('Done in %s.', this.timer.humanReadableElapsed());
}

private logRemark() {
if (!this.log.isTraceEnabled()) {
this.log.info('Trouble figuring out what went wrong? Try `npx stryker run --fileLogLevel trace --logLevel debug` to get some more info.');
}
}

private reportScore(mutantResults: MutantResult[]) {
const calculator = new ScoreResultCalculator();
const score = calculator.calculate(mutantResults);
Expand Down
3 changes: 3 additions & 0 deletions packages/stryker/src/StrykerCli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ export default class StrykerCli {
if (Object.keys(commands).indexOf(this.command) >= 0) {
commands[this.command]().catch(err => {
log.error(`an error occurred`, err);
if (!log.isTraceEnabled()) {
log.info('Trouble figuring out what went wrong? Try `npx stryker run --fileLogLevel trace --logLevel debug` to get some more info.');
}
process.exitCode = 1;
process.kill(process.pid, 'SIGINT');
});
Expand Down
12 changes: 12 additions & 0 deletions packages/stryker/test/unit/StrykerSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,18 @@ describe('Stryker', () => {
await sut.runMutationTest();
expect(currentLogMock().info).to.have.been.calledWith('It\'s a mutant-free world, nothing to test.');
});

it('should log the remark to run again with logLevel trace if no tests were executed in initial test run', async () => {
while (initialRunResult.tests.pop());
await sut.runMutationTest();
expect(currentLogMock().info).to.have.been.calledWith('Trouble figuring out what went wrong? Try `npx stryker run --fileLogLevel trace --logLevel debug` to get some more info.');
});

it('should log the remark to run again with logLevel trace if no mutants were generated', async () => {
while (mutants.pop()); // clear all mutants
await sut.runMutationTest();
expect(currentLogMock().info).to.have.been.calledWith('Trouble figuring out what went wrong? Try `npx stryker run --fileLogLevel trace --logLevel debug` to get some more info.');
});
});

describe('happy flow', () => {
Expand Down

0 comments on commit c9e3d97

Please sign in to comment.