Bug 1296280 (part 0b) - Make debugging node h2 server work better r?mcmanus draft
authorNicholas Hurley <hurley@todesschaf.org>
Wed, 07 Sep 2016 09:43:47 -0700
changeset 414561 6a52d9c83f9755bac19c27d4afd227f4197b33a2
parent 414560 d4e2540386dc8a3e5a892d9c304c300173d2a262
child 414562 fcc6c9a22f9948540c759cbe1024f4e9ed36264c
child 416120 cecab777fb8f69e8f283576c045e2356117373c9
push id29701
push userbmo:hurley@todesschaf.org
push dateFri, 16 Sep 2016 16:04:45 +0000
reviewersmcmanus
bugs1296280
milestone51.0a1
Bug 1296280 (part 0b) - Make debugging node h2 server work better r?mcmanus MozReview-Commit-ID: 6QoGiUKGTzA
testing/xpcshell/moz-http2/moz-http2.js
testing/xpcshell/runxpcshelltests.py
--- a/testing/xpcshell/moz-http2/moz-http2.js
+++ b/testing/xpcshell/moz-http2/moz-http2.js
@@ -738,23 +738,26 @@ function handleRequest(req, res) {
     res.setHeader('Connection', 'close');
   }
   res.writeHead(200);
   res.end(content);
 }
 
 // Set up the SSL certs for our server - this server has a cert for foo.example.com
 // signed by netwerk/tests/unit/CA.cert.der
-//var log_module = node_http2_root + "/test/util";
 var options = {
   key: fs.readFileSync(__dirname + '/http2-key.pem'),
   cert: fs.readFileSync(__dirname + '/http2-cert.pem'),
-  //, log: require(log_module).createLogger('server')
 };
 
+if (process.env.HTTP2_LOG !== undefined) {
+  var log_module = node_http2_root + "/test/util";
+  options.log = require(log_module).createLogger('server')
+}
+
 var server = http2.createServer(options, handleRequest);
 
 server.on('connection', function(socket) {
   socket.on('error', function() {
     // Ignoring SSL socket errors, since they usually represent a connection that was tore down
     // by the browser because of an untrusted certificate. And this happens at least once, when
     // the first test case if done.
   });
--- a/testing/xpcshell/runxpcshelltests.py
+++ b/testing/xpcshell/runxpcshelltests.py
@@ -990,17 +990,20 @@ class XPCShellTests(object):
         nodeBin = None
 
         # We try to find the node executable in the path given to us by the user in
         # the MOZ_NODE_PATH environment variable
         localPath = os.getenv('MOZ_NODE_PATH', None)
         if localPath and os.path.exists(localPath) and os.path.isfile(localPath):
             nodeBin = localPath
 
-        if nodeBin:
+        if os.getenv('MOZ_ASSUME_NODE_RUNNING', None):
+            self.log.info('Assuming required node servers are already running')
+            nodeMozInfo['hasNode'] = True
+        elif nodeBin:
             self.log.info('Found node at %s' % (nodeBin,))
 
             def startServer(name, serverJs):
                 if os.path.exists(serverJs):
                     # OK, we found our server, let's try to get it running
                     self.log.info('Found %s at %s' % (name, serverJs))
                     try:
                         # We pipe stdin to node because the server will exit when its
@@ -1018,19 +1021,16 @@ class XPCShellTests(object):
                             if searchObj:
                               self.env["MOZHTTP2_PORT"] = searchObj.group(1)
                     except OSError, e:
                         # This occurs if the subprocess couldn't be started
                         self.log.error('Could not run %s server: %s' % (name, str(e)))
 
             myDir = os.path.split(os.path.abspath(__file__))[0]
             startServer('moz-http2', os.path.join(myDir, 'moz-http2', 'moz-http2.js'))
-        elif os.getenv('MOZ_ASSUME_NODE_RUNNING', None):
-            self.log.info('Assuming required node servers are already running')
-            nodeMozInfo['hasNode'] = True
 
         mozinfo.update(nodeMozInfo)
 
     def shutdownNode(self):
         """
           Shut down our node process, if it exists
         """
         for name, proc in self.nodeProc.iteritems():