diff --git a/package.json b/package.json index 2332189..741c59a 100644 --- a/package.json +++ b/package.json @@ -119,7 +119,7 @@ "collect-stream": "^1.1.1", "eslint": "^1.10.3", "istanbul": "~0.2.4", - "jsftp": "git://github.com/sergi/jsftp.git#master", + "jsftp": "^2.0.0", "mocha": "^2.3.4", "should": "~3.1.2", "ftp": "^0.3.10" diff --git a/test/cwd-cdup.js b/test/cwd-cdup.js index 3a6d9c0..a0d0b0d 100644 --- a/test/cwd-cdup.js +++ b/test/cwd-cdup.js @@ -41,7 +41,7 @@ describe('CWD/CDUP commands', function() { it('should not change to non-existent directory', function(done) { client.raw('CWD', pathExisting, function(error, response) { response.code.should.equal(250); - server.suppressExpecteErrMsgs.push( + server.suppressExpectedErrMsgs.push( /^CWD \S+: Error: ENOENT/ ); client.raw('CWD', pathExisting, function(error) { diff --git a/test/init.js b/test/init.js index 2a20262..6c15e36 100644 --- a/test/init.js +++ b/test/init.js @@ -38,7 +38,7 @@ describe('initialization', function() { it('should bail if getRoot fails', function(done) { server = common.server({ getRoot: function(connection, callback) { - server.suppressExpecteErrMsgs.push( + server.suppressExpectedErrMsgs.push( 'getRoot signaled error [Error: intentional failure]'); callback(new Error('intentional failure')); }, @@ -85,7 +85,7 @@ describe('initialization', function() { it('should bail if getInitialCwd fails', function(done) { server = common.server({ getInitialCwd: function(connection, callback) { - server.suppressExpecteErrMsgs.push( + server.suppressExpectedErrMsgs.push( 'getInitialCwd signaled error [Error: intentional failure]'); callback(new Error('intentional failure')); }, diff --git a/test/lib/common.js b/test/lib/common.js index e41847b..78d0b35 100644 --- a/test/lib/common.js +++ b/test/lib/common.js @@ -80,12 +80,12 @@ var common = module.exports = { }); }); var origLogIf = server._logIf; - server.suppressExpecteErrMsgs = []; + server.suppressExpectedErrMsgs = []; server._logIf = function logIfNotExpected(verbosity, message, conn) { - var expecteErrMsgs = server.suppressExpecteErrMsgs; + var expectedErrMsgs = server.suppressExpectedErrMsgs; message = String(message).split(fixturesPath).join('fixture:/'); - if ((expecteErrMsgs.length > 0) && (verbosity < LogLevels.LOG_INFO)) { - var expected = expecteErrMsgs.shift(); + if ((expectedErrMsgs.length > 0) && (verbosity < LogLevels.LOG_INFO)) { + var expected = expectedErrMsgs.shift(); if (message === expected) { return; } diff --git a/test/mkd-rmd.js b/test/mkd-rmd.js index 0dee870..e2cbd66 100644 --- a/test/mkd-rmd.js +++ b/test/mkd-rmd.js @@ -22,7 +22,7 @@ describe('MKD/RMD commands', function() { }); it('should not create a duplicate directory', function(done) { - server.suppressExpecteErrMsgs.push( + server.suppressExpectedErrMsgs.push( /^MKD \S+: Error: EEXIST/ ); client.raw('MKD', directory, function(error) { @@ -42,7 +42,7 @@ describe('MKD/RMD commands', function() { }); it('should not delete a non-existent directory', function(done) { - server.suppressExpecteErrMsgs.push( + server.suppressExpectedErrMsgs.push( /^RMD \S+: Error: ENOENT/); client.raw('RMD', directory, function(error) { error.code.should.equal(550); diff --git a/test/normalize_test_logs.sh b/test/normalize_test_logs.sh new file mode 100755 index 0000000..6e84028 --- /dev/null +++ b/test/normalize_test_logs.sh @@ -0,0 +1,24 @@ +#!/bin/bash +# -*- coding: utf-8, tab-width: 2 -*- + + +function normalize_test_logs () { + export LANG{,UAGE}=en_US.UTF-8 # make error messages search engine-friendly + local SELFPATH="$(readlink -m "$BASH_SOURCE"/..)" + + [ "$#" == 0 ] && tty --silent && echo "H: gonna read stdin. consider:" \ + "npm test |& ./test/normalize_test_logs.sh | tee test.log" >&2 + + local MOD_DIR_RX="$(<<<"${SELFPATH%/*/*}" sed -re ' + s~[^A-Za-z0-9_/]~\\&~g')" + + sed -rf <(echo ' + s~^\r~~ + s~'"$MOD_DIR_RX"'/~/…/node_modules/~g + s~(^ +[0-9]+ passing +\()[0-9]+(ms\))~\1###\2~ + ') -- "$@" + return $? +} + + +normalize_test_logs "$@"; exit $? diff --git a/test/pass.js b/test/pass.js index c900b7f..a7f46cc 100644 --- a/test/pass.js +++ b/test/pass.js @@ -23,9 +23,9 @@ describe('PASS command', function() { client = new Client(options); client.auth(options.user, badPass, function(error) { error.code.should.eql(530); - client.raw.user(options.user, function(error, reply) { + client.raw('user', options.user, function(error, reply) { reply.code.should.eql(331); - client.raw.pass(badPass, function(error) { + client.raw('pass', badPass, function(error) { error.code.should.eql(530); done(); }); @@ -35,7 +35,7 @@ describe('PASS command', function() { it('should reject PASS without USER', function(done) { client = new Client(options); - client.raw.pass(options.pass, function(error) { + client.raw('pass', options.pass, function(error) { error.code.should.eql(503); done(); }); diff --git a/test/pwd.js b/test/pwd.js index 4508784..095795f 100644 --- a/test/pwd.js +++ b/test/pwd.js @@ -30,7 +30,7 @@ describe('PWD command', function() { }); it('should be "' + directory + '"', function(done) { - client.raw.pwd(function(error, reply) { + client.raw('pwd', function(error, reply) { common.should.not.exist(error); reply.code.should.equal(257); reply.text.should.startWith('257 "' + directory + '"'); @@ -39,7 +39,7 @@ describe('PWD command', function() { }); it('should reject parameters', function(done) { - client.raw.pwd(directory, function(error, reply) { + client.raw('pwd', directory, function(error, reply) { error.code.should.equal(501); reply.code.should.equal(501); done(); @@ -64,7 +64,7 @@ describe('PWD command', function() { }); it('should be "/"', function(done) { - client.raw.pwd(function(error, reply) { + client.raw('pwd', function(error, reply) { common.should.not.exist(error); reply.code.should.equal(257); reply.text.should.startWith('257 "/"'); diff --git a/test/tricky-paths.js b/test/tricky-paths.js index aa3d6c4..8631c35 100644 --- a/test/tricky-paths.js +++ b/test/tricky-paths.js @@ -38,7 +38,7 @@ describe('Tricky paths', function() { async.waterfall([ function strangePathRedundantEscape(nxt) { var dirRfcQuoted = dirPath.replace(/"/g, '""'); - server.suppressExpecteErrMsgs.push( + server.suppressExpectedErrMsgs.push( /^CWD [\S\s]+: Error: ENOENT/ ); client.raw('CWD', dirRfcQuoted, function(error) { diff --git a/test/user.js b/test/user.js index e5447dc..9790ea6 100644 --- a/test/user.js +++ b/test/user.js @@ -24,7 +24,7 @@ describe('USER command', function() { client = new Client(options); client.auth(options.user, options.pass, function(error) { error.code.should.eql(530); - client.raw.user(options.user, function(error) { + client.raw('user', options.user, function(error) { error.code.should.eql(530); done(); }); @@ -37,7 +37,7 @@ describe('USER command', function() { client = new Client(options); client.auth(badUser, options.pass, function(error) { error.code.should.eql(530); - client.raw.user(badUser, function(error) { + client.raw('user', badUser, function(error) { error.code.should.eql(530); done(); });