Add build tests for build command checks.

Former-commit-id: 3f43b83f07ded116e0ae667f9c809bd1b7b4f30a
This commit is contained in:
John-David Dalton
2013-07-02 23:39:51 -07:00
parent c43ff29f5d
commit 2d5f045c29
2 changed files with 50 additions and 7 deletions

View File

@@ -2498,7 +2498,7 @@
if (isTemplate) {
invalidArgs.push('template');
}
if (invalidArgs.length > 2) {
if (invalidArgs.length > 1) {
warnings.push('The `' + invalidArgs.slice(0, -1).join('`, `') + '`' + (invalidArgs.length > 2 ? ',' : '') + ' and `' + invalidArgs.slice(-1) + '` commands may not be combined.');
}
// report invalid command entries

View File

@@ -482,6 +482,48 @@
/*--------------------------------------------------------------------------*/
QUnit.module('build command checks');
(function() {
var reHelp = /lodash --help/,
write = process.stdout.write;
var commands = [
'node.EXE build -s modern',
'-s strict underscore'
];
commands.forEach(function(command) {
asyncTest('`lodash ' + command +'` is valid', function() {
var start = _.after(2, _.once(function() {
ok(true, 'should be valid');
QUnit.start();
}));
build(command.split(' '), start);
});
});
commands = [
'mobile underscore',
'modern template=./*.jst'
];
commands.forEach(function(command) {
asyncTest('`lodash ' + command +'` is not valid', function() {
process.stdout.write = _.once(function(string) {
ok(reHelp.test(string));
process.stdout.write = write;
QUnit.start();
});
build(command.split(' '), function() {});
});
});
}());
/*--------------------------------------------------------------------------*/
QUnit.module('minified AMD snippet');
(function() {
@@ -1388,6 +1430,8 @@
QUnit.module('stdout option');
(function() {
var write = process.stdout.write;
var commands = [
'-c',
'-c -d',
@@ -1397,19 +1441,18 @@
commands.forEach(function(command, index) {
asyncTest('`lodash ' + command +'`', function() {
var written,
start = _.once(QUnit.start),
write = process.stdout.write;
start = _.once(QUnit.start);
process.stdout.write = function(string) {
written = string;
};
build(['exports=', 'include='].concat(command.split(' ')), function(data) {
process.stdout.write = write;
strictEqual('outputPath' in data, false);
equal(written, data.source);
equal(arguments.length, 1);
process.stdout.write = write;
start();
});
});
@@ -1621,8 +1664,8 @@
// expand categories to function names
funcNames.slice().forEach(function(category) {
var otherNames = _.filter(categoryMap[category], function(identifier) {
return typeof _[identifier] == 'function';
var otherNames = _.filter(categoryMap[category], function(key) {
return typeof _[key] == 'function';
});
// limit function names to those available for specific builds