Skip to content

Commit

Permalink
Add a wpt command for updating expectation metadata.
Browse files Browse the repository at this point in the history
The |wpt update-expectations| command takes a list of raw log files,
and updates the expectation data located in the directory supplied
thorugh the --metadata keyword argument. This metadata is used by
subsequent test runs to determine the expected test results.

By default the "product" property is used as a possible conditional on
the data; this means that if multiple logs are passed in
simultaneously then different results will be distinguished by "if
product==foo" conditions in the metadata.
  • Loading branch information
jgraham committed Feb 28, 2018
1 parent 3346f8d commit f9debd2
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tools/wpt/commands.json
@@ -1,6 +1,10 @@
{
"run": {"path": "run.py", "script": "run", "parser": "create_parser", "help": "Run tests in a browser",
"virtualenv": true, "install": ["requests"], "requirements": ["../wptrunner/requirements.txt"]},
"update-expectations": {"path": "update.py", "script": "update_expectations",
"parser": "create_parser_update", "help": "Update expectations files from raw logs.",
"virtualenv": true, "install": ["requests"],
"requirements": ["../wptrunner/requirements.txt"]},
"files-changed": {"path": "testfiles.py", "script": "run_changed_files", "parser": "get_parser",
"help": "Get a list of files that have changed", "virtualenv": false},
"tests-affected": {"path": "testfiles.py", "script": "run_tests_affected", "parser": "get_parser_affected",
Expand Down
32 changes: 32 additions & 0 deletions tools/wpt/update.py
@@ -0,0 +1,32 @@
import os
import sys

wpt_root = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir))
sys.path.insert(0, os.path.abspath(os.path.join(wpt_root, "tools")))


def create_parser_update():
from wptrunner import wptcommandline

return wptcommandline.create_parser_update()


def update_expectations(venv, **kwargs):
from wptrunner import wptcommandline
from wptrunner.update import setup_logging, WPTUpdate

if not kwargs["tests_root"]:
kwargs["tests_root"] = wpt_root

if not kwargs["manifest_path"]:
kwargs["manifest_path"] = os.path.join(wpt_root, "MANIFEST.json")

if "product" not in kwargs["extra_property"]:
kwargs["extra_property"].append("product")

wptcommandline.check_args_update(kwargs)

logger = setup_logging(kwargs, {"mach": sys.stdout})

updater = WPTUpdate(logger, **kwargs)
updater.run()

0 comments on commit f9debd2

Please sign in to comment.