-
Notifications
You must be signed in to change notification settings - Fork 607
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…571) * Execute each images comparison in a separate child processes (#561) * Do not use the logger in the comparison child processes (#561)
- Loading branch information
Showing
2 changed files
with
49 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,30 @@ | ||
var compareHashes = require('./compare-hash'); | ||
var compareResemble = require('./compare-resemble'); | ||
var storeFailedDiff = require('./store-failed-diff.js'); | ||
|
||
module.exports = function (referencePath, testPath, misMatchThreshold, resembleOutputSettings, requireSameDimensions) { | ||
return compareHashes(referencePath, testPath) | ||
.catch(() => compareResemble(referencePath, testPath, misMatchThreshold, resembleOutputSettings, requireSameDimensions)); | ||
process.on('message', compare); | ||
|
||
function compare (data) { | ||
var {referencePath, testPath, resembleOutputSettings, pair} = data; | ||
var promise = compareHashes(referencePath, testPath) | ||
.catch(() => compareResemble(referencePath, testPath, pair.misMatchThreshold, resembleOutputSettings, pair.requireSameDimensions)); | ||
promise | ||
.then(function (data) { | ||
pair.diff = data; | ||
pair.status = 'pass'; | ||
return sendMessage(pair); | ||
}) | ||
.catch(function (data) { | ||
pair.diff = data; | ||
pair.status = 'fail'; | ||
|
||
return storeFailedDiff(testPath, data).then(function (compare) { | ||
pair.diffImage = compare; | ||
return sendMessage(pair); | ||
}); | ||
}); | ||
}; | ||
|
||
function sendMessage (data) { | ||
process.send(data); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters