From 9af5e9ade4c433128881fea663a25e3bb052cf8f Mon Sep 17 00:00:00 2001 From: oleg Date: Thu, 25 Jun 2015 01:11:49 +0300 Subject: [PATCH] add test helpers for removing dir + small tests fixes --- test/distributor/blocking.js | 5 +++++ test/executor.js | 21 +++++---------------- test/helpers.js | 19 +++++++++++++++++++ 3 files changed, 29 insertions(+), 16 deletions(-) diff --git a/test/distributor/blocking.js b/test/distributor/blocking.js index 0b54ab5..651c147 100644 --- a/test/distributor/blocking.js +++ b/test/distributor/blocking.js @@ -173,4 +173,9 @@ describe('Distributor blocking with max 2 executors count', function() { itRunParallelProjects(); } ); + + after(function() { + Distributor.prototype._createNode.restore(); + }); + }); diff --git a/test/executor.js b/test/executor.js index 63e66fa..5c66f34 100644 --- a/test/executor.js +++ b/test/executor.js @@ -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 || {}; diff --git a/test/helpers.js b/test/helpers.js index 7fac9b8..a8ce36a 100644 --- a/test/helpers.js +++ b/test/helpers.js @@ -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 = [{