From 2c8d5165a6ed9f55818af5f7e9e07d7851fc030d Mon Sep 17 00:00:00 2001
From: murgatroid99 <michael.lumish@gmail.com>
Date: Mon, 26 Jan 2015 10:41:21 -0800
Subject: [PATCH 1/4] Added node test runner

---
 tools/run_tests/run_node.sh  | 10 ++++++++++
 tools/run_tests/run_tests.py | 18 ++++++++++++++++--
 2 files changed, 26 insertions(+), 2 deletions(-)
 create mode 100644 tools/run_tests/run_node.sh

diff --git a/tools/run_tests/run_node.sh b/tools/run_tests/run_node.sh
new file mode 100644
index 00000000000..76f8a1a4f4e
--- /dev/null
+++ b/tools/run_tests/run_node.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+set -ex
+
+# change to grpc repo root
+cd $(dirname $0)/../..
+
+root=`pwd`
+
+$root/src/node/node_modules/mocha/bin/mocha $root/node/test
diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py
index da849f04cb0..141f1117ab9 100755
--- a/tools/run_tests/run_tests.py
+++ b/tools/run_tests/run_tests.py
@@ -46,8 +46,8 @@ class CLanguage(object):
     self.make_target = make_target
     with open('tools/run_tests/tests.json') as f:
       js = json.load(f)
