11/*global require console setTimeout process Buffer */
22var PORT = 6379 ;
33var HOST = '127.0.0.1' ;
4+ var parser = process . argv [ 3 ] ;
45
5- var redis = require ( "./index" ) ,
6- client = redis . createClient ( PORT , HOST ) ,
7- client2 = redis . createClient ( PORT , HOST ) ,
8- client3 = redis . createClient ( PORT , HOST ) ,
9- bclient = redis . createClient ( PORT , HOST , { return_buffers : true } ) ,
6+ var redis = require ( ".. /index" ) ,
7+ client = redis . createClient ( PORT , HOST , { parser : parser } ) ,
8+ client2 = redis . createClient ( PORT , HOST , { parser : parser } ) ,
9+ client3 = redis . createClient ( PORT , HOST , { parser : parser } ) ,
10+ bclient = redis . createClient ( PORT , HOST , { return_buffers : true , parser : parser } ) ,
1011 assert = require ( "assert" ) ,
1112 crypto = require ( "crypto" ) ,
12- util = require ( "./lib/util" ) ,
13+ util = require ( ".. /lib/util" ) ,
1314 fork = require ( "child_process" ) . fork ,
1415 test_db_num = 15 , // this DB will be flushed and used for testing
1516 tests = { } ,
1617 connected = false ,
1718 ended = false ,
1819 next , cur_start , run_next_test , all_tests , all_start , test_count ;
1920
20-
2121// Set this to truthy to see the wire protocol and other debugging info
22- redis . debug_mode = process . argv [ 2 ] ;
22+ redis . debug_mode = process . argv [ 2 ] ? JSON . parse ( process . argv [ 2 ] ) : false ;
2323
2424function server_version_at_least ( connection , desired_version ) {
2525 // Return true if the server version >= desired_version
@@ -116,7 +116,7 @@ next = function next(name) {
116116// Tests are run in the order they are defined, so FLUSHDB should always be first.
117117
118118tests . IPV4 = function ( ) {
119- var ipv4Client = redis . createClient ( PORT , "127.0.0.1" , { " family" : "IPv4" } ) ;
119+ var ipv4Client = redis . createClient ( PORT , "127.0.0.1" , { family : "IPv4" , parser : parser } ) ;
120120
121121 ipv4Client . once ( "ready" , function start_tests ( ) {
122122 console . log ( "Connected to " + ipv4Client . address + ", Redis server version " + ipv4Client . server_info . redis_version + "\n" ) ;
@@ -142,7 +142,7 @@ tests.IPV6 = function () {
142142 console . log ( "Skipping IPV6 for old Redis server version < 2.8.0" ) ;
143143 return run_next_test ( ) ;
144144 }
145- var ipv6Client = redis . createClient ( PORT , "::1" , { " family" : "IPv6" } ) ;
145+ var ipv6Client = redis . createClient ( PORT , "::1" , { family : "IPv6" , parser : parser } ) ;
146146
147147 ipv6Client . once ( "ready" , function start_tests ( ) {
148148 console . log ( "Connected to " + ipv6Client . address + ", Redis server version " + ipv6Client . server_info . redis_version + "\n" ) ;
@@ -164,7 +164,7 @@ tests.IPV6 = function () {
164164}
165165
166166tests . UNIX_SOCKET = function ( ) {
167- var unixClient = redis . createClient ( '/tmp/redis.sock' ) ;
167+ var unixClient = redis . createClient ( '/tmp/redis.sock' , { parser : parser } ) ;
168168
169169 // if this fails, check the permission of unix socket.
170170 // unixsocket /tmp/redis.sock
@@ -374,7 +374,7 @@ tests.MULTI_7 = function () {
374374 return next ( name ) ;
375375 }
376376
377- var p = require ( "./lib/parser/javascript" ) ;
377+ var p = require ( ".. /lib/parser/javascript" ) ;
378378 var parser = new p . Parser ( false ) ;
379379 var reply_count = 0 ;
380380 function check_reply ( reply ) {
@@ -728,7 +728,7 @@ tests.WATCH_TRANSACTION = function () {
728728
729729
730730tests . detect_buffers = function ( ) {
731- var name = "detect_buffers" , detect_client = redis . createClient ( { detect_buffers : true } ) ;
731+ var name = "detect_buffers" , detect_client = redis . createClient ( { detect_buffers : true , parser : parser } ) ;
732732
733733 detect_client . on ( "ready" , function ( ) {
734734 // single Buffer or String
@@ -795,9 +795,9 @@ tests.detect_buffers = function () {
795795tests . socket_nodelay = function ( ) {
796796 var name = "socket_nodelay" , c1 , c2 , c3 , ready_count = 0 , quit_count = 0 ;
797797
798- c1 = redis . createClient ( { socket_nodelay : true } ) ;
799- c2 = redis . createClient ( { socket_nodelay : false } ) ;
800- c3 = redis . createClient ( ) ;
798+ c1 = redis . createClient ( { socket_nodelay : true , parser : parser } ) ;
799+ c2 = redis . createClient ( { socket_nodelay : false , parser : parser } ) ;
800+ c3 = redis . createClient ( { parser : parser } ) ;
801801
802802 function quit_check ( ) {
803803 quit_count ++ ;
@@ -1158,8 +1158,8 @@ tests.SUBSCRIBE_QUIT = function () {
11581158
11591159tests . SUBSCRIBE_CLOSE_RESUBSCRIBE = function ( ) {
11601160 var name = "SUBSCRIBE_CLOSE_RESUBSCRIBE" ;
1161- var c1 = redis . createClient ( ) ;
1162- var c2 = redis . createClient ( ) ;
1161+ var c1 = redis . createClient ( { parser : parser } ) ;
1162+ var c2 = redis . createClient ( { parser : parser } ) ;
11631163 var count = 0 ;
11641164
11651165 /* Create two clients. c1 subscribes to two channels, c2 will publish to them.
@@ -1955,7 +1955,7 @@ tests.MONITOR = function () {
19551955 return next ( name ) ;
19561956 }
19571957
1958- monitor_client = redis . createClient ( ) ;
1958+ monitor_client = redis . createClient ( { parser : parser } ) ;
19591959 monitor_client . monitor ( function ( err , res ) {
19601960 client . mget ( "some" , "keys" , "foo" , "bar" ) ;
19611961 client . set ( "json" , JSON . stringify ( {
@@ -2056,7 +2056,8 @@ tests.OPTIONAL_CALLBACK_UNDEFINED = function () {
20562056tests . ENABLE_OFFLINE_QUEUE_TRUE = function ( ) {
20572057 var name = "ENABLE_OFFLINE_QUEUE_TRUE" ;
20582058 var cli = redis . createClient ( 9999 , null , {
2059- max_attempts : 1
2059+ max_attempts : 1 ,
2060+ parser : parser
20602061 // default :)
20612062 // enable_offline_queue: true
20622063 } ) ;
@@ -2078,6 +2079,7 @@ tests.ENABLE_OFFLINE_QUEUE_TRUE = function () {
20782079tests . ENABLE_OFFLINE_QUEUE_FALSE = function ( ) {
20792080 var name = "ENABLE_OFFLINE_QUEUE_FALSE" ;
20802081 var cli = redis . createClient ( 9999 , null , {
2082+ parser : parser ,
20812083 max_attempts : 1 ,
20822084 enable_offline_queue : false
20832085 } ) ;
@@ -2134,7 +2136,10 @@ tests.DOMAIN = function () {
21342136 } ) ;
21352137
21362138 // this is the expected and desired behavior
2137- domain . on ( 'error' , function ( err ) { next ( name ) ; } ) ;
2139+ domain . on ( 'error' , function ( err ) {
2140+ domain . exit ( ) ;
2141+ next ( name ) ;
2142+ } ) ;
21382143 }
21392144} ;
21402145
@@ -2143,7 +2148,7 @@ tests.DOMAIN = function () {
21432148tests . auth = function ( ) {
21442149 var name = "AUTH" , client4 , ready_count = 0 ;
21452150
2146- client4 = redis . createClient ( 9006 , "filefish.redistogo.com" ) ;
2151+ client4 = redis . createClient ( 9006 , "filefish.redistogo.com" , { parser : parser } ) ;
21472152 client4 . auth ( "664b1b6aaf134e1ec281945a8de702a9" , function ( err , res ) {
21482153 assert . strictEqual ( null , err , name ) ;
21492154 assert . strictEqual ( "OK" , res . toString ( ) , name ) ;
@@ -2165,7 +2170,7 @@ tests.auth = function () {
21652170tests . auth2 = function ( ) {
21662171 var name = "AUTH2" , client4 , ready_count = 0 ;
21672172
2168- client4 = redis . createClient ( 9006 , "filefish.redistogo.com" , { auth_pass : "664b1b6aaf134e1ec281945a8de702a9" } ) ;
2173+ client4 = redis . createClient ( 9006 , "filefish.redistogo.com" , { auth_pass : "664b1b6aaf134e1ec281945a8de702a9" , parser : parser } ) ;
21692174
21702175 // test auth, then kill the connection so it'll auto-reconnect and auto-re-auth
21712176 client4 . on ( "ready" , function ( ) {
@@ -2204,7 +2209,8 @@ tests.reconnectRetryMaxDelay = function() {
22042209 name = 'reconnectRetryMaxDelay' ,
22052210 reconnecting = false ;
22062211 var client = redis . createClient ( PORT , HOST , {
2207- retry_max_delay : 1
2212+ retry_max_delay : 1 ,
2213+ parser : parser
22082214 } ) ;
22092215 client . on ( 'ready' , function ( ) {
22102216 if ( ! reconnecting ) {
@@ -2223,7 +2229,7 @@ tests.reconnectRetryMaxDelay = function() {
22232229
22242230tests . unref = function ( ) {
22252231 var name = "unref" ;
2226- var external = fork ( "./test-unref.js" ) ;
2232+ var external = fork ( "./test/test -unref.js" ) ;
22272233 var done = false ;
22282234 external . on ( "close" , function ( code ) {
22292235 assert ( code == 0 , "test-unref.js failed" ) ;
@@ -2235,9 +2241,12 @@ tests.unref = function () {
22352241 }
22362242 assert ( done , "test-unref.js didn't finish in time." ) ;
22372243 next ( name ) ;
2238- } , 500 ) ;
2244+ } , 1500 ) ;
22392245} ;
22402246
2247+ // starting to split tests into multiple files.
2248+ require ( './queue-test' ) ( tests , next )
2249+
22412250all_tests = Object . keys ( tests ) ;
22422251all_start = new Date ( ) ;
22432252test_count = 0 ;
0 commit comments