aboutsummaryrefslogtreecommitdiffstats
path: root/python/servo/testing_commands.py
diff options
context:
space:
mode:
authorMs2ger <Ms2ger@gmail.com>2015-08-09 11:20:40 +0200
committerMs2ger <Ms2ger@gmail.com>2015-08-09 11:20:40 +0200
commit47d6d958f58f5011742a18abcdd5a76bf4390966 (patch)
treee4d041afeeb75e0f3d424da8cdbac0026bd5de8c /python/servo/testing_commands.py
parentc315404db80c92a695531b0aa4bcf61c125a3bff (diff)
downloadservo-47d6d958f58f5011742a18abcdd5a76bf4390966.tar.gz
servo-47d6d958f58f5011742a18abcdd5a76bf4390966.zip
Revert "Auto merge of #7103 - frewsxcv:python-venv, r=metajack" for breaking web-platform-tests.
This reverts commit c315404db80c92a695531b0aa4bcf61c125a3bff, reversing changes made to b00583bd4e7169a6b952633df718268904f2bd0c.
Diffstat (limited to 'python/servo/testing_commands.py')
-rw-r--r--python/servo/testing_commands.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/python/servo/testing_commands.py b/python/servo/testing_commands.py
index 732db39a186..76e5bf9cb79 100644
--- a/python/servo/testing_commands.py
+++ b/python/servo/testing_commands.py
@@ -15,6 +15,7 @@ import os
import os.path as path
import subprocess
from collections import OrderedDict
+from distutils.spawn import find_executable
from time import time
from mach.registrar import Registrar
@@ -236,6 +237,7 @@ class MachCommands(CommandBase):
help="Run with a release build of servo")
def test_wpt(self, **kwargs):
self.ensure_bootstrapped()
+ self.ensure_wpt_virtualenv()
hosts_file_path = path.join('tests', 'wpt', 'hosts')
os.environ["hosts_file_path"] = hosts_file_path
@@ -253,6 +255,7 @@ class MachCommands(CommandBase):
parser=updatecommandline.create_parser())
def update_wpt(self, **kwargs):
self.ensure_bootstrapped()
+ self.ensure_wpt_virtualenv()
run_file = path.abspath(path.join("tests", "wpt", "update.py"))
run_globals = {"__file__": run_file}
execfile(run_file, run_globals)
@@ -298,6 +301,7 @@ class MachCommands(CommandBase):
help="Run with a release build of servo")
def test_css(self, **kwargs):
self.ensure_bootstrapped()
+ self.ensure_wpt_virtualenv()
run_file = path.abspath(path.join("tests", "wpt", "run_css.py"))
run_globals = {"__file__": run_file}
@@ -316,6 +320,45 @@ class MachCommands(CommandBase):
execfile(run_file, run_globals)
return run_globals["update_tests"](**kwargs)
+ def ensure_wpt_virtualenv(self):
+ virtualenv_path = path.join("tests", "wpt", "_virtualenv")
+ python = self.get_exec("python2", "python")
+
+ if not os.path.exists(virtualenv_path):
+ virtualenv = self.get_exec("virtualenv2", "virtualenv")
+ subprocess.check_call([virtualenv, "-p", python, virtualenv_path])
+
+ activate_path = path.join(virtualenv_path, "bin", "activate_this.py")
+
+ execfile(activate_path, dict(__file__=activate_path))
+
+ try:
+ import wptrunner # noqa
+ from wptrunner.browsers import servo # noqa
+ except ImportError:
+ subprocess.check_call(["pip", "install", "-r",
+ path.join("tests", "wpt", "harness", "requirements.txt")])
+ subprocess.check_call(["pip", "install", "-r",
+ path.join("tests", "wpt", "harness", "requirements_servo.txt")])
+ try:
+ import blessings
+ except ImportError:
+ subprocess.check_call(["pip", "install", "blessings"])
+
+ # This is an unfortunate hack. Because mozlog gets imported by wptcommandline
+ # before the virtualenv is initalised it doesn't see the blessings module so we don't
+ # get coloured output. Setting the blessings global explicitly fixes that.
+ from mozlog.structured.formatters import machformatter
+ import blessings # noqa
+ machformatter.blessings = blessings
+
+ def get_exec(self, name, default=None):
+ path = find_executable(name)
+ if not path:
+ return default
+
+ return path
+
def jquery_test_runner(self, cmd, release, dev):
self.ensure_bootstrapped()
base_dir = path.abspath(path.join("tests", "jquery"))