1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-04 15:02:09 +03:00

Test windows fixes

Replace win-spawn with cross-spawn
This commit is contained in:
Ruben Bridgewater
2016-03-07 23:37:30 +01:00
parent 7ffba03be6
commit 20128fe779
6 changed files with 17 additions and 33 deletions

View File

@ -43,7 +43,7 @@
"optional-dev-dependency": "^1.1.0",
"tcp-port-used": "^0.1.2",
"uuid": "^2.0.1",
"win-spawn": "^2.0.0"
"cross-spawn": "^2.1.5"
},
"repository": {
"type": "git",

View File

@ -5,13 +5,9 @@ var config = require('./lib/config');
var helper = require('./helper');
var redis = config.redis;
if (process.platform === 'win32') {
// TODO: Fix redis process spawn on windows
return;
}
describe('client authentication', function () {
before(function (done) {
this.timeout(25000);
helper.stopRedis(function () {
helper.startRedis('./conf/password.conf', done);
});
@ -286,6 +282,7 @@ describe('client authentication', function () {
after(function (done) {
if (helper.redisProcess().spawnFailed()) return done();
this.timeout(25000);
helper.stopRedis(function () {
helper.startRedis('./conf/redis.conf', done);
});

View File

@ -8,16 +8,12 @@ var rp;
var path = require('path');
var redis = config.redis;
if (process.platform === 'win32') {
// TODO: Fix redis process spawn on windows
return;
}
describe('master slave sync', function () {
var master = null;
var slave = null;
before(function (done) {
this.timeout(25000);
helper.stopRedis(function () {
helper.startRedis('./conf/password.conf', done);
});
@ -40,6 +36,7 @@ describe('master slave sync', function () {
it('sync process and no master should delay ready being emitted for slaves', function (done) {
if (helper.redisProcess().spawnFailed()) this.skip();
if (process.platform === 'win32') this.timeout(25000);
var port = 6381;
var firstInfo;
@ -85,6 +82,7 @@ describe('master slave sync', function () {
after(function (done) {
if (helper.redisProcess().spawnFailed()) return done();
this.timeout(25000);
var end = helper.callFuncAfter(done, 3);
rp.stop(end);
slave.end(true);

View File

@ -15,11 +15,6 @@ function startRedis (conf, done, port) {
}, path.resolve(__dirname, conf), port);
}
// don't start redis every time we
// include this helper file!
if (!process.env.REDIS_TESTS_STARTED) {
process.env.REDIS_TESTS_STARTED = true;
before(function (done) {
startRedis('./conf/redis.conf', done);
});
@ -27,7 +22,6 @@ if (!process.env.REDIS_TESTS_STARTED) {
after(function (done) {
if (rp) rp.stop(done);
});
}
module.exports = {
redisProcess: function () {

View File

@ -4,15 +4,13 @@
var config = require('./config');
var fs = require('fs');
var path = require('path');
var spawn = require('win-spawn');
var spawn = require('cross-spawn');
var tcpPortUsed = require('tcp-port-used');
var bluebird = require('bluebird');
// wait for redis to be listening in
// all three modes (ipv4, ipv6, socket).
function waitForRedis (available, cb, port) {
if (process.platform === 'win32') return cb();
var time = Date.now();
var running = false;
var socket = '/tmp/redis.sock';
@ -29,14 +27,14 @@ function waitForRedis (available, cb, port) {
tcpPortUsed.check(port, '::1'),
function (ipV4, ipV6) {
if (ipV6 === available && ipV4 === available) {
if (fs.existsSync(socket) === available) {
if (fs.existsSync(socket) === available || process.platform === 'win32') {
clearInterval(id);
return cb();
}
// The same message applies for can't stop but we ignore that case
throw new Error('Port ' + port + ' is already in use. Tests can\'t start.\n');
}
if (Date.now() - time > 6000) {
if (Date.now() - time > 24000) {
throw new Error('Redis could not start on port ' + (port || config.PORT) + '\n');
}
running = false;

View File

@ -5,13 +5,9 @@ var config = require('./lib/config');
var helper = require('./helper');
var redis = config.redis;
if (process.platform === 'win32') {
// TODO: Fix redis process spawn on windows
return;
}
describe('rename commands', function () {
before(function (done) {
this.timeout(25000);
helper.stopRedis(function () {
helper.startRedis('./conf/rename.conf', done);
});
@ -140,6 +136,7 @@ describe('rename commands', function () {
after(function (done) {
if (helper.redisProcess().spawnFailed()) return done();
this.timeout(25000);
helper.stopRedis(function () {
helper.startRedis('./conf/redis.conf', done);
});