mirror of
https://github.com/servo/servo.git
synced 2025-08-09 07:25:35 +01: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
|
@ -4,7 +4,7 @@ servo =
|
|||
[web-platform-tests]
|
||||
remote_url = https://github.com/w3c/web-platform-tests.git
|
||||
branch = master
|
||||
sync_path = web-platform-tests
|
||||
sync_path = sync
|
||||
|
||||
[paths]
|
||||
run-info = .
|
||||
|
|
|
@ -2,34 +2,54 @@
|
|||
# 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/.
|
||||
|
||||
import sys, os, argparse
|
||||
import argparse
|
||||
import multiprocessing
|
||||
import os
|
||||
import sys
|
||||
|
||||
here = os.path.split(__file__)[0]
|
||||
servo_root = os.path.abspath(os.path.join(here, "..", ".."))
|
||||
|
||||
def wptsubdir(*args):
|
||||
def wpt_path(*args):
|
||||
return os.path.join(here, *args)
|
||||
|
||||
def servo_path(*args):
|
||||
return os.path.join(servo_root, *args)
|
||||
|
||||
# Imports
|
||||
sys.path.append(wptsubdir("web-platform-tests"))
|
||||
sys.path.append(wpt_path("harness"))
|
||||
from wptrunner import wptrunner, wptcommandline
|
||||
|
||||
def run_tests(**kwargs):
|
||||
wptrunner.setup_logging(kwargs, {"raw": sys.stdout})
|
||||
def run_tests(paths=None, **kwargs):
|
||||
if paths is None:
|
||||
paths = {}
|
||||
set_defaults(paths, kwargs)
|
||||
wptrunner.setup_logging(kwargs, {"mach": sys.stdout})
|
||||
return wptrunner.run_tests(**kwargs)
|
||||
|
||||
def set_defaults(args):
|
||||
args.include_manifest = args.include_manifest if args.include_manifest else wptsubdir("include.ini")
|
||||
args.product = "servo"
|
||||
rv = vars(args)
|
||||
wptcommandline.check_args(rv)
|
||||
return rv
|
||||
def set_defaults(paths, kwargs):
|
||||
if kwargs["product"] is None:
|
||||
kwargs["product"] = "servo"
|
||||
|
||||
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()
|
||||
args = parser.parse_args()
|
||||
kwargs = set_defaults(args)
|
||||
return run_tests(**kwargs)
|
||||
kwargs = vars(parser.parse_args())
|
||||
return run_tests(paths, **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