add test helpers for removing dir + small tests fixes

This commit is contained in:
oleg 2015-06-25 01:11:49 +03:00
parent 827c3d4888
commit 9af5e9ade4
3 changed files with 29 additions and 16 deletions

View File

@ -173,4 +173,9 @@ describe('Distributor blocking with max 2 executors count', function() {
itRunParallelProjects(); itRunParallelProjects();
} }
); );
after(function() {
Distributor.prototype._createNode.restore();
});
}); });

View File

@ -2,30 +2,19 @@
var expect = require('expect.js'), var expect = require('expect.js'),
path = require('path'), path = require('path'),
fs = require('fs'),
createExecutor = require('../lib/executor').createExecutor, createExecutor = require('../lib/executor').createExecutor,
SpawnCommand = require('../lib/command/spawn').Command,
_ = require('underscore'), _ = require('underscore'),
mercurialRevs = _(require('./helpers').mercurialRevs).clone(); helpers = require('./helpers'),
mercurialRevs = helpers.mercurialRevs;
['local'].forEach(function(type) { ['local'].forEach(function(type) {
describe(type + ' executor', function() { describe(type + ' executor', function() {
var workspacePath = path.join(__dirname, 'workspace'); var workspacePath = path.join(__dirname, 'workspace');
var removeDir = function (dir, callback) { var clearWorkspace = function(done) {
new SpawnCommand().run({cmd: 'rm', args: ['-R', dir]}, callback); helpers.removeDirIfExists(workspacePath, done);
} };
var clearWorkspace = function (done) {
if (fs.exists(workspacePath, function(isExists) {
if (isExists) {
removeDir(workspacePath, done);
} else {
done();
}
}));
}
var makeExecutorParams = function(params) { var makeExecutorParams = function(params) {
params = params || {}; params = params || {};

View File

@ -1,5 +1,24 @@
'use strict'; 'use strict';
var SpawnCommand = require('../lib/command/spawn').Command,
fs = require('fs');
exports.removeDir = function(dir, callback) {
new SpawnCommand().run({cmd: 'rm', args: ['-R', dir]}, callback);
};
exports.removeDirIfExists = function(dir, done) {
if (fs.exists(dir, function(isExists) {
if (isExists) {
exports.removeDir(dir, done);
} else {
done();
}
}));
};
// revisions for the test mercurial repo // revisions for the test mercurial repo
exports.mercurialRevs = [{ exports.mercurialRevs = [{