Bug 1231981 - Part 5: Install python packages we need in the virtualenv if not present. r=gps
MozReview-Commit-ID: 9PUHLMxHhQP
--- a/python/mozbuild/mozbuild/virtualenv.py
+++ b/python/mozbuild/mozbuild/virtualenv.py
@@ -457,16 +457,27 @@ class VirtualenvManager(object):
virtualenv, you can simply instantiate an instance of this class
and call .ensure() and .activate() to make the virtualenv active.
"""
execfile(self.activate_path, dict(__file__=self.activate_path))
if isinstance(os.environ['PATH'], unicode):
os.environ['PATH'] = os.environ['PATH'].encode('utf-8')
+ def install_pip_requirements_file(self, requirements_filename):
+ """Installs packages in |requirements_filename| via pip."""
+
+ args = [
+ 'install',
+ '-r',
+ requirements_filename
+ ]
+
+ return self._run_pip(args)
+
def install_pip_package(self, package):
"""Install a package via pip.
The supplied package is specified using a pip requirement specifier.
e.g. 'foo' or 'foo==1.0'.
If the package is already installed, this is a no-op.
"""
--- a/testing/mochitest/mach_commands.py
+++ b/testing/mochitest/mach_commands.py
@@ -150,16 +150,22 @@ class MochitestRunner(MozbuildObject):
self.tests_dir = os.path.join(self.topobjdir, '_tests')
self.mochitest_dir = os.path.join(
self.tests_dir,
'testing',
'mochitest')
self.bin_dir = os.path.join(self.topobjdir, 'dist', 'bin')
+ self._activate_virtualenv()
+ self.virtualenv_manager.install_pip_requirements_file(
+ os.path.join(self.mochitest_dir,
+ 'websocketprocessbridge',
+ 'websocketprocessbridge_requirements.txt'))
+
def resolve_tests(self, test_paths, test_objects=None, cwd=None):
if test_objects:
return test_objects
from mozbuild.testing import TestResolver
resolver = self._spawn(TestResolver)
tests = list(resolver.resolve_tests(paths=test_paths, cwd=cwd))
return tests
--- a/testing/mochitest/runtests.py
+++ b/testing/mochitest/runtests.py
@@ -810,16 +810,17 @@ class MochitestBase(object):
def startWebsocketProcessBridge(self, options):
"""Create a websocket server that can launch various processes that
JS needs (eg; ICE server for webrtc testing)
"""
command = [sys.executable,
os.path.join("websocketprocessbridge",
"websocketprocessbridge.py")]
+ os.environ['PYTHONPATH'] = os.pathsep.join(p for p in sys.path)
self.websocketprocessbridge = mozprocess.ProcessHandler(command,
cwd=SCRIPT_DIR)
self.websocketprocessbridge.run()
self.log.info("runtests.py | websocket/process bridge pid: %d"
% self.websocketprocessbridge.pid)
# ensure the server is up, wait for at most ten seconds
for i in range(1,100):