Permalink
Browse files

Remove graphicsmagick as a dependency.

Launching a new process per test is possibly expensive. Let's all do it in JS
instead. (See https://www.destroyallsoftware.com/talks/a-whole-new-world)
  • Loading branch information...
1 parent e09e767 commit 980fc66f85b0589a9c859c0ab418017b400eac38 @oliverzheng committed May 23, 2015
View
@@ -3,7 +3,6 @@ node_js:
- "0.10"
before_install:
- npm install -g bower && bower install
- - sudo apt-get install -y graphicsmagick
before_script: npm run build-minify
deploy:
provider: s3
@@ -83,10 +83,12 @@ class Method {
getTextContent(): mixed {
if (this._addIDs) {
// TODO rename addIDs to "isTest" or something
- // These IIs have the least variance in font rendering. Even if the fonts
+ // This 'I' has the least variance in font rendering. Even if the fonts
// shift up and down, the majority of the text still occupy the same
- // space.
- return 'IIIIII';
+ // space. Only 1 character is used, because Windows and Mac render the
+ // same text with different spacing.
+ // See http://fmforums.com/forum/topic/79795-cross-platform-fonts-revisited-arial-vs-verdana/
+ return 'I';
}
return 'Text Content';
}
View
@@ -4,12 +4,12 @@ require('colors');
var _ = require('underscore');
var fs = require('fs');
var wd = require('wd');
-var wdScreenshot = require('wd-screenshot')({
- tolerance: 0.003, // browser text rendering variances
-});
+var BlinkDiff = require('blink-diff');
var jsStringEscape = require('js-string-escape')
var chai = require('chai');
var invariant = require('invariant');
+var tmp = require('tmp');
+var Q = require('q');
var chaiAsPromised = require('chai-as-promised');
var findMethod = require('../how/findMethod');
@@ -34,7 +34,6 @@ wd.configureHttp({
retryDelay: 15000,
retries: 5
});
-wdScreenshot.addFunctions(wd);
var remoteConfig = undefined;
var browserMappings;
@@ -58,6 +57,9 @@ var allTests = testMatrix.generateTestsForSeleniumBrowsers(
enumerateAllBrowserSupports
);
+// browser text rendering variances
+var SCREENSHOT_TOLERANCE = 0.000003;
+
var WINDOW_WIDTH = 400;
var WINDOW_HEIGHT = 400;
@@ -152,11 +154,44 @@ allTests.forEach(seleniumTests => {
var res =
b.execute(cssJS + insertJS);
+ var referenceFilename = getReferenceFilename(t);
if (isCreatingSnapshots) {
- res = res.saveScreenshot(getReferenceFilename(t));
+ res = res.saveScreenshot(referenceFilename);
fs.writeFileSync(getReferenceHTMLFilename(t), css + html);
} else {
- res = res.compareWithReferenceScreenshot(getReferenceFilename(t));
+ var tmpFilename = tmp.tmpNameSync({
+ // for finding it easier in Finder
+ prefix: 'screenshot-' + Date.now() + '-' + testName + '-',
+ postfix: '.png',
+ });
+ res = res
+ .saveScreenshot(tmpFilename)
+ .then(() => {
+ var blinkDiff = new BlinkDiff({
+ imageAPath: referenceFilename,
+ imageBPath: tmpFilename,
+ thresholdType: BlinkDiff.THRESHOLD_PERCENT,
+ });
+ return Q.ninvoke(blinkDiff, 'run');
+ })
+ .then(result => {
+ var diff = result.differences / result.dimension;
+ var pass = diff < SCREENSHOT_TOLERANCE;
+ var deferred = Q.defer();
+ if (pass) {
+ fs.unlinkSync(tmpFilename);
+ deferred.resolve(diff);
+ } else {
+ deferred.reject(
+ tmpFilename +
+ ' is not equal to reference ' +
+ referenceFilename +
+ ', diff: ' + diff +
+ ', tolerance: ' + SCREENSHOT_TOLERANCE
+ );
+ }
+ return deferred.promise;
+ });
}
res.nodeify(done);
});
@@ -264,18 +264,18 @@ function getTestName(test: Test): string {
browserSupport,
} = test;
- var name = getSnapshotName(test) + ' ';
+ var name = getSnapshotName(test) + '_';
if (!browserSupport || browserSupport.browserVersionsRequired.length === 0) {
- name += 'support all browsers';
+ name += 'support_all_browsers';
} else {
name += browserSupport.browserVersionsRequired.map(
browserVersionRequired => {
var name = browserVersionRequired.browser.shortName;
if (browserVersionRequired.minVersion) {
- name += ' minVer=' + browserVersionRequired.minVersion;
+ name += '_minVer_' + browserVersionRequired.minVersion;
} else {
- name += ' no-support';
+ name += '_no-support';
}
return name;
}
View
@@ -67,9 +67,10 @@
"js-string-escape": "^1.0.0",
"keymirror": "^0.1.1",
"mocha": "^2.2.4",
- "q": "^1.3.0",
+ "q": "^1.4.1",
"react-tools": "^0.13.2",
"shortid": "^2.1.3",
+ "tmp": "0.0.26",
"uglifycss": "0.0.13",
"underscore": "^1.8.3",
"wd": "^0.3.11",
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 980fc66

Please sign in to comment.