tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_autoland.py (2166B)


      1 # Any copyright is dedicated to the public domain.
      2 # http://creativecommons.org/publicdomain/zero/1.0/
      3 
      4 import pytest
      5 from mozunit import main
      6 
      7 pytestmark = pytest.mark.slow
      8 PARAMS = {
      9    "head_repository": "https://hg.mozilla.org/integration/autoland",
     10    "project": "autoland",
     11    # These ensure this isn't considered a backstop. The pushdate must
     12    # be slightly higher than the one in data/pushes.json, and
     13    # pushlog_id must not be a multiple of 10.
     14    "pushdate": 1593029536,
     15    "pushlog_id": "2",
     16 }
     17 
     18 
     19 def test_tasks_have_optimization(full_task_graph, filter_tasks):
     20    kinds = (
     21        "artifact_build",
     22        "build-fat-aar",
     23        "build",
     24        "generate-profile",
     25        "hazard",
     26        "instrumented-build",
     27        "spidermonkey",
     28        "static-analysis-autotest",
     29        "test",
     30        "valgrind",
     31    )
     32    errors = []
     33    for task in filter_tasks(
     34        full_task_graph, lambda t: t.kind in kinds and "ccov" not in t.label
     35    ):
     36        if not task.optimization:
     37            errors.append(task.label)
     38 
     39    if errors:
     40        label_str = "\n  ".join(errors)
     41        s_are = " is" if len(errors) == 1 else "s are"
     42        pytest.fail(
     43            f"The following task{s_are} missing an optimization:\n  {label_str}"
     44        )
     45 
     46 
     47 def test_generate_graph(optimized_task_graph):
     48    """Simply tests that generating the graph does not fail."""
     49    assert len(optimized_task_graph.tasks) > 0
     50 
     51 
     52 @pytest.mark.parametrize(
     53    "func",
     54    (
     55        pytest.param(
     56            lambda t: t.kind == "build" and "fuzzing" in t.attributes["build_platform"],
     57            id="no fuzzing builds",
     58        ),
     59        pytest.param(
     60            lambda t: t.kind == "build" and "ccov" in t.attributes["build_platform"],
     61            id="no ccov builds",
     62        ),
     63    ),
     64 )
     65 def test_tasks_are_not_scheduled(
     66    optimized_task_graph, filter_tasks, print_dependents, func
     67 ):
     68    """Ensure the specified tasks are not scheduled on autoland."""
     69    tasks = [t.label for t in filter_tasks(optimized_task_graph, func)]
     70    for t in tasks:
     71        print_dependents(optimized_task_graph, t)
     72    assert tasks == []
     73 
     74 
     75 if __name__ == "__main__":
     76    main()