Skip to content

Commit

Permalink
Separate metadata_root and expectation_root
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke Bjerring committed Oct 23, 2017
1 parent 37cf560 commit f3f091f
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 16 deletions.
5 changes: 5 additions & 0 deletions tools/ci/check_stability.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,11 @@ def get_parser():
action="store",
default=wpt_root,
help="Directory that will contain MANIFEST.json")
parser.add_argument("--expectation_root",
dest="expectation_root",
action="store",
default=wpt_root,
help="Root directory that will contain test metadata manifests.")
parser.add_argument("--config-file",
action="store",
type=str,
Expand Down
1 change: 1 addition & 0 deletions tools/wpt/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def exit(msg):
def args_general(kwargs):
kwargs.set_if_none("tests_root", wpt_root)
kwargs.set_if_none("metadata_root", wpt_root)
kwargs.set_if_none("expectation_root", kwargs.get("metadata_root"))
kwargs.set_if_none("manifest_update", True)

if kwargs["ssl_type"] in (None, "pregenerated"):
Expand Down
2 changes: 1 addition & 1 deletion tools/wpt/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def set_if_none(self, name, value, err_fn=None, desc=None, extra_cond=None):
if desc is None:
desc = name

if self[name] is None:
if name not in self or self[name] is None:
if extra_cond is not None and not extra_cond(self):
return
if callable(value):
Expand Down
6 changes: 3 additions & 3 deletions tools/wptrunner/wptrunner/expected.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import os


def expected_path(metadata_path, test_path):
def expected_path(expectation_root, test_path):
"""Path to the expectation data file for a given test path.
This is defined as metadata_path + relative_test_path + .ini
:param metadata_path: Path to the root of the metadata directory
:param expectation_root: Path to the root of the metadata directory
:param test_path: Relative path to the test file from the test root
"""
args = list(test_path.split("/"))
args[-1] += ".ini"
return os.path.join(metadata_path, *args)
return os.path.join(expectation_root, *args)
6 changes: 3 additions & 3 deletions tools/wptrunner/wptrunner/manifestexpected.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,17 +224,17 @@ def is_empty(self):
return True


def get_manifest(metadata_root, test_path, url_base, run_info):
def get_manifest(expectation_root, test_path, url_base, run_info):
"""Get the ExpectedManifest for a particular test path, or None if there is no
metadata stored for that test path.
:param metadata_root: Absolute path to the root of the metadata directory
:param expectation_root: Absolute path to the root of the metadata directory
:param test_path: Path to the test(s) relative to the test root
:param url_base: Base url for serving the tests in this manifest
:param run_info: Dictionary of properties of the test run for which the expectation
values should be computed.
"""
manifest_path = expected.expected_path(metadata_root, test_path)
manifest_path = expected.expected_path(expectation_root, test_path)
try:
with open(manifest_path) as f:
return static.compile(f,
Expand Down
6 changes: 3 additions & 3 deletions tools/wptrunner/wptrunner/manifestupdate.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,19 +439,19 @@ def make_expr(prop_set, status, boolean_properties=None):
return root


def get_manifest(metadata_root, test_path, url_base, property_order=None,
def get_manifest(expectation_root, test_path, url_base, property_order=None,
boolean_properties=None):
"""Get the ExpectedManifest for a particular test path, or None if there is no
metadata stored for that test path.
:param metadata_root: Absolute path to the root of the metadata directory
:param expectation_root: Absolute path to the root of the metadata directory
:param test_path: Path to the test(s) relative to the test root
:param url_base: Base url for serving the tests in this manifest
:param property_order: List of properties to use in expectation metadata
from most to least significant.
:param boolean_properties: Set of properties in property_order that should
be treated as boolean."""
manifest_path = expected.expected_path(metadata_root, test_path)
manifest_path = expected.expected_path(expectation_root, test_path)
try:
with open(manifest_path) as f:
return compile(f, test_path, url_base, property_order=property_order,
Expand Down
17 changes: 11 additions & 6 deletions tools/wptrunner/wptrunner/wpttest.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,20 @@ class WdspecSubtestResult(SubtestResult):
statuses = set(["PASS", "FAIL", "ERROR"])


def get_run_info(metadata_root, product, **kwargs):
return RunInfo(metadata_root, product, **kwargs)
def get_run_info(expectation_root, product, **kwargs):
"""Gets a RunInfo for the given args.
:param (string) expectation_root: Absolute path to the root for expectation manifest files.
:param (string) product: Product to run the tests for (e.g. chrome-63.0).
"""
return RunInfo(expectation_root, product, **kwargs)


class RunInfo(dict):
def __init__(self, metadata_root, product, debug, extras=None):
def __init__(self, expectation_root, product, debug, extras=None):
import mozinfo

self._update_mozinfo(metadata_root)
self._update_mozinfo(expectation_root)
self.update(mozinfo.info)
self["product"] = product
if debug is not None:
Expand All @@ -84,12 +89,12 @@ def __init__(self, metadata_root, product, debug, extras=None):
if extras is not None:
self.update(extras)

def _update_mozinfo(self, metadata_root):
def _update_mozinfo(self, expectation_root):
"""Add extra build information from a mozinfo.json file in a parent
directory"""
import mozinfo

path = metadata_root
path = expectation_root
dirs = set()
while path != os.path.expanduser('~'):
if path in dirs:
Expand Down

0 comments on commit f3f091f

Please sign in to comment.