File: 0001-launch_redis-server_during_test.patch

package info (click to toggle)
node-redis 0.12.1-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 628 kB
  • ctags: 502
  • sloc: sh: 22; makefile: 5
file content (46 lines) | stat: -rw-r--r-- 1,414 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
Description: Launch an instance of redis-server during tests
 and kill it at the end.
 .
 Upstream rejected this patch since it requires a more specific
 setup for the machine with the tests running and makes difficult
 run test with different redis-server versions.
Author: Leo Iannacone <l3on@ubuntu.com>
Forwarded: https://github.com/mranney/node_redis/issues/608

---
 test.js |   12 ++++++++++++
 1 file changed, 12 insertions(+)

--- a/test.js
+++ b/test.js
@@ -2,6 +2,16 @@
 var PORT = 6379;
 var HOST = '127.0.0.1';
 
+// redis server child process
+var redis_server_child = require("child_process")
+                         .spawn("redis-server", ["--port", PORT,
+                                                "--unixsocket", "/tmp/redis.sock",
+                                                "--unixsocketperm", 777
+                                                ]);
+redis_server_child.stdout.on('data', function(data) {
+  console.log("[redis-server] " + data);
+});
+
 var redis = require("./index"),
     client = redis.createClient(PORT, HOST),
     client2 = redis.createClient(PORT, HOST),
@@ -2224,6 +2234,7 @@
         client.quit();
         client2.quit();
         bclient.quit();
+        process.exit(0);
     }
 };
 
@@ -2270,4 +2281,5 @@
 process.on('exit', function (code) {
     assert.equal(true, connected);
     assert.equal(true, ended);
+    redis_server_child.kill();
 });