-      self.binaries = [tgt['name'] 
-                       for tgt in js 
+      self.binaries = [tgt['name']
+                       for tgt in js
                        if tgt['language'] == test_lang]
 
   def test_binaries(self, config):
@@ -59,6 +59,19 @@ class CLanguage(object):
   def build_steps(self):
     return []
 
+class NodeLanguage(object):
+
+  def __init__(self):
+    self.allow_hashing = False
+
+  def test_binaries(self, config):
+    return ['tools/run_tests/run_node.sh']
+
+  def make_targets(self):
+    return []
+
+  def build_steps(self):
+    return [['tools/run_tests/build_node.sh']]
 
 class PhpLanguage(object):
 
@@ -107,6 +120,7 @@ _DEFAULT = ['dbg', 'opt']
 _LANGUAGES = {
     'c++': CLanguage('cxx', 'c++'),
     'c': CLanguage('c', 'c'),
+    'node': NodeLanguage(),
     'php': PhpLanguage(),
     'python': PythonLanguage(),
 }

From 51cab624b8fda39ad1a5709d817f5d82f0edbcd5 Mon Sep 17 00:00:00 2001
From: murgatroid99 <michael.lumish@gmail.com>
Date: Mon, 26 Jan 2015 10:45:49 -0800
Subject: [PATCH 2/4] Added missing server shutdown to interop test runner

---
 src/node/test/interop_sanity_test.js | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/node/test/interop_sanity_test.js b/src/node/test/interop_sanity_test.js
index 8ea48c359f8..6cc7d444cdc 100644
--- a/src/node/test/interop_sanity_test.js
+++ b/src/node/test/interop_sanity_test.js
@@ -48,6 +48,9 @@ describe('Interop tests', function() {
     port = 'localhost:' + server_obj.port;
     done();
   });
+  after(function() {
+    server.shutdown();
+  });
   // This depends on not using a binary stream
   it('should pass empty_unary', function(done) {
     interop_client.runTest(port, name_override, 'empty_unary', true, done);

From 564b944b3cd06e4c19b9b72a7db322801cd4d107 Mon Sep 17 00:00:00 2001
From: murgatroid99 <michael.lumish@gmail.com>
Date: Mon, 26 Jan 2015 11:07:59 -0800
Subject: [PATCH 3/4] Started fixing php test runner

---
 tools/run_tests/build_php.sh | 8 +++-----
 tools/run_tests/run_tests.py | 2 +-
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/tools/run_tests/build_php.sh b/tools/run_tests/build_php.sh
index 6841656bdb8..0a8d0c74923 100755
--- a/tools/run_tests/build_php.sh
+++ b/tools/run_tests/build_php.sh
@@ -2,14 +2,13 @@
 
 set -ex
 
+CONFIG=${CONFIG:-opt}
+
 # change to grpc repo root
 cd $(dirname $0)/../..
 
 root=`pwd`
-export GRPC_LIB_SUBDIR=libs/opt
-
-# make the libraries
-make -j static_c
+export GRPC_LIB_SUBDIR=libs/$CONFIG
 
 # build php
 cd src/php
@@ -18,4 +17,3 @@ cd ext/grpc
 phpize
 ./configure --enable-grpc=$root
 make
-
diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py
index 141f1117ab9..bfe6d7949bc 100755
--- a/tools/run_tests/run_tests.py
+++ b/tools/run_tests/run_tests.py
@@ -82,7 +82,7 @@ class PhpLanguage(object):
     return ['src/php/bin/run_tests.sh']
 
   def make_targets(self):
-    return []
+    return ['static_c']
 
   def build_steps(self):
     return [['tools/run_tests/build_php.sh']]

From c279165f726dedc976fa9a73f1afe700639c6f3e Mon Sep 17 00:00:00 2001
From: murgatroid99 <michael.lumish@gmail.com>
Date: Mon, 26 Jan 2015 11:33:39 -0800
Subject: [PATCH 4/4] Got run_tests.py and node tests working

---
 tools/run_tests/build_node.sh | 7 +++----
 tools/run_tests/run_node.sh   | 2 +-
 tools/run_tests/run_tests.py  | 4 ++--
 3 files changed, 6 insertions(+), 7 deletions(-)
 mode change 100644 => 100755 tools/run_tests/run_node.sh

diff --git a/tools/run_tests/build_node.sh b/tools/run_tests/build_node.sh
index 600b1bde8cd..4b092982b29 100755
--- a/tools/run_tests/build_node.sh
+++ b/tools/run_tests/build_node.sh
@@ -2,19 +2,18 @@
 
 set -ex
 
+CONFIG=${CONFIG:-opt}
+
 # change to grpc repo root
 cd $(dirname $0)/../..
 
 # tells npm install to look for files in that directory
 export GRPC_ROOT=`pwd`
 # tells npm install the subdirectory with library files
-export GRPC_LIB_SUBDIR=libs/opt
+export GRPC_LIB_SUBDIR=libs/$CONFIG
 # tells npm install not to use default locations
 export GRPC_NO_INSTALL=yes
 
-# build the c libraries
-make -j static_c
-
 cd src/node
 
 npm install
diff --git a/tools/run_tests/run_node.sh b/tools/run_tests/run_node.sh
old mode 100644
new mode 100755
index 76f8a1a4f4e..00562959490
--- a/tools/run_tests/run_node.sh
+++ b/tools/run_tests/run_node.sh
@@ -7,4 +7,4 @@ cd $(dirname $0)/../..
 
 root=`pwd`
 
-$root/src/node/node_modules/mocha/bin/mocha $root/node/test
+$root/src/node/node_modules/mocha/bin/mocha $root/src/node/test
diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py
index bfe6d7949bc..4f2f10f15c8 100755
--- a/tools/run_tests/run_tests.py
+++ b/tools/run_tests/run_tests.py
@@ -68,7 +68,7 @@ class NodeLanguage(object):
     return ['tools/run_tests/run_node.sh']
 
   def make_targets(self):
-    return []
+    return ['static_c']
 
   def build_steps(self):
     return [['tools/run_tests/build_node.sh']]
@@ -205,7 +205,7 @@ class TestCache(object):
 def _build_and_run(check_cancelled, newline_on_success, cache):
   """Do one pass of building & running tests."""
   # build latest, sharing cpu between the various makes
-  if not jobset.run(build_steps):
+  if not jobset.run(build_steps, maxjobs=1):
     return 1
 
   # run all the tests