Add QUnit.config.noglobals to build tests.

Former-commit-id: 4519f5322a51632ce23dc4c574365472338a18e0
This commit is contained in:
John-David Dalton
2013-02-23 20:29:23 -08:00
parent 251e228ce4
commit 323d7306e2

View File

@@ -2,6 +2,9 @@
;(function(undefined) { ;(function(undefined) {
'use strict'; 'use strict';
/** Used to avoid `noglobal` false positives caused by `errno` leaked in Node.js */
global.errno = true;
/** Load modules */ /** Load modules */
var fs = require('fs'), var fs = require('fs'),
path = require('path'), path = require('path'),
@@ -12,10 +15,10 @@
/** The unit testing framework */ /** The unit testing framework */
var QUnit = ( var QUnit = (
global.addEventListener || (global.addEventListener = Function.prototype), global.addEventListener = Function.prototype,
global.QUnit = require('../vendor/qunit/qunit/qunit.js'), global.QUnit = require('../vendor/qunit/qunit/qunit.js'),
require('../vendor/qunit-clib/qunit-clib.js').runInContext(global), require('../vendor/qunit-clib/qunit-clib.js').runInContext(global),
global.addEventListener === Function.prototype && delete global.addEventListener, delete global.addEventListener,
global.QUnit global.QUnit
); );
@@ -488,10 +491,10 @@
QUnit.module('minified AMD snippet'); QUnit.module('minified AMD snippet');
(function() { (function() {
var start = _.once(QUnit.start); var start = _.after(2, _.once(QUnit.start));
asyncTest('`lodash`', function() { asyncTest('`lodash`', function() {
build(['-s'], function(data) { build(['-s', 'exclude='], function(data) {
// used by r.js build optimizer // used by r.js build optimizer
var defineHasRegExp = /typeof\s+define\s*==(=)?\s*['"]function['"]\s*&&\s*typeof\s+define\.amd\s*==(=)?\s*['"]object['"]\s*&&\s*define\.amd/g, var defineHasRegExp = /typeof\s+define\s*==(=)?\s*['"]function['"]\s*&&\s*typeof\s+define\.amd\s*==(=)?\s*['"]object['"]\s*&&\s*define\.amd/g,
basename = path.basename(data.outputPath, '.js'); basename = path.basename(data.outputPath, '.js');
@@ -1206,6 +1209,7 @@
'backbone legacy category=utilities minus=first,last', 'backbone legacy category=utilities minus=first,last',
'legacy include=defer', 'legacy include=defer',
'legacy underscore', 'legacy underscore',
'modern strict include=isArguments,isArray,isFunction,isPlainObject,key',
'underscore include=debounce,throttle plus=after minus=throttle', 'underscore include=debounce,throttle plus=after minus=throttle',
'underscore mobile strict category=functions exports=amd,global plus=pick,uniq', 'underscore mobile strict category=functions exports=amd,global plus=pick,uniq',
] ]
@@ -1216,7 +1220,7 @@
); );
commands.forEach(function(origCommand) { commands.forEach(function(origCommand) {
_.times(5, function(index) { _.times(4, function(index) {
var command = origCommand; var command = origCommand;
if (index == 1) { if (index == 1) {
@@ -1232,12 +1236,6 @@
command = 'modern ' + command; command = 'modern ' + command;
} }
else if (index == 3) { else if (index == 3) {
if (/strict/.test(command)) {
return;
}
command = 'strict ' + command;
}
else if (index == 4) {
if (/category|legacy|underscore/.test(command)) { if (/category|legacy|underscore/.test(command)) {
return; return;
} }
@@ -1327,8 +1325,6 @@
process.exit(QUnit.config.stats.bad ? 1 : 0); process.exit(QUnit.config.stats.bad ? 1 : 0);
}, timeLimit); }, timeLimit);
} }
// explicitly call `QUnit.start()` for Narwhal, Node.js, Rhino, and RingoJS QUnit.config.noglobals = true;
if (!global.document) { QUnit.start();
QUnit.start();
}
}()); }());