summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/tools/wptrunner/wptrunner/update/metadata.py
blob: 48519900e7db5ad5f395ef03409b5c95fc9250af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# mypy: allow-untyped-defs

import os

from .. import metadata, products

from .base import Step, StepRunner


class GetUpdatePropertyList(Step):
    provides = ["update_properties"]

    def create(self, state):
        state.update_properties = products.load_product_update(state.config, state.product.name)


class UpdateExpected(Step):
    """Do the metadata update on the local checkout"""

    def create(self, state):
        metadata.update_expected(state.paths,
                                 state.run_log,
                                 update_properties=state.update_properties,
                                 full_update=state.full_update,
                                 disable_intermittent=state.disable_intermittent,
                                 update_intermittent=state.update_intermittent,
                                 remove_intermittent=state.remove_intermittent)


class CreateMetadataPatch(Step):
    """Create a patch/commit for the metadata checkout"""

    def create(self, state):
        if not state.patch:
            return

        local_tree = state.local_tree
        sync_tree = state.sync_tree

        if sync_tree is not None:
            name = "web-platform-tests_update_%s_metadata" % sync_tree.rev
            message = f"Update {state.suite_name} expected data to revision {sync_tree.rev}"
        else:
            name = "web-platform-tests_update_metadata"
            message = "Update %s expected data" % state.suite_name

        local_tree.create_patch(name, message)

        if not local_tree.is_clean:
            metadata_paths = [manifest_path["metadata_path"]
                              for manifest_path in state.paths.itervalues()]
            for path in metadata_paths:
                local_tree.add_new(os.path.relpath(path, local_tree.root))
            local_tree.update_patch(include=metadata_paths)
            local_tree.commit_patch()


class MetadataUpdateRunner(StepRunner):
    """(Sub)Runner for updating metadata"""
    steps = [GetUpdatePropertyList,
             UpdateExpected,
             CreateMetadataPatch]