Fix how method names are resolved from categories in test/test-build.js.

Former-commit-id: bbb8a2ca376a64b2fd9c3e2fbe0d3911a7089a94
This commit is contained in:
John-David Dalton
2013-06-24 08:01:19 -07:00
parent 54a2a0da48
commit 449c946423
2 changed files with 27 additions and 25 deletions

View File

@@ -2142,7 +2142,7 @@
: accumulator; : accumulator;
}, []); }, []);
// expand categories to methods // expand categories to method names
_.each([includeMethods, minusMethods, plusMethods], function(methodNames) { _.each([includeMethods, minusMethods, plusMethods], function(methodNames) {
var categories = _.intersection(methodNames, methodCategories); var categories = _.intersection(methodNames, methodCategories);

View File

@@ -1619,8 +1619,7 @@
var start = _.after(2, _.once(QUnit.start)); var start = _.after(2, _.once(QUnit.start));
build(['--silent'].concat(command.split(' ')), function(data) { build(['--silent'].concat(command.split(' ')), function(data) {
var methodNames, var basename = path.basename(data.outputPath, '.js'),
basename = path.basename(data.outputPath, '.js'),
context = createContext(), context = createContext(),
isBackbone = /\bbackbone\b/.test(command), isBackbone = /\bbackbone\b/.test(command),
isUnderscore = isBackbone || /\bunderscore\b/.test(command), isUnderscore = isBackbone || /\bunderscore\b/.test(command),
@@ -1634,7 +1633,13 @@
} }
// add method names explicitly // add method names explicitly
if (/\binclude=/.test(command)) { if (/\binclude=/.test(command)) {
methodNames = command.match(/\binclude=(\S*)/)[1].split(/, */); var methodNames = command.match(/\binclude=(\S*)/)[1].split(/, */);
}
if (/\bcategory=/.test(command)) {
var categories = command.match(/\bcategory=(\S*)/)[1].split(/, */);
methodNames = (methodNames || []).concat(categories.map(function(category) {
return capitalize(category.toLowerCase());
}));
} }
// add method names required by Backbone and Underscore builds // add method names required by Backbone and Underscore builds
if (/\bbackbone\b/.test(command) && !methodNames) { if (/\bbackbone\b/.test(command) && !methodNames) {
@@ -1648,44 +1653,41 @@
methodNames = underscoreMethods.slice(); methodNames = underscoreMethods.slice();
} }
} }
if (/\bcategory=/.test(command)) {
methodNames = (methodNames || []).concat(command.match(/\bcategory=(\S*)/)[1].split(/, */).map(function(category) {
return capitalize(category.toLowerCase());
}));
}
if (!methodNames) { if (!methodNames) {
methodNames = lodashMethods.slice(); methodNames = lodashMethods.slice();
} }
if (/\bplus=/.test(command)) { if (/\bplus=/.test(command)) {
methodNames = methodNames.concat(command.match(/\bplus=(\S*)/)[1].split(/, */)); var otherNames = command.match(/\bplus=(\S*)/)[1].split(/, */);
methodNames = methodNames.concat(expandMethodNames(otherNames));
} }
if (/\bminus=/.test(command)) { if (/\bminus=/.test(command)) {
methodNames = _.difference(methodNames, expandMethodNames(command.match(/\bminus=(\S*)/)[1].split(/, */))); otherNames = command.match(/\bminus=(\S*)/)[1].split(/, */);
methodNames = _.difference(methodNames, expandMethodNames(otherNames));
} }
if (/\bexclude=/.test(command)) { if (/\bexclude=/.test(command)) {
methodNames = _.difference(methodNames, expandMethodNames(command.match(/\bexclude=(\S*)/)[1].split(/, */))); otherNames = command.match(/\bexclude=(\S*)/)[1].split(/, */);
methodNames = _.difference(methodNames, expandMethodNames(otherNames));
} }
// expand categories to real method names // expand categories to method names
methodNames.slice().forEach(function(category) { methodNames.slice().forEach(function(category) {
var result = getMethodsByCategory(category); var otherNames = getMethodsByCategory(category);
// limit category methods to those available for specific builds // limit method names to those available for specific builds
result = result.filter(function(methodName) { otherNames = _.intersection(otherNames,
return _.contains( isBackbone ? backboneDependencies :
isBackbone ? backboneDependencies : isUnderscore ? underscoreMethods :
isUnderscore ? underscoreMethods : lodashMethods
lodashMethods, methodName );
);
}); if (otherNames.length) {
if (result.length) {
methodNames = _.without(methodNames, category); methodNames = _.without(methodNames, category);
push.apply(methodNames, result); push.apply(methodNames, otherNames);
} }
}); });
// expand aliases and remove nonexistent and duplicate method names // expand aliases and remove nonexistent and duplicate method names
methodNames = _.uniq(_.intersection(allMethods, expandMethodNames(methodNames))); methodNames = _.uniq(_.intersection(expandMethodNames(methodNames), allMethods));
if (!exposeAssign) { if (!exposeAssign) {
methodNames = _.without(methodNames, 'assign'); methodNames = _.without(methodNames, 'assign');