Skip to content
This repository has been archived by the owner on Sep 21, 2022. It is now read-only.

Commit

Permalink
Removed multiProcess option, always run subprocesses
Browse files Browse the repository at this point in the history
  • Loading branch information
j0tunn committed Dec 7, 2015
1 parent 16ea173 commit bd077bd
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 62 deletions.
4 changes: 0 additions & 4 deletions doc/config.md
Expand Up @@ -56,7 +56,6 @@ system:
parallelLimit: 3
diffColor: '#ff0000'
referenceImageAbsence: 'error'
multiProcess: true
coverage:
enabled: true
exclude:
Expand Down Expand Up @@ -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`
Expand Down
5 changes: 0 additions & 5 deletions doc/config.ru.md
Expand Up @@ -58,7 +58,6 @@ system:
parallelLimit: 3
diffColor: '#ff0000'
referenceImageAbsence: 'error'
multiProcess: true
coverage:
enabled: true
exclude:
Expand Down Expand Up @@ -108,10 +107,6 @@ system:
предупреждением (`warning`) или ошибкой (`error`). По-умолчанию ошибка
(`error`).

* `multiProcess` - если `true`, то gemini создаст несколько вспомогательных
процессов для выполнения "тяжелых" операций, таких как сравнение изображений
и создание diff-оф. По-умолчанию `true`

* `coverage` - `gemini` может собирать статистику покрытия CSS-кода тестами.
Вы можете получить отчет о покрытии даже если используете препроцессоры и
минификаторы, поскольку инструмен поддерживает source maps. В этой секции
Expand Down
4 changes: 2 additions & 2 deletions lib/capture-processor/tester.js
Expand Up @@ -6,7 +6,7 @@ var q = require('q'),
temp = require('temp'),

CaptureProcessor = require('./capture-processor'),
imageProcessor = require('../image-processor'),
ImageProcessor = require('../image-processor'),
NoRefImageError = require('../errors/no-ref-image-error'),

RunnerEvents = require('../constants/runner-events');
Expand All @@ -22,7 +22,7 @@ module.exports = inherit(CaptureProcessor, {
},

prepare: function(emitter) {
this._imageProcessor = imageProcessor.create(this._config, emitter);
this._imageProcessor = new ImageProcessor(emitter);
return fs.makeTree(this._tempDir);
},

Expand Down
1 change: 0 additions & 1 deletion lib/config/options.js
Expand Up @@ -36,7 +36,6 @@ module.exports = root(
plugins: anyObject(),

debug: booleanOption(false),
multiProcess: booleanOption(true),

parallelLimit: positiveIntegerOption(Infinity),

Expand Down
23 changes: 9 additions & 14 deletions lib/image-processor/index.js
Expand Up @@ -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);
}
});

Expand Down
24 changes: 0 additions & 24 deletions lib/image-processor/parallel-comparator.js

This file was deleted.

12 changes: 10 additions & 2 deletions 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() {
Expand Down
9 changes: 5 additions & 4 deletions test/functional/image.test.js
Expand Up @@ -11,9 +11,10 @@ describe('image', function() {
});

it('should return correct size', function() {
var size = this.image.getSize();
assert.equal(size.width, 20);
assert.equal(size.height, 20);
assert.deepEqual(
this.image.getSize(),
{width: 20, height: 20}
);
});

it('should save the image', function() {
Expand All @@ -29,7 +30,7 @@ describe('image', function() {
it('should crop image', function() {
var _this = this;
return util.withTempFile(function(filePath) {
return _this.image.crop({top: 1, left:1, width: 18, height: 18})
return _this.image.crop({top: 1, left: 1, width: 18, height: 18})
.then(function(image) {
return image.save(filePath);
})
Expand Down
16 changes: 10 additions & 6 deletions 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);
Expand All @@ -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
);
};

0 comments on commit bd077bd

Please sign in to comment.