|
@@ -19,6 +19,7 @@ var PhantomasWrapper = function() {
|
|
|
|
|
|
|
|
|
var options = {
|
|
|
+
|
|
|
// Cusomizable options
|
|
|
'timeout': task.options.timeout || 45,
|
|
|
'js-deep-analysis': task.options.jsDeepAnalysis || false,
|
|
@@ -75,34 +76,52 @@ var PhantomasWrapper = function() {
|
|
|
}
|
|
|
debug('node node_modules/phantomas/bin/phantomas.js --url=' + task.url + optionsString + ' --verbose');
|
|
|
|
|
|
- // Kill the application if nothing happens
|
|
|
+
|
|
|
var phantomasPid;
|
|
|
+ var isKilled = false;
|
|
|
+
|
|
|
+ // Kill phantomas if nothing happens
|
|
|
var killer = setTimeout(function() {
|
|
|
- debug('Killing the app because the test on %s was launched %d seconds ago', task.url, 5*options.timeout);
|
|
|
- // If in server mode, forever will restart the server
|
|
|
+ console.log('Killing phantomas because the test on ' + task.url + ' was launched ' + 5*options.timeout + ' seconds ago');
|
|
|
|
|
|
- // Kill the Phantomas process first
|
|
|
if (phantomasPid) {
|
|
|
ps.kill(phantomasPid, function(err) {
|
|
|
+
|
|
|
if (err) {
|
|
|
debug('Could not kill Phantomas process %s', phantomasPid);
|
|
|
+
|
|
|
+ // Suicide
|
|
|
+ process.exit(1);
|
|
|
+ // If in server mode, forever will restart the server
|
|
|
}
|
|
|
- else {
|
|
|
- debug('Phantomas process %s was correctly killed', phantomasPid);
|
|
|
- }
|
|
|
|
|
|
- // Then suicide.
|
|
|
- process.exit(1);
|
|
|
+ debug('Phantomas process %s was correctly killed', phantomasPid);
|
|
|
+
|
|
|
+ // Then mark the test as failed
|
|
|
+ // Error 1003 = Phantomas not answering
|
|
|
+ deferred.reject(1003);
|
|
|
+ isKilled = true;
|
|
|
});
|
|
|
+ } else {
|
|
|
+ // Suicide
|
|
|
+ process.exit(1);
|
|
|
}
|
|
|
|
|
|
}, 5*options.timeout*1000);
|
|
|
|
|
|
+
|
|
|
// It's time to launch the test!!!
|
|
|
var triesNumber = 2;
|
|
|
|
|
|
async.retry(triesNumber, function(cb) {
|
|
|
var process = phantomas(task.url, options, function(err, json, results) {
|
|
|
+
|
|
|
+ if (isKilled) {
|
|
|
+ debug('Process was killed, too late Phantomas, sorry...');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
debug('Returning from Phantomas');
|
|
|
|
|
|
// Adding some YellowLabTools errors here
|