Skip to content

Commit

Permalink
Merge pull request mochajs#1910 from nexdrew/fix/mocha-opts-dupe
Browse files Browse the repository at this point in the history
Fix duplication of mocha.opts on process.argv
  • Loading branch information
Travis Jeffery committed Oct 21, 2015
2 parents 0c70277 + f8294e6 commit 20ebec8
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 20ebec8

Please sign in to comment.