mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Make the test-wpt mach command support all the command line arguments of wptrunner.
Also remove the shell script and ensure that default options are set in a single location
This commit is contained in:
parent
0a7429f147
commit
2bde318d24
7 changed files with 162 additions and 77 deletions
|
@ -11,8 +11,11 @@ import sys
|
||||||
SEARCH_PATHS = [
|
SEARCH_PATHS = [
|
||||||
"python/mach",
|
"python/mach",
|
||||||
"python/toml",
|
"python/toml",
|
||||||
|
"python/mozlog",
|
||||||
"python/mozinfo",
|
"python/mozinfo",
|
||||||
"python/mozdebug",
|
"python/mozdebug",
|
||||||
|
"tests/wpt",
|
||||||
|
"tests/wpt/harness",
|
||||||
]
|
]
|
||||||
|
|
||||||
# Individual files providing mach commands.
|
# Individual files providing mach commands.
|
||||||
|
|
|
@ -5,6 +5,7 @@ import sys
|
||||||
import os
|
import os
|
||||||
import os.path as path
|
import os.path as path
|
||||||
import subprocess
|
import subprocess
|
||||||
|
from distutils.spawn import find_executable
|
||||||
from time import time
|
from time import time
|
||||||
|
|
||||||
from mach.registrar import Registrar
|
from mach.registrar import Registrar
|
||||||
|
@ -15,8 +16,9 @@ from mach.decorators import (
|
||||||
)
|
)
|
||||||
|
|
||||||
from servo.command_base import CommandBase
|
from servo.command_base import CommandBase
|
||||||
|
from wptrunner import wptcommandline
|
||||||
|
from update import updatecommandline
|
||||||
import tidy
|
import tidy
|
||||||
import multiprocessing
|
|
||||||
|
|
||||||
|
|
||||||
@CommandProvider
|
@CommandProvider
|
||||||
|
@ -215,32 +217,65 @@ class MachCommands(CommandBase):
|
||||||
|
|
||||||
@Command('test-wpt',
|
@Command('test-wpt',
|
||||||
description='Run the web platform tests',
|
description='Run the web platform tests',
|
||||||
category='testing')
|
category='testing',
|
||||||
@CommandArgument(
|
parser=wptcommandline.create_parser())
|
||||||
'--processes', default=None,
|
@CommandArgument('--release', default=False, action="store_true",
|
||||||
help="Number of servo processes to spawn")
|
help="Run with a release build of servo")
|
||||||
@CommandArgument(
|
def test_wpt(self, **kwargs):
|
||||||
"params", default=None, nargs='...',
|
|
||||||
help="command-line arguments to be passed through to wpt/run.sh")
|
|
||||||
def test_wpt(self, processes=None, params=None):
|
|
||||||
self.ensure_bootstrapped()
|
self.ensure_bootstrapped()
|
||||||
|
self.ensure_wpt_virtualenv()
|
||||||
if params is None:
|
|
||||||
params = []
|
|
||||||
else:
|
|
||||||
# Allow the first argument to be a relative path from Servo's root
|
|
||||||
# directory, converting it to `--include some/wpt/test.html`
|
|
||||||
maybe_path = path.normpath(params[0])
|
|
||||||
wpt_path = path.join('tests', 'wpt', 'web-platform-tests')
|
|
||||||
|
|
||||||
if path.exists(maybe_path) and wpt_path in maybe_path:
|
|
||||||
params = ["--include",
|
|
||||||
path.relpath(maybe_path, wpt_path)]
|
|
||||||
|
|
||||||
processes = str(multiprocessing.cpu_count()) if processes is None else processes
|
|
||||||
params = params + ["--processes", processes]
|
|
||||||
hosts_file_path = path.join('tests', 'wpt', 'hosts')
|
hosts_file_path = path.join('tests', 'wpt', 'hosts')
|
||||||
|
|
||||||
return subprocess.call(
|
os.environ["hosts_file_path"] = hosts_file_path
|
||||||
["bash", path.join("tests", "wpt", "run.sh")] + params,
|
|
||||||
env=self.build_env(hosts_file_path=hosts_file_path))
|
run_file = path.abspath(path.join("tests", "wpt", "run_wpt.py"))
|
||||||
|
run_globals = {"__file__": run_file}
|
||||||
|
execfile(run_file, run_globals)
|
||||||
|
return run_globals["run_tests"](**kwargs)
|
||||||
|
|
||||||
|
@Command('update-wpt',
|
||||||
|
description='Update the web platform tests',
|
||||||
|
category='testing',
|
||||||
|
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)
|
||||||
|
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
|
||||||
|
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")])
|
||||||
|
|
||||||
|
# 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
|
||||||
|
machformatter.blessings = blessings
|
||||||
|
|
||||||
|
def get_exec(self, name, default=None):
|
||||||
|
path = find_executable(name)
|
||||||
|
if not path:
|
||||||
|
return default
|
||||||
|
|
||||||
|
return path
|
||||||
|
|
|
@ -4,7 +4,7 @@ servo =
|
||||||
[web-platform-tests]
|
[web-platform-tests]
|
||||||
remote_url = https://github.com/w3c/web-platform-tests.git
|
remote_url = https://github.com/w3c/web-platform-tests.git
|
||||||
branch = master
|
branch = master
|
||||||
sync_path = web-platform-tests
|
sync_path = sync
|
||||||
|
|
||||||
[paths]
|
[paths]
|
||||||
run-info = .
|
run-info = .
|
||||||
|
|
|
@ -2,34 +2,54 @@
|
||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
import sys, os, argparse
|
import argparse
|
||||||
|
import multiprocessing
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
here = os.path.split(__file__)[0]
|
here = os.path.split(__file__)[0]
|
||||||
servo_root = os.path.abspath(os.path.join(here, "..", ".."))
|
servo_root = os.path.abspath(os.path.join(here, "..", ".."))
|
||||||
|
|
||||||
def wptsubdir(*args):
|
def wpt_path(*args):
|
||||||
return os.path.join(here, *args)
|
return os.path.join(here, *args)
|
||||||
|
|
||||||
|
def servo_path(*args):
|
||||||
|
return os.path.join(servo_root, *args)
|
||||||
|
|
||||||
# Imports
|
# Imports
|
||||||
sys.path.append(wptsubdir("web-platform-tests"))
|
sys.path.append(wpt_path("harness"))
|
||||||
from wptrunner import wptrunner, wptcommandline
|
from wptrunner import wptrunner, wptcommandline
|
||||||
|
|
||||||
def run_tests(**kwargs):
|
def run_tests(paths=None, **kwargs):
|
||||||
wptrunner.setup_logging(kwargs, {"raw": sys.stdout})
|
if paths is None:
|
||||||
|
paths = {}
|
||||||
|
set_defaults(paths, kwargs)
|
||||||
|
wptrunner.setup_logging(kwargs, {"mach": sys.stdout})
|
||||||
return wptrunner.run_tests(**kwargs)
|
return wptrunner.run_tests(**kwargs)
|
||||||
|
|
||||||
def set_defaults(args):
|
def set_defaults(paths, kwargs):
|
||||||
args.include_manifest = args.include_manifest if args.include_manifest else wptsubdir("include.ini")
|
if kwargs["product"] is None:
|
||||||
args.product = "servo"
|
kwargs["product"] = "servo"
|
||||||
rv = vars(args)
|
|
||||||
wptcommandline.check_args(rv)
|
|
||||||
return rv
|
|
||||||
|
|
||||||
def main():
|
if kwargs["config"] is None and "config" in paths:
|
||||||
|
kwargs["config"] = paths["config"]
|
||||||
|
|
||||||
|
if kwargs["include_manifest"] is None and "include_manifest" in paths:
|
||||||
|
kwargs["include_manifest"] = paths["include_manifest"]
|
||||||
|
|
||||||
|
if kwargs["binary"] is None:
|
||||||
|
bin_dir = "release" if kwargs["release"] else "debug"
|
||||||
|
bin_path = servo_path("components", "servo", "target", bin_dir, "servo")
|
||||||
|
|
||||||
|
kwargs["binary"] = bin_path
|
||||||
|
|
||||||
|
if kwargs["processes"] is None:
|
||||||
|
kwargs["processes"] = multiprocessing.cpu_count()
|
||||||
|
|
||||||
|
wptcommandline.check_args(kwargs)
|
||||||
|
|
||||||
|
def main(paths=None):
|
||||||
parser = wptcommandline.create_parser()
|
parser = wptcommandline.create_parser()
|
||||||
args = parser.parse_args()
|
kwargs = vars(parser.parse_args())
|
||||||
kwargs = set_defaults(args)
|
return run_tests(paths, **kwargs)
|
||||||
return run_tests(**kwargs)
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
sys.exit(0 if main() else 1)
|
|
||||||
|
|
|
@ -1,32 +0,0 @@
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
wpt_root=$(dirname $0)
|
|
||||||
binary_dir=$wpt_root/../../components/servo/target
|
|
||||||
if [[ $1 == "--release" ]]; then
|
|
||||||
binary_dir=$binary_dir/release
|
|
||||||
shift
|
|
||||||
else
|
|
||||||
binary_dir=$binary_dir/debug
|
|
||||||
fi
|
|
||||||
|
|
||||||
PYTHON=$(which python2 2> /dev/null || echo python)
|
|
||||||
VIRTUALENV=$(which virtualenv2 2> /dev/null || echo virtualenv)
|
|
||||||
|
|
||||||
test -d $wpt_root/_virtualenv || $VIRTUALENV $wpt_root/_virtualenv -p $PYTHON
|
|
||||||
test -d $wpt_root/metadata || mkdir -p $wpt_root/metadata
|
|
||||||
test -d $wpt_root/prefs || mkdir -p $wpt_root/prefs
|
|
||||||
source $wpt_root/_virtualenv/bin/activate
|
|
||||||
if [[ $* == *--update-manifest* ]]; then
|
|
||||||
(python -c "import html5lib" &>/dev/null) || pip install html5lib
|
|
||||||
fi
|
|
||||||
(python -c "import wptrunner" &>/dev/null) || pip install 'wptrunner==1.14'
|
|
||||||
|
|
||||||
python $wpt_root/run.py \
|
|
||||||
--config $wpt_root/config.ini \
|
|
||||||
--binary $binary_dir/servo \
|
|
||||||
--log-mach - \
|
|
||||||
"$@"
|
|
19
tests/wpt/run_wpt.py
Normal file
19
tests/wpt/run_wpt.py
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import run
|
||||||
|
|
||||||
|
paths = {"include_manifest": run.wpt_path("include.ini"),
|
||||||
|
"config": run.wpt_path("config.ini")}
|
||||||
|
|
||||||
|
def run_tests(**kwargs):
|
||||||
|
return run.run_tests(paths=paths, **kwargs)
|
||||||
|
|
||||||
|
def main():
|
||||||
|
return run.main(paths)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
sys.exit(0 if main() else 1)
|
40
tests/wpt/update.py
Normal file
40
tests/wpt/update.py
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import multiprocessing
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
here = os.path.split(__file__)[0]
|
||||||
|
|
||||||
|
def wpt_path(*args):
|
||||||
|
return os.path.join(here, *args)
|
||||||
|
|
||||||
|
# Imports
|
||||||
|
from update import updatecommandline
|
||||||
|
|
||||||
|
def update_tests(**kwargs):
|
||||||
|
import update
|
||||||
|
|
||||||
|
set_defaults(kwargs)
|
||||||
|
logger = update.setup_logging(kwargs, {"mach": sys.stdout})
|
||||||
|
|
||||||
|
rv = update.run_update(logger, **kwargs)
|
||||||
|
return 0 if rv is update.exit_unclean else 1
|
||||||
|
|
||||||
|
def set_defaults(kwargs):
|
||||||
|
if kwargs["config"] is None:
|
||||||
|
kwargs["config"] = wpt_path('config.ini')
|
||||||
|
updatecommandline.check_args(kwargs)
|
||||||
|
|
||||||
|
def main():
|
||||||
|
parser = wptcommandline.create_parser()
|
||||||
|
kwargs = vars(parser.parse_args())
|
||||||
|
return update_tests(**kwargs)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
sys.exit(0 if main() else 1)
|
Loading…
Add table
Add a link
Reference in a new issue