mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
Test result outputs
This commit is contained in:
parent
64c993f2fe
commit
1e8fffa2c9
1
.gitignore
vendored
1
.gitignore
vendored
@ -13,3 +13,4 @@ node_modules/
|
|||||||
server.js
|
server.js
|
||||||
*.sublime-workspace
|
*.sublime-workspace
|
||||||
chromedriver.log
|
chromedriver.log
|
||||||
|
.baseline
|
1
tests/results/chrome-23.0.1271.97-windows-vista.json
Normal file
1
tests/results/chrome-23.0.1271.97-windows-vista.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"tests":{"cases/background/encoded.html":98,"cases/background/linear-gradient.html":82.27},"date":"2012-12-28T16:48:04.248Z","version":"23.0.1271.97"}
|
@ -0,0 +1 @@
|
|||||||
|
{"tests":{"cases/background/encoded.html":100,"cases/background/linear-gradient.html":82.27},"date":"2012-12-28T17:20:56.098Z","version":"23.0.1271.97"}
|
1
tests/results/chrome.json
Normal file
1
tests/results/chrome.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"tests":{"cases/background/encoded.html":100,"cases/background/linear-gradient.html":82.27},"date":"2012-12-28T16:48:04.248Z","version":"23.0.1271.97"}
|
1
tests/results/firefox-12.0-windows-vista.json
Normal file
1
tests/results/firefox-12.0-windows-vista.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"tests":{"cases/background/encoded.html":100,"cases/background/linear-gradient.html":92.64},"date":"2012-12-28T16:48:10.772Z","version":"12.0"}
|
1
tests/results/firefox.json
Normal file
1
tests/results/firefox.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"tests":{"cases/background/encoded.html":100,"cases/background/linear-gradient.html":85.64},"date":"2012-12-28T16:48:10.772Z","version":"12.0"}
|
1
tests/results/iexplorer-9-windows-vista.json
Normal file
1
tests/results/iexplorer-9-windows-vista.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"tests":{"cases/background/encoded.html":100,"cases/background/linear-gradient.html":100},"date":"2012-12-28T16:48:04.855Z","version":"9"}
|
1
tests/results/iexplorer.json
Normal file
1
tests/results/iexplorer.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"tests":{"cases/background/encoded.html":100,"cases/background/linear-gradient.html":100},"date":"2012-12-28T16:48:04.855Z","version":"9"}
|
@ -1,3 +1,5 @@
|
|||||||
|
(function(){
|
||||||
|
"use strict;"
|
||||||
var webdriver = require("webdriver.js").webdriver,
|
var webdriver = require("webdriver.js").webdriver,
|
||||||
http = require("http"),
|
http = require("http"),
|
||||||
url = require("url"),
|
url = require("url"),
|
||||||
@ -6,7 +8,6 @@ base64_arraybuffer = require('base64-arraybuffer'),
|
|||||||
PNG = require('png-js'),
|
PNG = require('png-js'),
|
||||||
fs = require("fs");
|
fs = require("fs");
|
||||||
|
|
||||||
|
|
||||||
function createServer(port) {
|
function createServer(port) {
|
||||||
return http.createServer(function(request, response) {
|
return http.createServer(function(request, response) {
|
||||||
var uri = url.parse(request.url).pathname,
|
var uri = url.parse(request.url).pathname,
|
||||||
@ -98,6 +99,72 @@ function testPage(browser, url, done) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var writeResultFile = function(filename, json, append) {
|
||||||
|
fs.writeFile(filename + (append || ""), json);
|
||||||
|
};
|
||||||
|
|
||||||
|
var openResultFile = function(stats, browser) {
|
||||||
|
var tests = stats[browser].tests,
|
||||||
|
filename = "results/" + browser + ".json",
|
||||||
|
write = writeResultFile.bind(null, filename, JSON.stringify(stats[browser]));
|
||||||
|
|
||||||
|
fs.exists(filename, function(exists) {
|
||||||
|
if(exists) {
|
||||||
|
fs.readFile(filename, "binary", parseResultFile.bind(null, tests, browser, write));
|
||||||
|
} else {
|
||||||
|
write();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
var setColor = function(color, text) {
|
||||||
|
return color + text.amount + "% " + text.test;
|
||||||
|
};
|
||||||
|
|
||||||
|
var parseResultFile = function(tests, browser, createResultFile, err, file) {
|
||||||
|
if (err) throw err;
|
||||||
|
var data = JSON.parse(file),
|
||||||
|
improved = [],
|
||||||
|
colors = {
|
||||||
|
red: "\x1b[1;31m",
|
||||||
|
green: "\x1b[0;32m"
|
||||||
|
},
|
||||||
|
regressed = [];
|
||||||
|
|
||||||
|
Object.keys(tests).forEach(function(test){
|
||||||
|
var testResult = tests[test],
|
||||||
|
dataResult = data.tests[test],
|
||||||
|
dataObject = {
|
||||||
|
amount: testResult - dataResult,
|
||||||
|
test: test
|
||||||
|
};
|
||||||
|
|
||||||
|
if (testResult > dataResult) {
|
||||||
|
improved.push(dataObject);
|
||||||
|
} else if (testResult < dataResult) {
|
||||||
|
regressed.push(dataObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
if (improved.length > 0 || regressed.length > 0) {
|
||||||
|
if (regressed.length === 0) {
|
||||||
|
createResultFile(".baseline");
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log((regressed.length > 0) ? colors.red : colors.green, browser);
|
||||||
|
|
||||||
|
improved.map(setColor.bind(null, colors.green)).concat(regressed.map(setColor.bind(null, colors.red))).forEach(function(item) {
|
||||||
|
console.log(" *", item);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
function handleResults(stats) {
|
||||||
|
Object.keys(stats).forEach(openResultFile.bind(null, stats));
|
||||||
|
}
|
||||||
|
|
||||||
function runBrowsers(pages){
|
function runBrowsers(pages){
|
||||||
|
|
||||||
var port = 5555,
|
var port = 5555,
|
||||||
@ -110,7 +177,7 @@ function runBrowsers(pages){
|
|||||||
var browserDone = function() {
|
var browserDone = function() {
|
||||||
if (++browsersDone >= browsers.length) {
|
if (++browsersDone >= browsers.length) {
|
||||||
server.close();
|
server.close();
|
||||||
console.log(stats);
|
handleResults(stats);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -119,13 +186,14 @@ function runBrowsers(pages){
|
|||||||
browser: browserName
|
browser: browserName
|
||||||
}),
|
}),
|
||||||
browserType;
|
browserType;
|
||||||
|
browserName = browserName.replace("internet explorer", "iexplorer");
|
||||||
browser.status(function(browserInfo){
|
browser.status(function(browserInfo){
|
||||||
browserType = [browserName, browser.version, browserInfo.os.name.replace(/\s+/g, "-").toLowerCase()].join("-");
|
browserType = [browserName, browser.version, browserInfo.os.name.replace(/\s+/g, "-").toLowerCase()].join("-");
|
||||||
var date = new Date(),
|
var date = new Date(),
|
||||||
obj = {
|
obj = {
|
||||||
tests: {},
|
tests: {},
|
||||||
date: date.toISOString()
|
date: date.toISOString(),
|
||||||
|
version: browser.version
|
||||||
};
|
};
|
||||||
stats[browserType] = obj;
|
stats[browserType] = obj;
|
||||||
stats[browserName] = obj;
|
stats[browserName] = obj;
|
||||||
@ -149,6 +217,7 @@ function runBrowsers(pages){
|
|||||||
|
|
||||||
walkDir("cases", function(err, results) {
|
walkDir("cases", function(err, results) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
runBrowsers(results);
|
runBrowsers(results.slice(0, 2));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
})();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user