File: test_mach_try_auto.py

package info (click to toggle)
firefox 147.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,683,484 kB
  • sloc: cpp: 7,607,246; javascript: 6,533,185; ansic: 3,775,227; python: 1,415,393; xml: 634,561; asm: 438,951; java: 186,241; sh: 62,752; makefile: 18,079; objc: 13,092; perl: 12,808; yacc: 4,583; cs: 3,846; pascal: 3,448; lex: 1,720; ruby: 1,003; php: 436; lisp: 258; awk: 247; sql: 66; sed: 54; csh: 10; exp: 6
file content (117 lines) | stat: -rw-r--r-- 3,796 bytes parent folder | download | duplicates (3)
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# Any copyright is dedicated to the public domain.
# http://creativecommons.org/publicdomain/zero/1.0/

import pytest
from gecko_taskgraph.util.bugbug import push_schedules
from gecko_taskgraph.util.chunking import BugbugLoader
from mozunit import main
from tryselect.selectors.auto import TRY_AUTO_PARAMETERS

pytestmark = pytest.mark.slow
PARAMS = TRY_AUTO_PARAMETERS.copy()
PARAMS.update(
    {
        "files_changed": [
            "dom/html/HTMLDetailsElement.cpp",
            "gfx/thebes/gfxUserFontSet.cpp",
        ],
        "head_repository": "https://hg.mozilla.org/try",
        "project": "try",
        "target_kind": "mochitest",
        # These ensure this isn't considered a backstop. The pushdate must
        # be slightly higher than the one in data/pushes.json, and
        # pushlog_id must not be a multiple of 10.
        "pushdate": 1593029536,
        "pushlog_id": "2",
    }
)


def test_generate_graph(optimized_task_graph):
    """Simply tests that generating the graph does not fail."""
    assert len(optimized_task_graph.tasks) > 0


def test_only_important_manifests(params, full_task_graph, filter_tasks):
    data = push_schedules(params["project"], params["head_rev"])
    important_manifests = {
        m
        for m, c in data.get("groups", {}).items()
        if c >= BugbugLoader.CONFIDENCE_THRESHOLD
    }

    # Ensure we don't schedule unimportant manifests.
    for task in filter_tasks(full_task_graph, lambda t: t.kind == "mochitest"):
        attr = task.attributes.get

        if "test_manifests" in task.attributes:
            unimportant = [
                t for t in attr("test_manifests") if t not in important_manifests
            ]

            # Manifest scheduling is disabled for mochitest-ally.
            if attr("unittest_suite") in ["mochitest-a11y"]:
                assert len(unimportant) > 0
            else:
                assert unimportant == []


@pytest.mark.parametrize(
    "func,min_expected",
    (
        pytest.param(
            lambda t: (
                t.kind == "mochitest"
                and t.attributes["unittest_suite"] == "mochitest-browser-chrome"
            ),
            5,
            id="mochitest-browser-chrome",
        ),
    ),
)
def test_tasks_are_scheduled(optimized_task_graph, filter_tasks, func, min_expected):
    """Ensure the specified tasks are scheduled on mozilla-central."""
    tasks = [t.label for t in filter_tasks(optimized_task_graph, func)]
    assert len(tasks) >= min_expected


@pytest.mark.parametrize(
    "func",
    (
        pytest.param(
            lambda t: t.kind == "build"
            and "shippable" in t.attributes["build_platform"],
            id="no shippable builds",
        ),
        pytest.param(
            lambda t: t.kind == "build" and "fuzzing" in t.attributes["build_platform"],
            id="no fuzzing builds",
        ),
        pytest.param(
            lambda t: t.kind == "build" and "ccov" in t.attributes["build_platform"],
            id="no ccov builds",
        ),
        # We should only assert that we have no signed builds on platforms that don't run
        # xpcshell tests.
        pytest.param(
            lambda t: t.kind == "build-signing",
            id="no build-signing",
            marks=pytest.mark.xfail(reason="some xpcshell tests require signed builds"),
        ),
        pytest.param(
            lambda t: t.kind == "upload-symbols",
            id="no upload-symbols",
        ),
    ),
)
def test_tasks_are_not_scheduled(
    optimized_task_graph, filter_tasks, print_dependents, func
):
    tasks = [t.label for t in filter_tasks(optimized_task_graph, func)]
    for t in tasks:
        print_dependents(optimized_task_graph, t)
    assert tasks == []


if __name__ == "__main__":
    main()