From 2d5f045c293ef170f0d666cd2633c89ea357ee0a Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Tue, 2 Jul 2013 23:39:51 -0700 Subject: [PATCH] Add build tests for build command checks. Former-commit-id: 3f43b83f07ded116e0ae667f9c809bd1b7b4f30a --- build.js | 2 +- test/test-build.js | 55 +++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 50 insertions(+), 7 deletions(-) diff --git a/build.js b/build.js index f0bc7bd2a..173fb888a 100755 --- a/build.js +++ b/build.js @@ -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 diff --git a/test/test-build.js b/test/test-build.js index a293f48f2..17197bbdd 100644 --- a/test/test-build.js +++ b/test/test-build.js @@ -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