Use populist v0.1.2 to bundle test modules instead of browserify.

This will allow full support for mocking, dumpCache, and correct line
numbers in error messages.
This commit is contained in:
Ben Newman
2013-07-15 11:34:47 -04:00
parent f457394362
commit c6c4657f83
5 changed files with 50 additions and 1 deletions

View File

@@ -4,6 +4,7 @@ var exec = require('child_process').exec;
var jsxTask = require('./grunt/tasks/jsx');
var browserifyTask = require('./grunt/tasks/browserify');
var wrapupTask = require('./grunt/tasks/wrapup');
var populistTask = require('./grunt/tasks/populist');
var phantomTask = require('./grunt/tasks/phantom');
var npmTask = require('./grunt/tasks/npm');
var releaseTasks = require('./grunt/tasks/release');
@@ -16,6 +17,7 @@ module.exports = function(grunt) {
jsx: require('./grunt/config/jsx/jsx'),
browserify: require('./grunt/config/browserify'),
wrapup: require('./grunt/config/wrapup'),
populist: require('./grunt/config/populist'),
phantom: require('./grunt/config/phantom'),
npm: require('./grunt/config/npm'),
clean: ['./build', './*.gem', './docs/_site', './examples/shared/*.js'],
@@ -44,6 +46,8 @@ module.exports = function(grunt) {
// defines global variables instead of using require.
grunt.registerMultiTask('wrapup', wrapupTask);
grunt.registerMultiTask('populist', populistTask);
grunt.registerMultiTask('phantom', phantomTask);
grunt.registerMultiTask('npm', npmTask);
@@ -56,7 +60,7 @@ module.exports = function(grunt) {
'jsx:jasmine',
'jsx:test',
'browserify:jasmine',
'browserify:test'
'populist:test'
]);
grunt.registerTask('test', ['build:test', 'phantom:run']);

13
grunt/config/populist.js Normal file
View File

@@ -0,0 +1,13 @@
'use strict';
var test = {
args: ["test/all:"],
requires: [
"**/__tests__/*-test.js"
],
outfile: './build/react-test.js'
};
module.exports = {
test: test
};

28
grunt/tasks/populist.js Normal file
View File

@@ -0,0 +1,28 @@
'use strict';
var grunt = require('grunt');
module.exports = function() {
var config = this.data;
var done = this.async();
// create the bundle we'll work with
var args = config.args;
// Make sure the things that need to be exposed are.
var requires = config.requires || {};
grunt.file.expand({
nonull: true, // Keep IDs that don't expand to anything.
cwd: "src"
}, requires).forEach(function(name) {
args.push(name.replace(/\.js$/i, ""));
});
require("populist").buildP({
rootDirectory: "build/modules",
args: args
}).then(function(output) {
grunt.file.write(config.outfile, output);
done();
});
};

View File

@@ -44,6 +44,7 @@
"devDependencies": {
"browserify": "~2.24.1",
"wrapup": "~0.12.0",
"populist": "~0.1.2",
"grunt-cli": "~0.1.9",
"grunt": "~0.4.1",
"grunt-contrib-copy": "~0.4.1",

View File

@@ -6,6 +6,9 @@ var Ap = Array.prototype;
var slice = Ap.slice;
var Fp = Function.prototype;
var global = Function("return this")();
global.require = require;
if (!Fp.bind) {
// PhantomJS doesn't support Function.prototype.bind natively, so
// polyfill it whenever this module is required.