diff --git a/lib/commands/exam/iterate.js b/lib/commands/exam/iterate.js index 673ece8f..93930d2b 100644 --- a/lib/commands/exam/iterate.js +++ b/lib/commands/exam/iterate.js @@ -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 [ diff --git a/node-tests/acceptance/exam-iterate-test.js b/node-tests/acceptance/exam-iterate-test.js index 674e5b03..1f22db1d 100644 --- a/node-tests/acceptance/exam-iterate-test.js +++ b/node-tests/acceptance/exam-iterate-test.js @@ -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) { @@ -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(); + }); + }); + }); }); diff --git a/node-tests/fixtures/failure.js b/node-tests/fixtures/failure.js new file mode 100644 index 00000000..18397c3f --- /dev/null +++ b/node-tests/fixtures/failure.js @@ -0,0 +1 @@ +throw 'failure'; diff --git a/package.json b/package.json index c262b747..2d98d0c7 100644 --- a/package.json +++ b/package.json @@ -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": {