|
@@ -1,7 +1,9 @@
|
|
var async = require('async');
|
|
var async = require('async');
|
|
var Q = require('q');
|
|
var Q = require('q');
|
|
|
|
+var debug = require('debug')('ylt:phantomaswrapper');
|
|
var phantomas = require('phantomas');
|
|
var phantomas = require('phantomas');
|
|
|
|
|
|
|
|
+
|
|
var PhantomasWrapper = function() {
|
|
var PhantomasWrapper = function() {
|
|
'use strict';
|
|
'use strict';
|
|
|
|
|
|
@@ -47,16 +49,16 @@ var PhantomasWrapper = function() {
|
|
};
|
|
};
|
|
|
|
|
|
// Output the command line for debugging purpose
|
|
// Output the command line for debugging purpose
|
|
- console.log('If you want to reproduce the phantomas task only, copy the following command line:');
|
|
|
|
|
|
+ debug('If you want to reproduce the phantomas task only, copy the following command line:');
|
|
var optionsString = '';
|
|
var optionsString = '';
|
|
for (var opt in options) {
|
|
for (var opt in options) {
|
|
optionsString += ' ' + '--' + opt + '=' + options[opt];
|
|
optionsString += ' ' + '--' + opt + '=' + options[opt];
|
|
}
|
|
}
|
|
- console.log('node node_modules/phantomas/bin/phantomas.js --url=' + task.url + optionsString + ' --verbose');
|
|
|
|
|
|
+ debug('node node_modules/phantomas/bin/phantomas.js --url=' + task.url + optionsString + ' --verbose');
|
|
|
|
|
|
// Kill the application if nothing happens for 10 minutes
|
|
// Kill the application if nothing happens for 10 minutes
|
|
var killer = setTimeout(function() {
|
|
var killer = setTimeout(function() {
|
|
- console.log('Killing the app because the test on ' + task.url + ' was launched 10 minutes ago');
|
|
|
|
|
|
+ debug('Killing the app because the test on ' + task.url + ' was launched 10 minutes ago');
|
|
// If in server mode, forever will restart the server
|
|
// If in server mode, forever will restart the server
|
|
process.exit(1);
|
|
process.exit(1);
|
|
}, 600000);
|
|
}, 600000);
|
|
@@ -66,7 +68,7 @@ var PhantomasWrapper = function() {
|
|
|
|
|
|
async.retry(triesNumber, function(cb) {
|
|
async.retry(triesNumber, function(cb) {
|
|
phantomas(task.url, options, function(err, json, results) {
|
|
phantomas(task.url, options, function(err, json, results) {
|
|
- console.log('Returning from Phantomas');
|
|
|
|
|
|
+ debug('Returning from Phantomas');
|
|
|
|
|
|
// Adding some YellowLabTools errors here
|
|
// Adding some YellowLabTools errors here
|
|
if (json && json.metrics && !json.metrics.javascriptExecutionTree) {
|
|
if (json && json.metrics && !json.metrics.javascriptExecutionTree) {
|
|
@@ -79,12 +81,12 @@ var PhantomasWrapper = function() {
|
|
|
|
|
|
// Don't cancel test if it is a timeout and we've got some results
|
|
// Don't cancel test if it is a timeout and we've got some results
|
|
if (err === 252 && json) {
|
|
if (err === 252 && json) {
|
|
- console.log('Timeout after ' + options.timeout + ' seconds. But it\'s not a problem, the test is valid.');
|
|
|
|
|
|
+ debug('Timeout after ' + options.timeout + ' seconds. But it\'s not a problem, the test is valid.');
|
|
err = null;
|
|
err = null;
|
|
}
|
|
}
|
|
|
|
|
|
if (err) {
|
|
if (err) {
|
|
- console.log('Attempt failed. Error code ' + err);
|
|
|
|
|
|
+ debug('Attempt failed. Error code ' + err);
|
|
}
|
|
}
|
|
|
|
|
|
cb(err, json);
|
|
cb(err, json);
|
|
@@ -94,7 +96,7 @@ var PhantomasWrapper = function() {
|
|
clearTimeout(killer);
|
|
clearTimeout(killer);
|
|
|
|
|
|
if (err) {
|
|
if (err) {
|
|
- console.log('All ' + triesNumber + ' attemps failed for the test');
|
|
|
|
|
|
+ debug('All ' + triesNumber + ' attemps failed for the test');
|
|
deferred.reject(err);
|
|
deferred.reject(err);
|
|
} else {
|
|
} else {
|
|
|
|
|