Skip to content
This repository has been archived by the owner on Feb 2, 2020. It is now read-only.

Commit

Permalink
Merge pull request #25 from kellyselden/error-code
Browse files Browse the repository at this point in the history
exit with error code when failures
  • Loading branch information
Kelly Selden authored Jun 24, 2016
2 parents ddc66ac + 64bf174 commit 09c12ed
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 4 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ node_js:
- "0.11"
- "iojs"

branches:
only:
- master

cache:
directories:
- node_modules
Expand Down
4 changes: 4 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ platform:
- x86
- x64

branches:
only:
- master

# Fix line endings in Windows. (runs before repo cloning)
init:
- git config --global core.autocrlf true
Expand Down
2 changes: 1 addition & 1 deletion lib/mocha/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ export default (lintTestFile, options) => {
addCompilers(mochaCompilers, extensions);
addFiles(mocha, mochaFiles, extensions, isMochaRecursive, lintTestFile);

mocha.run();
mocha.run(process.exit);
};
2 changes: 1 addition & 1 deletion test/acceptance/failure-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('acceptance - failure', function() {
'--eslint-args="**/*.js"',
'--mocha-args="test/**/*-test.js"'
];
return run(args, workingDir).then(stdout => {
return run(args, workingDir).catch(stdout => {
expect(stdout).to.contain(`${ok} this is my test`);
expect(stdout).to.contain('my-file.js passes');
expect(stdout).to.contain('my-test.js passes');
Expand Down
7 changes: 6 additions & 1 deletion test/helpers/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,13 @@ export default (args, workingDir) => {
process.chdir(originalWorkingDir);
}

if (stderr) {
let hasRuntimeError = stderr;
let hasTestError = err;

if (hasRuntimeError) {
reject(stderr);
} else if (hasTestError) {
reject(stdout);
} else {
resolve(stdout);
}
Expand Down
3 changes: 2 additions & 1 deletion test/unit/mocha/run-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ describe('unit - mocha/run', function() {
it('runs mocha', function() {
run(null, {});

expect(mochaRun.args).to.deep.equal([[]]);
expect(mochaRun.args.length).to.equal(1);
expect(mochaRun.args[0].length).to.equal(1);
});
});

0 comments on commit 09c12ed

Please sign in to comment.