Skip to content

Commit d1a0003

Browse files
authored
Merge pull request #438 from gemini-testing/feat/rm.gemini-core
feat: use looks-same directly instead of gemini-core.Image wrapper
2 parents 88d76fa + 0ed8f83 commit d1a0003

File tree

8 files changed

+367
-149
lines changed

8 files changed

+367
-149
lines changed

lib/gui/tool-runner/index.js

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,6 @@ const {DATABASE_URLS_JSON_NAME, LOCAL_DATABASE_NAME} = require('../../constants/
1818
const {formatId, getShortMD5, mkFullTitle, mergeDatabasesForReuse, filterByEqualDiffSizes} = require('./utils');
1919
const {getTestsTreeFromDatabase} = require('../../db-utils/server');
2020

21-
const lookSameAsync = (img1, img2, opts) => {
22-
return new Promise((resolve, reject) => {
23-
looksSame(img1, img2, opts, (err, data) => {
24-
err ? reject(err) : resolve(data);
25-
});
26-
});
27-
};
28-
2921
module.exports = class ToolRunner {
3022
static create(paths, hermione, configs) {
3123
return new this(paths, hermione, configs);
@@ -135,7 +127,7 @@ module.exports = class ToolRunner {
135127
const equalImages = await Promise.filter(comparedImages, async (image) => {
136128
try {
137129
await Promise.mapSeries(image.diffClusters, async (diffCluster, i) => {
138-
const refComparisonRes = await lookSameAsync(
130+
const refComparisonRes = await looksSame(
139131
{source: this._resolveImgPath(selectedImage.expectedImg.path), boundingBox: selectedImage.diffClusters[i]},
140132
{source: this._resolveImgPath(image.expectedImg.path), boundingBox: diffCluster},
141133
compareOpts
@@ -145,7 +137,7 @@ module.exports = class ToolRunner {
145137
return Promise.reject(false);
146138
}
147139

148-
const actComparisonRes = await lookSameAsync(
140+
const actComparisonRes = await looksSame(
149141
{source: this._resolveImgPath(selectedImage.actualImg.path), boundingBox: selectedImage.diffClusters[i]},
150142
{source: this._resolveImgPath(image.actualImg.path), boundingBox: diffCluster},
151143
compareOpts

lib/test-adapter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ module.exports = class TestAdapter {
377377
return result;
378378
}
379379

380-
//parallelize and cache of 'gemini-core.Image.buildDiff' (because it is very slow)
380+
//parallelize and cache of 'looks-same.createDiff' (because it is very slow)
381381
async _saveDiffInWorker(imageDiffError, destPath, workers, cacheDiffImages = globalCacheDiffImages) {
382382
await utils.makeDirFor(destPath);
383383

lib/workers/worker.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
'use strict';
22

3-
const {Image} = require('gemini-core');
3+
const looksSame = require('looks-same');
44

55
module.exports = {
66
/**
77
* @param {Object} imageDiffError
88
* @param {String} diffPath
99
*/
1010
saveDiffTo: function(imageDiffError, diffPath) {
11-
return Image.buildDiff({diff: diffPath, ...imageDiffError.diffOpts});
11+
const {diffColor: highlightColor, ...otherOpts} = imageDiffError.diffOpts;
12+
13+
return looksSame.createDiff({diff: diffPath, highlightColor, ...otherOpts});
1214
}
1315
};

0 commit comments

Comments
 (0)