--- a/testing/xpcshell/runxpcshelltests.py
+++ b/testing/xpcshell/runxpcshelltests.py
@@ -985,58 +985,53 @@ class XPCShellTests(object):
def trySetupNode(self):
"""
Run node for HTTP/2 tests, if available, and updates mozinfo as appropriate.
"""
if os.getenv('MOZ_ASSUME_NODE_RUNNING', None):
self.log.info('Assuming required node servers are already running')
return
- 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 not localPath:
+ nodeBin = os.getenv('MOZ_NODE_PATH', None)
+ if not nodeBin:
self.log.info('MOZ_NODE_PATH environment variable not set')
return
- if not os.path.exists(localPath) or not os.path.isfile(localPath):
- self.log.error('node not found at MOZ_NODE_PATH %s' % (localPath))
+ if not os.path.exists(nodeBin) or not os.path.isfile(nodeBin):
+ self.log.error('node not found at MOZ_NODE_PATH %s' % (nodeBin))
return
- nodeBin = localPath
+ self.log.info('Found node at %s' % (nodeBin,))
- if 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
+ # stdin reaches EOF
+ process = Popen([nodeBin, serverJs], stdin=PIPE, stdout=PIPE,
+ stderr=PIPE, env=self.env, cwd=os.getcwd())
+ self.nodeProc[name] = process
- 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
- # stdin reaches EOF
- process = Popen([nodeBin, serverJs], stdin=PIPE, stdout=PIPE,
- stderr=PIPE, env=self.env, cwd=os.getcwd())
- self.nodeProc[name] = process
+ # Check to make sure the server starts properly by waiting for it to
+ # tell us it's started
+ msg = process.stdout.readline()
+ if 'server listening' in msg:
+ searchObj = re.search( r'HTTP2 server listening on port (.*)', msg, 0)
+ 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)))
- # Check to make sure the server starts properly by waiting for it to
- # tell us it's started
- msg = process.stdout.readline()
- if 'server listening' in msg:
- searchObj = re.search( r'HTTP2 server listening on port (.*)', msg, 0)
- 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'))
+ myDir = os.path.split(os.path.abspath(__file__))[0]
+ startServer('moz-http2', os.path.join(myDir, 'moz-http2', 'moz-http2.js'))
def shutdownNode(self):
"""
Shut down our node process, if it exists
"""
for name, proc in self.nodeProc.iteritems():
self.log.info('Node %s server shutting down ...' % name)
if proc.poll() is not None: