summaryrefslogtreecommitdiffstats
path: root/testing/mozharness/mozharness/mozilla/testing/verify_tools.py
blob: 3cf19351c5224c7d070d16356b5e80a7ac14fb7f (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
63
64
65
66
67
68
69
#!/usr/bin/env python
# ***** BEGIN LICENSE BLOCK *****
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
# ***** END LICENSE BLOCK *****

from mozharness.base.script import PostScriptAction
from mozharness.mozilla.testing.per_test_base import SingleTestMixin

verify_config_options = [
    [
        ["--verify"],
        {
            "action": "store_true",
            "dest": "verify",
            "default": False,
            "help": "Run additional verification on modified tests.",
        },
    ],
]


class VerifyToolsMixin(SingleTestMixin):
    """Utility functions for test verification."""

    def __init__(self):
        super(VerifyToolsMixin, self).__init__()

    @property
    def verify_enabled(self):
        try:
            return bool(self.config.get("verify"))
        except (AttributeError, KeyError, TypeError):
            return False

    @PostScriptAction("download-and-extract")
    def find_tests_for_verification(self, action, success=None):
        """
        For each file modified on this push, determine if the modified file
        is a test, by searching test manifests. Populate self.verify_suites
        with test files, organized by suite.

        This depends on test manifests, so can only run after test zips have
        been downloaded and extracted.
        """

        if not self.verify_enabled:
            return

        self.find_modified_tests()

    @property
    def verify_args(self):
        if not self.verify_enabled:
            return []

        # Limit each test harness run to 15 minutes, to avoid task timeouts
        # when executing long-running tests.
        MAX_TIME_PER_TEST = 900

        if self.config.get("per_test_category") == "web-platform":
            args = ["--verify-log-full"]
        else:
            args = ["--verify-max-time=%d" % MAX_TIME_PER_TEST]

        args.append("--verify")

        return args