Пример #1
0
def write_new_expected(metadata_path, expected):
    # Serialize the data back to a file
    path = expected_path(metadata_path, expected.test_path)
    if not expected.is_empty:
        manifest_str = wptmanifest.serialize(expected.node,
                                             skip_empty_data=True)
        assert manifest_str != ""
        dir = os.path.split(path)[0]
        if not os.path.exists(dir):
            os.makedirs(dir)
        tmp_path = path + ".tmp"
        try:
            with open(tmp_path, "wb") as f:
                f.write(manifest_str)
            os.rename(tmp_path, path)
        except (Exception, KeyboardInterrupt):
            try:
                os.unlink(tmp_path)
            except OSError:
                pass
    else:
        try:
            os.unlink(path)
        except OSError:
            pass
Пример #2
0
    def update(self, full_update=False, disable_intermittent=None):
        """Update the underlying manifest AST for this test based on all the
        added results.

        This will update existing conditionals if they got the same result in
        all matching runs in the updated results, will delete existing conditionals
        that get more than one different result in the updated run, and add new
        conditionals for anything that doesn't match an existing conditional.

        Conditionals not matched by any added result are not changed.

        When `disable_intermittent` is not None, disable any test that shows multiple
        unexpected results for the same set of parameters.
        """
        if not self.has_result:
            return

        property_tree = self.property_builder(
            self.node.root.run_info_properties, self.results)

        conditions, errors = self.update_conditions(property_tree, full_update)

        for e in errors:
            if disable_intermittent:
                condition = e.cond.children[0] if e.cond else None
                msg = disable_intermittent if isinstance(
                    disable_intermittent, (str, unicode)) else "unstable"
                self.node.set("disabled", msg, condition)
                self.node.new_disabled = True
            else:
                msg = "Conflicting metadata values for %s" % (
                    self.node.root.test_path)
                if e.cond:
                    msg += ": %s" % serialize(e.cond).strip()
                print(msg)

        # If all the values match remove all conditionals
        # This handles the case where we update a number of existing conditions and they
        # all end up looking like the post-update default.
        new_default = self.default_value
        if conditions and conditions[-1][0] is None:
            new_default = conditions[-1][1]
        if all(condition[1] == new_default for condition in conditions):
            conditions = [(None, new_default)]

        # Don't set the default to the class default
        if (conditions and conditions[-1][0] is None
                and conditions[-1][1] == self.default_value):
            self.node.modified = True
            conditions = conditions[:-1]

        if self.node.modified:
            self.node.clear(self.property_name)

            for condition, value in conditions:
                self.node.set(self.property_name, self.to_ini_value(value),
                              condition)
Пример #3
0
def write_new_expected(metadata_path, expected_map):
    # Serialize the data back to a file
    for tree in expected_map.itervalues():
        if not tree.is_empty:
            manifest_str = wptmanifest.serialize(tree.node, skip_empty_data=True)
            assert manifest_str != ""
            path = expected.expected_path(metadata_path, tree.test_path)
            dir = os.path.split(path)[0]
            if not os.path.exists(dir):
                os.makedirs(dir)
            with open(path, "w") as f:
                f.write(manifest_str.encode("utf8"))
Пример #4
0
def write_new_expected(metadata_path, expected_map):
    # Serialize the data back to a file
    for tree in expected_map.itervalues():
        if not tree.is_empty:
            manifest_str = wptmanifest.serialize(tree.node, skip_empty_data=True)
            assert manifest_str != ""
            path = expected.expected_path(metadata_path, tree.test_path)
            dir = os.path.split(path)[0]
            if not os.path.exists(dir):
                os.makedirs(dir)
            with open(path, "wb") as f:
                f.write(manifest_str)
Пример #5
0
def write_new_expected(metadata_path, expected):
    # Serialize the data back to a file
    path = expected_path(metadata_path, expected.test_path)
    if not expected.is_empty:
        manifest_str = wptmanifest.serialize(expected.node, skip_empty_data=True)
        assert manifest_str != ""
        dir = os.path.split(path)[0]
        if not os.path.exists(dir):
            os.makedirs(dir)
        tmp_path = path + ".tmp"
        try:
            with open(tmp_path, "wb") as f:
                f.write(manifest_str)
            os.rename(tmp_path, path)
        except (Exception, KeyboardInterrupt):
            try:
                os.unlink(tmp_path)
            except OSError:
                pass
    else:
        try:
            os.unlink(path)
        except OSError:
            pass