Skip to content

Commit

Permalink
fixed support for multiple --globals lists
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Apr 13, 2012
1 parent cc466dd commit 792c34a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
14 changes: 9 additions & 5 deletions bin/_mocha
Expand Up @@ -26,6 +26,12 @@ var program = require('commander')

var files = [];

/**
* Globals.
*/

var globals = [];

/**
* Images.
*/
Expand Down Expand Up @@ -63,10 +69,8 @@ program.name = 'mocha';

// --globals

var globals = [];
program.on('globals', function(){
globals = globals.concat(program.globals);
program.globals = globals;
program.on('globals', function(val){
globals = globals.concat(list(val));
});

// --reporters
Expand Down Expand Up @@ -277,7 +281,7 @@ function load(files, fn) {
function run(suite, fn) {
suite.emit('run');
var runner = new Runner(suite);
runner.globals(program.globals);
runner.globals(globals);
if (program.ignoreLeaks) runner.ignoreLeaks = true;
if (program.grep) runner.grep(new RegExp(program.grep));
var reporter = new Reporter(runner);
Expand Down
1 change: 1 addition & 0 deletions test/acceptance/globals.js
Expand Up @@ -21,6 +21,7 @@ describe('global leaks', function(){
it('should pass when accepted', function(){
okGlobalA = 1;
okGlobalB = 1;
okGlobalC = 1;
})

afterEach(function(){
Expand Down
2 changes: 1 addition & 1 deletion test/jsapi/index.js
Expand Up @@ -4,7 +4,7 @@ var Mocha = require('../../')

var mocha = new Mocha({
ui: 'bdd',
globals: ['okGlobalA', 'okGlobalB'],
globals: ['okGlobalA', 'okGlobalB', 'okGlobalC'],
// ignoreLeaks: true,
growl: true
});
Expand Down
4 changes: 2 additions & 2 deletions test/mocha.opts
Expand Up @@ -2,6 +2,6 @@
--reporter dot
--ui bdd
--growl
--globals okGlobalA
--globals okGlobalB
--globals okGlobalA,okGlobalB
--globals okGlobalC
--timeout 200

0 comments on commit 792c34a

Please sign in to comment.