Skip to content

Commit

Permalink
remove duplication of mocha.opts on process.argv
Browse files Browse the repository at this point in the history
  • Loading branch information
nexdrew committed Oct 7, 2015
1 parent 0c70277 commit f8294e6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
7 changes: 1 addition & 6 deletions bin/mocha
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
9 changes: 9 additions & 0 deletions test/integration/regression.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
var assert = require('assert');
var fs = require('fs');
var path = require('path');
var run = require('./helpers').runMocha;

describe('regressions', function() {
Expand All @@ -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');
});
});

0 comments on commit f8294e6

Please sign in to comment.