diff --git a/lib/collector.js b/lib/collector.js index e282aca2b..873183f72 100644 --- a/lib/collector.js +++ b/lib/collector.js @@ -78,6 +78,12 @@ Collector.prototype.createAggregates = function() { return aggregates; }; +Collector.prototype.clear = function() { + collectors.forEach(function(c) { + c.clear(); + }); +}; + Collector.prototype.createCollections = function() { var collections = {}; diff --git a/lib/collectors/assets.js b/lib/collectors/assets.js index a43582a6c..5de06a67b 100644 --- a/lib/collectors/assets.js +++ b/lib/collectors/assets.js @@ -43,3 +43,7 @@ exports.generateResults = function() { list: values }; }; + +exports.clear = function() { + assets = {}; +}; diff --git a/lib/collectors/pages.js b/lib/collectors/pages.js index a2434b2b5..0ac401516 100644 --- a/lib/collectors/pages.js +++ b/lib/collectors/pages.js @@ -235,3 +235,7 @@ exports.generateResults = function() { list: pages }; }; + +exports.clear = function() { + pages = []; +}; diff --git a/lib/runner.js b/lib/runner.js index 3d8e4aaf9..6bad77d97 100644 --- a/lib/runner.js +++ b/lib/runner.js @@ -109,6 +109,7 @@ Runner.prototype._setupConfigurationForSite = function(args, cb) { "yyyy-mm-dd-HH-MM-ss"), config.urlObject.hostname); // setup the directories needed var dataDir = path.join(config.run.absResultDir, config.dataDir); + fs.mkdirs(dataDir, function(err) { if (err) { log.log('error', "Couldn't create the data dir:" + dataDir + ' ' + err); @@ -333,6 +334,14 @@ Runner.prototype._createOutput = function (downloadErrors, analysisErrors, callB } }, function(err, results) { + + // TODO this can be cleaner + // We clear the number of pages tested and + // the collected data, so it is ready for next run + // used when testing multiple sites + self.htmlRenderer.numberOfAnalyzedPages = 0; + self.collector.clear(); + if (!err) log.log('info', "Wrote results to " + config.run.absResultDir); callBack();