Bug 1248198 - Set "hasNode" only if the node version is >=5.0.0 because older node does not support ALPN. r=glandium
authorMasatoshi Kimura <VYV03354@nifty.ne.jp>
Fri, 15 Jul 2016 21:08:42 +0900
changeset 314332 c6876f222943810536b0970db21053ceafda3097
parent 314331 32bb28f7009253b367e4e9bbcda234f0f92c1e58
child 314333 4624432ec08e65b5a885d25fcf6f24c081a7e7a6
push id30718
push userphilringnalda@gmail.com
push dateSat, 17 Sep 2016 20:44:56 +0000
treeherdermozilla-central@eaf5eb6f8fa0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium
bugs1248198
milestone51.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1248198 - Set "hasNode" only if the node version is >=5.0.0 because older node does not support ALPN. r=glandium MozReview-Commit-ID: D4rrp92R5YS
testing/xpcshell/runxpcshelltests.py
--- a/testing/xpcshell/runxpcshelltests.py
+++ b/testing/xpcshell/runxpcshelltests.py
@@ -11,23 +11,25 @@ import math
 import mozdebug
 import mozinfo
 import os
 import os.path
 import random
 import re
 import shutil
 import signal
+import subprocess
 import sys
 import tempfile
 import time
 import traceback
 
 from collections import deque, namedtuple
 from distutils import dir_util
+from distutils.version import LooseVersion
 from multiprocessing import cpu_count
 from argparse import ArgumentParser
 from subprocess import Popen, PIPE, STDOUT
 from tempfile import mkdtemp, gettempdir
 from threading import (
     Timer,
     Thread,
     Event,
@@ -988,17 +990,27 @@ class XPCShellTests(object):
         """
         nodeMozInfo = {'hasNode': False} # Assume the worst
         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
+            try:
+                version_str = subprocess.check_output([localPath, "--version"],
+                                                      stderr=subprocess.STDOUT)
+                # nodejs prefixes its version strings with "v"
+                version = LooseVersion(version_str.lstrip('v'))
+                # Use node only if node version is >=5.0.0 because
+                # node did not support ALPN until this version.
+                if version >= LooseVersion("5.0.0"):
+                    nodeBin = localPath
+            except (subprocess.CalledProcessError, OSError), e:
+                self.log.error('Could not retrieve node version: %s' % str(e))
 
         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))