diff --git a/doc/config.md b/doc/config.md index 299fce87c..a9b0be662 100644 --- a/doc/config.md +++ b/doc/config.md @@ -56,7 +56,6 @@ system: parallelLimit: 3 diffColor: '#ff0000' referenceImageAbsence: 'error' - multiProcess: true coverage: enabled: true exclude: @@ -108,9 +107,6 @@ settings. These settings can not be set per-browser. * `referenceImageAbsence` – treat the cases when a reference image does not exist as `error` or `warning`. Default value is `error`. -* `multiProcess` - if `true` gemini will make few child processes for heavy - operations like image comparison and creating diff images. `true` by default - * `coverage` - `gemini` can gather and report CSS tests coverage. It supports source maps, so you can get the report even if you are using preprocessor or minifier. The JSON and html reports are saved to `gemini-coverage` diff --git a/doc/config.ru.md b/doc/config.ru.md index b5ad1aa4c..ef85460d6 100644 --- a/doc/config.ru.md +++ b/doc/config.ru.md @@ -58,7 +58,6 @@ system: parallelLimit: 3 diffColor: '#ff0000' referenceImageAbsence: 'error' - multiProcess: true coverage: enabled: true exclude: @@ -108,10 +107,6 @@ system: предупреждением (`warning`) или ошибкой (`error`). По-умолчанию ошибка (`error`). -* `multiProcess` - если `true`, то gemini создаст несколько вспомогательных - процессов для выполнения "тяжелых" операций, таких как сравнение изображений - и создание diff-оф. По-умолчанию `true` - * `coverage` - `gemini` может собирать статистику покрытия CSS-кода тестами. Вы можете получить отчет о покрытии даже если используете препроцессоры и минификаторы, поскольку инструмен поддерживает source maps. В этой секции diff --git a/lib/config/options.js b/lib/config/options.js index 2249a0241..7457164ec 100644 --- a/lib/config/options.js +++ b/lib/config/options.js @@ -36,7 +36,6 @@ module.exports = root( plugins: anyObject(), debug: booleanOption(false), - multiProcess: booleanOption(true), parallelLimit: positiveIntegerOption(Infinity), diff --git a/lib/image-processor/index.js b/lib/image-processor/index.js index 634c119d3..b26bc9701 100644 --- a/lib/image-processor/index.js +++ b/lib/image-processor/index.js @@ -3,31 +3,26 @@ var q = require('q'), _ = require('lodash'), inherit = require('inherit'), - compareAdapter = require('./compare-adapter'), - ParallelComporator = require('./parallel-comparator'); + workerFarm = require('worker-farm'), + RunnerEvents = require('../constants/runner-events'); var ImageProcessor = inherit({ - __constructor: function(comparator) { - this._comparator = _.bindAll(comparator); + __constructor: function(emitter) { + this._workers = workerFarm(require.resolve('./compare-adapter'), ['compare', 'buildDiff']); + emitter.on(RunnerEvents.END, function() { + workerFarm.end(this._workers); + }.bind(this)); }, compare: function(path1, path2, opts) { - return q.nfcall(this._comparator.compare, _.extend(opts || {}, { + return q.nfcall(this._workers.compare, _.extend(opts || {}, { path1: path1, path2: path2 })); }, buildDiff: function(opts) { - return q.nfcall(this._comparator.buildDiff, opts); - } -}, { - create: function(config, emitter) { - var comparator = _.get(config, 'system.multiProcess') - ? new ParallelComporator(emitter) - : compareAdapter; - - return new ImageProcessor(comparator); + return q.nfcall(this._workers.buildDiff, opts); } }); diff --git a/lib/image-processor/parallel-comparator.js b/lib/image-processor/parallel-comparator.js deleted file mode 100644 index e3562429e..000000000 --- a/lib/image-processor/parallel-comparator.js +++ /dev/null @@ -1,24 +0,0 @@ -'use strict'; - -var workerFarm = require('worker-farm'), - inherit = require('inherit'), - RunnerEvents = require('../constants/runner-events'); - -var ParallelComporator = inherit({ - __constructor: function(emitter) { - this._workers = workerFarm(require.resolve('./compare-adapter'), ['compare', 'buildDiff']); - emitter.on(RunnerEvents.END, function() { - workerFarm.end(this._workers); - }.bind(this)); - }, - - compare: function() { - return this._workers.compare.apply(this._workers, arguments); - }, - - buildDiff: function() { - return this._workers.buildDiff.apply(this._workers, arguments); - } -}); - -module.exports = ParallelComporator; diff --git a/test/functional/image-processor.test.js b/test/functional/image-processor.test.js index 8e502d448..878603f50 100644 --- a/test/functional/image-processor.test.js +++ b/test/functional/image-processor.test.js @@ -1,9 +1,17 @@ 'use strict'; -var util = require('./util'); +var EventEmitter = require('events').EventEmitter, + util = require('./util'), + ImageProcessor = require('../../lib/image-processor'), + RunnerEvents = require('../../lib/constants/runner-events'); describe('image', function() { - var imageProcessor = require('../../lib/image-processor').create(); + var emitter = new EventEmitter(), + imageProcessor = new ImageProcessor(emitter); + + after(function() { + emitter.emit(RunnerEvents.END); + }); describe('compare', function() { it('should resolve to `true` for equal images', function() { diff --git a/test/functional/util.js b/test/functional/util.js index 5f2aa784a..a4fdc021e 100644 --- a/test/functional/util.js +++ b/test/functional/util.js @@ -1,9 +1,10 @@ 'use strict'; -var fs = require('fs'), +var q = require('q'), + fs = require('fs'), path = require('path'), temp = require('temp'), - imageProcessor = require('../../lib/image-processor').create(); + compareAdapter = require('../../lib/image-processor/compare-adapter'); function imagePath(name) { return path.join(__dirname, 'data', 'image', name); @@ -21,8 +22,11 @@ exports.withTempFile = function(func) { }; exports.assertSameImages = function(refName, filePath) { - return assert.eventually.isTrue(imageProcessor.compare( - imagePath(refName), - filePath - ), 'expected image to be equal to ' + refName); + return assert.eventually.isTrue( + q.nfcall(compareAdapter.compare, { + path1: imagePath(refName), + path2:filePath + }), + 'expected image to be equal to ' + refName + ); };