Skip to content

Commit

Permalink
Ensure iterate exits with proper code
Browse files Browse the repository at this point in the history
  • Loading branch information
Trent Willis committed Mar 25, 2017
1 parent 5c77472 commit 0431ab6
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/commands/exam/iterate.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ module.exports = {
} catch (error) {
this._write('Returned non-zero exit code with error: ' + error);
exitCode = 1;
process.exitCode = 1;
} finally {
var color = exitCode ? chalk.red : chalk.green;
return [
Expand Down
22 changes: 21 additions & 1 deletion node-tests/acceptance/exam-iterate-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var child_process = require('child_process');
var exec = child_process.exec;
var execSync = child_process.execSync;
var rimraf = require('rimraf');
var fs = require('fs');
var fs = require('fs-extra');
var path = require('path');

function contains(str, value) {
Expand Down Expand Up @@ -88,4 +88,24 @@ describe('Acceptance | Exam Iterate Command', function() {
done();
});
});

describe('Exit Code', function() {
var destPath = path.join( __dirname, '..', '..', 'tests', 'unit', 'failing-test.js');

beforeEach(function() {
var failingTestPath = path.join( __dirname, '..', 'fixtures', 'failure.js');
fs.copySync(failingTestPath, destPath);
});

afterEach(function() {
fs.removeSync(destPath);
});

it('should have an exitCode of 1 when a test fails', function(done) {
exec('ember exam:iterate 1', function(error, stdout, stderr) {
assert.equal(error.code, 1);
done();
});
});
});
});
1 change: 1 addition & 0 deletions node-tests/fixtures/failure.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
throw 'failure';
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
"scripts": {
"build": "ember build",
"start": "ember server",
"test": "mocha --recursive node-tests/",
"test": "mocha node-tests/**/*-test.js",
"test:ember": "ember try:each",
"test:all": "npm run test:ember && npm test",
"test:ci": "ember try:one $EMBER_TRY_SCENARIO && npm test",
"test:cover": "istanbul cover ./node_modules/mocha/bin/_mocha -- --recursive node-tests/",
"test:cover": "istanbul cover ./node_modules/mocha/bin/_mocha -- node-tests/**/*-test.js",
"test:ci:cover": "ember try:one $EMBER_TRY_SCENARIO && npm run test:cover"
},
"repository": {
Expand Down

0 comments on commit 0431ab6

Please sign in to comment.