Merge pull request #118 from gmetais/phantomas1.13

Merged
This commit is contained in:
Gaël Métais
2015-10-28 21:26:02 +01:00
3 changed files with 59 additions and 47 deletions
+10 -9
View File
@@ -115,6 +115,7 @@ var PhantomasWrapper = function() {
async.retry(triesNumber, function(cb) {
var process = phantomas(task.url, options, function(err, json, results) {
var errorCode = err ? parseInt(err.message, 10) : null;
if (isKilled) {
debug('Process was killed, too late Phantomas, sorry...');
@@ -122,28 +123,28 @@ var PhantomasWrapper = function() {
}
debug('Returning from Phantomas with error %s', err);
debug('Returning from Phantomas with error %s', errorCode);
// Adding some YellowLabTools errors here
if (json && json.metrics && (!json.metrics.javascriptExecutionTree || !json.offenders.javascriptExecutionTree)) {
err = 1001;
errorCode = 1001;
}
if (!err && (!json || !json.metrics)) {
err = 1002;
if (!errorCode && (!json || !json.metrics)) {
errorCode = 1002;
}
// Don't cancel test if it is a timeout and we've got some results
if (err === 252 && json) {
if (errorCode === 252 && json) {
debug('Timeout after ' + options.timeout + ' seconds. But it\'s not a problem, the test is valid.');
err = null;
errorCode = null;
}
if (err) {
debug('Attempt failed. Error code ' + err);
if (errorCode) {
debug('Attempt failed. Error code ' + errorCode);
}
cb(err, json);
cb(errorCode, json);
});
phantomasPid = process.pid;
+29 -25
View File
@@ -1,6 +1,6 @@
{
"name": "yellowlabtools",
"version": "1.8.0",
"version": "1.8.1",
"description": "Online tool to audit a webpage for performance and front-end quality issues",
"license": "GPL-2.0",
"author": {
@@ -15,51 +15,55 @@
"bin": {
"yellowlabtools": "./bin/cli.js"
},
"engines": {
"node": ">= 0.12.0"
},
"main": "./lib/index.js",
"dependencies": {
"angular": "1.4.5",
"angular-animate": "1.4.5",
"angular-chart.js": "0.8.4",
"angular": "1.4.7",
"angular-animate": "1.4.7",
"angular-chart.js": "0.8.5",
"angular-local-storage": "0.2.2",
"angular-resource": "1.4.5",
"angular-route": "1.4.5",
"angular-sanitize": "1.4.5",
"async": "1.4.2",
"body-parser": "1.14.0",
"angular-resource": "1.4.7",
"angular-route": "1.4.7",
"angular-sanitize": "1.4.7",
"async": "1.5.0",
"body-parser": "1.14.1",
"chart.js": "1.0.2",
"clean-css": "3.4.3",
"clean-css": "3.4.6",
"color-diff": "0.1.7",
"compression": "1.5.2",
"compression": "1.6.0",
"cors": "2.7.1",
"debug": "2.2.0",
"express": "4.13.3",
"imagemin": "3.2.0",
"imagemin": "3.2.2",
"imagemin-jpegoptim": "4.0.0",
"jstoxml": "0.2.3",
"lwip": "0.0.7",
"meow": "3.3.0",
"minimize": "1.7.1",
"lwip": "0.0.8",
"meow": "3.4.2",
"minimize": "1.7.4",
"parse-color": "1.0.0",
"phantomas": "1.12.0",
"ps-node": "0.0.4",
"phantomas": "1.13.0",
"ps-node": "0.0.5",
"q": "1.4.1",
"request": "2.62.0",
"request": "2.65.0",
"rimraf": "2.4.3",
"temporary": "0.0.8",
"uglify-js": "2.4.24"
"try-thread-sleep": "1.0.0",
"uglify-js": "2.5.0"
},
"devDependencies": {
"chai": "~3.2.0",
"chai": "~3.4.0",
"grunt": "~0.4.5",
"grunt-blanket": "~0.0.8",
"grunt-contrib-clean": "~0.6.0",
"grunt-contrib-concat": "~0.5.1",
"grunt-contrib-copy": "~0.8.1",
"grunt-contrib-copy": "~0.8.2",
"grunt-contrib-cssmin": "~0.14.0",
"grunt-contrib-htmlmin": "~0.4.0",
"grunt-contrib-htmlmin": "~0.6.0",
"grunt-contrib-jshint": "~0.11.3",
"grunt-contrib-less": "~1.0.1",
"grunt-contrib-uglify": "~0.9.2",
"grunt-contrib-uglify": "~0.10.0",
"grunt-env": "~0.4.4",
"grunt-express": "~1.4.1",
"grunt-filerev": "~2.3.1",
@@ -69,9 +73,9 @@
"grunt-replace": "~0.11.0",
"grunt-usemin": "~3.1.1",
"grunt-webfont": "~0.5.4",
"matchdep": "~0.3.0",
"matchdep": "~1.0.0",
"mocha": "~2.3.2",
"sinon": "~1.16.1",
"sinon": "~1.17.2",
"sinon-chai": "~2.8.0"
},
"scripts": {
+20 -13
View File
@@ -51,11 +51,14 @@ describe('phantomasWrapper', function() {
done('Error: unwanted success');
}).fail(function(err) {
try {
should.exist(err);
err.should.equal(254);
should.exist(err);
err.should.equal(254);
done();
done();
} catch(error) {
done(error);
}
});
});
@@ -72,16 +75,20 @@ describe('phantomasWrapper', function() {
}
}).then(function(data) {
/*jshint -W030 */
data.should.be.an('object');
data.should.have.a.property('generator');
data.generator.should.contain('phantomas');
data.should.have.a.property('url').that.equals(url);
data.should.have.a.property('metrics').that.is.an('object').not.empty;
data.should.have.a.property('offenders').that.is.an('object').not.empty;
data.offenders.should.have.a.property('javascriptExecutionTree').that.is.a('array').not.empty;
done();
try {
data.should.be.an('object');
data.should.have.a.property('generator');
data.generator.should.contain('phantomas');
data.should.have.a.property('url').that.equals(url);
data.should.have.a.property('metrics').that.is.an('object').not.empty;
data.should.have.a.property('offenders').that.is.an('object').not.empty;
data.offenders.should.have.a.property('javascriptExecutionTree').that.is.a('array').not.empty;
done();
} catch(error) {
done(error);
}
}).fail(function(err) {
done(err);
});