diff --git a/bin/mocha b/bin/mocha index 123929e8f1..031ef56bff 100755 --- a/bin/mocha +++ b/bin/mocha @@ -8,12 +8,7 @@ var spawn = require('child_process').spawn, path = require('path'), fs = require('fs'), - args = [path.join(__dirname, '_mocha')], - getOptions = require('./options'); - -// load mocha.opts into process.argv - -getOptions(); + args = [path.join(__dirname, '_mocha')]; process.argv.slice(2).forEach(function(arg){ var flag = arg.split('=')[0]; diff --git a/test/integration/regression.js b/test/integration/regression.js index 564e922110..5e2d863a64 100644 --- a/test/integration/regression.js +++ b/test/integration/regression.js @@ -1,4 +1,6 @@ var assert = require('assert'); +var fs = require('fs'); +var path = require('path'); var run = require('./helpers').runMocha; describe('regressions', function() { @@ -21,4 +23,11 @@ describe('regressions', function() { done(); }); }); + + it('should not duplicate mocha.opts args in process.argv', function() { + var processArgv = process.argv.join(''); + var mochaOpts = fs.readFileSync(path.join(__dirname, '..', 'mocha.opts'), 'utf-8').split(/[\s]+/).join(''); + assert.notEqual(processArgv.indexOf(mochaOpts), -1, 'process.argv missing mocha.opts'); + assert.equal(processArgv.indexOf(mochaOpts), processArgv.lastIndexOf(mochaOpts), 'process.argv contains duplicated mocha.opts'); + }); });