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();
}
);
after(function() {
Distributor.prototype._createNode.restore();
});
});

View File

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

View File

@ -1,5 +1,24 @@
'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
exports.mercurialRevs = [{