Permalink
Browse files

Simplify collecting testbuilders.

  • Loading branch information...
1 parent 4190ea7 commit 235e068b4dbca0a8dd04911ab50d58bb6857db0e @tobie committed Sep 25, 2010
Showing with 9 additions and 18 deletions.
  1. +9 −18 lib/builder/suiteBuilder.js
@@ -8,20 +8,17 @@ var ASSETS_PATH = path.normalize(path.join(__dirname, '..', '..', 'assets'));
exports.createSuiteBuilder = createSuiteBuilder;
function createSuiteBuilder(config) {
- var self = {}, testFiles, testPageBuilders = [];
+ var self = {}, testFiles, builders = [];
self.build = build;
function build(callback) {
- async.compose([
+ builders.length = 0;
+ async.compose([
_rmdirOutput,
_mkdirOutput,
_mkdirsOutputStructure,
_collectTestFiles,
_buildTestPages,
- function(builders, callback) {
- _setTestBuilders(builders);
- callback(null);
- },
_createManifest,
_cpIndex,
_cpAssets
@@ -51,23 +48,17 @@ function createSuiteBuilder(config) {
}
function _buildTestPages(files, callback) {
- async.map(files, function(file, i, files, callback) {
- testPageBuilder.build(file, config, callback);
+ async.forEach(files, function(file, i, files, callback) {
+
+ var builder = testPageBuilder.createTestPage(file, config);
+ builders.push(builder);
+ builder.build(callback);
}, null, callback);
}
- function _getTestBuilders() {
- return testPageBuilders;
- }
-
- function _setTestBuilders(builders) {
- testPageBuilders.length = 0;
- testPageBuilders.push.apply(testPageBuilders, builders);
- }
-
function _createManifest(callback) {
var files = [];
- _getTestBuilders().forEach(function(builder) {
+ builders.forEach(function(builder) {
files.push.apply(files, builder.getPages());
});
fs.writeFile(config.manifest, JSON.stringify(files), 'utf8', callback);

0 comments on commit 235e068

Please sign in to comment.