def _add_rule(self, test_manifests, url, direction): maybe_path = os.path.join(os.path.abspath(os.curdir), url) rest, last = os.path.split(maybe_path) variant = "" if "#" in last: last, fragment = last.rsplit("#", 1) variant += "#" + fragment if "?" in last: last, query = last.rsplit("?", 1) variant += "?" + query maybe_path = os.path.join(rest, last) if os.path.exists(maybe_path): for manifest, data in test_manifests.iteritems(): rel_path = os.path.relpath(maybe_path, data["tests_path"]) if ".." not in rel_path.split(os.sep): url = "/" + rel_path.replace(os.path.sep, "/") + variant break assert direction in ("include", "exclude") components = self._get_components(url) node = self while components: component = components.pop() if component not in node.child_map: new_node = IncludeManifest(DataNode(component)) node.append(new_node) node = node.child_map[component] skip = False if direction == "include" else True node.set("skip", str(skip))
def __init__(self, node, test_path, url_base, run_info_properties): """Object representing all the tests in a particular manifest :param node: AST Node associated with this object. If this is None, a new AST is created to associate with this manifest. :param test_path: Path of the test file associated with this manifest. :param url_base: Base url for serving the tests in this manifest. :param run_info_properties: Tuple of ([property name], {property_name: [dependent property]}) The first part lists run_info properties that are always used in the update, the second maps property names to additional properties that can be considered if we already have a condition on the key property e.g. {"foo": ["bar"]} means that we consider making conditions on bar only after we already made one on foo. """ if node is None: node = DataNode(None) ManifestItem.__init__(self, node) self.child_map = {} self.test_path = test_path self.url_base = url_base assert self.url_base is not None self._modified = False self.run_info_properties = run_info_properties self.update_properties = UpdateProperties( self, **{ "lsan": LsanUpdate, "leak_object": LeakObjectUpdate, "leak_threshold": LeakThresholdUpdate, })
def __init__(self, node, test_path=None, url_base=None, property_order=None, boolean_properties=None): """Object representing all the tests in a particular manifest :param node: AST Node associated with this object. If this is None, a new AST is created to associate with this manifest. :param test_path: Path of the test file associated with this manifest. :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. """ if node is None: node = DataNode(None) ManifestItem.__init__(self, node) self.child_map = {} self.test_path = test_path self.url_base = url_base assert self.url_base is not None self.modified = False self.boolean_properties = boolean_properties self.property_order = property_order
def create(cls, test_id): """Create a TestNode corresponding to a given test :param test_type: The type of the test :param test_id: The id of the test""" name = test_id[len(urlsplit(test_id).path.rsplit("/", 1)[0]) + 1:] node = DataNode(name) self = cls(node) self._from_file = False return self
def _add_rule(self, test_manifests, url, direction): maybe_path = os.path.join(os.path.abspath(os.curdir), url) rest, last = os.path.split(maybe_path) fragment = query = None if "#" in last: last, fragment = last.rsplit("#", 1) if "?" in last: last, query = last.rsplit("?", 1) maybe_path = os.path.join(rest, last) paths = glob.glob(maybe_path) if paths: urls = [] for path in paths: for manifest, data in test_manifests.iteritems(): found = False rel_path = os.path.relpath(path, data["tests_path"]) iterator = manifest.iterpath if os.path.isfile( path) else manifest.iterdir for test in iterator(rel_path): if not hasattr(test, "url"): continue url = test.url if query or fragment: parsed = urlparse.urlparse(url) if ((query and query != parsed.query) or (fragment and fragment != parsed.fragment)): continue urls.append(url) found = True if found: break else: urls = [url] assert direction in ("include", "exclude") for url in urls: components = self._get_components(url) node = self while components: component = components.pop() if component not in node.child_map: new_node = IncludeManifest(DataNode(component)) node.append(new_node) new_node.set("skip", node.get("skip", {})) node = node.child_map[component] skip = False if direction == "include" else True node.set("skip", str(skip))
def create(cls, test_id): """Create a TestNode corresponding to a given test :param test_type: The type of the test :param test_id: The id of the test""" url = test_id name = url.rsplit("/", 1)[1] node = DataNode(name) self = cls(node) self._from_file = False return self
def __init__(self, node, test_path=None): """Object representing all the tests in a particular manifest :param node: AST Node associated with this object. If this is None, a new AST is created to associate with this manifest. :param test_path: Path of the test file associated with this manifest. """ if node is None: node = DataNode(None) ManifestItem.__init__(self, node) self.child_map = {} self.test_path = test_path self.modified = False
def _add_rule(self, url, direction): assert direction in ("include", "exclude") components = [item for item in reversed(url.split("/")) if item] node = self while components: component = components.pop() if component not in node.child_map: new_node = IncludeManifest(DataNode(component)) node.append(new_node) node = node.child_map[component] skip = False if direction == "include" else True node.set("skip", str(skip))
def __init__(self, node, test_path, url_base, run_info_properties, update_intermittent=False, remove_intermittent=False): """Object representing all the tests in a particular manifest :param node: AST Node associated with this object. If this is None, a new AST is created to associate with this manifest. :param test_path: Path of the test file associated with this manifest. :param url_base: Base url for serving the tests in this manifest. :param run_info_properties: Tuple of ([property name], {property_name: [dependent property]}) The first part lists run_info properties that are always used in the update, the second maps property names to additional properties that can be considered if we already have a condition on the key property e.g. {"foo": ["bar"]} means that we consider making conditions on bar only after we already made one on foo. :param update_intermittent: When True, intermittent statuses will be recorded as `expected` in the test metadata. :param: remove_intermittent: When True, old intermittent statuses will be removed if no longer intermittent. This is only relevant if `update_intermittent` is also True, because if False, the metadata will simply update one `expected`status. """ if node is None: node = DataNode(None) ManifestItem.__init__(self, node) self.child_map = {} self.test_path = test_path self.url_base = url_base assert self.url_base is not None self._modified = False self.run_info_properties = run_info_properties self.update_intermittent = update_intermittent self.remove_intermittent = remove_intermittent self.update_properties = UpdateProperties( self, **{ "lsan": LsanUpdate, "leak_object": LeakObjectUpdate, "leak_threshold": LeakThresholdUpdate, })
def create(cls, test_type, test_id): """Create a TestNode corresponding to a given test :param test_type: The type of the test :param test_id: The id of the test""" if test_type == "reftest": url = test_id[0] else: url = test_id name = url.split("/")[-1] node = DataNode(name) self = cls(node) self.set("type", test_type) if test_type == "reftest": self.set("reftype", test_id[1]) self.set("refurl", test_id[2]) self._from_file = False return self
def _add_rule(self, test_manifests, url, direction): maybe_path = os.path.abspath(os.path.join(os.curdir, url)) if os.path.exists(maybe_path): for manifest, data in test_manifests.iteritems(): rel_path = os.path.relpath(maybe_path, data["tests_path"]) if ".." not in rel_path.split(os.sep): url = rel_path assert direction in ("include", "exclude") components = [item for item in reversed(url.split("/")) if item] node = self while components: component = components.pop() if component not in node.child_map: new_node = IncludeManifest(DataNode(component)) node.append(new_node) node = node.child_map[component] skip = False if direction == "include" else True node.set("skip", str(skip))
def create(cls, name): node = DataNode(name) self = cls(node) return self
def create(cls): """Create an empty IncludeManifest tree""" node = DataNode(None) return cls(node)