test_mach_try_auto.py (3738B)
1 # Any copyright is dedicated to the public domain. 2 # http://creativecommons.org/publicdomain/zero/1.0/ 3 4 import pytest 5 from gecko_taskgraph.util.bugbug import push_schedules 6 from gecko_taskgraph.util.chunking import BugbugLoader 7 from mozunit import main 8 from tryselect.selectors.auto import TRY_AUTO_PARAMETERS 9 10 pytestmark = pytest.mark.slow 11 PARAMS = TRY_AUTO_PARAMETERS.copy() 12 PARAMS.update({ 13 "files_changed": [ 14 "dom/html/HTMLDetailsElement.cpp", 15 "gfx/thebes/gfxUserFontSet.cpp", 16 ], 17 "head_repository": "https://hg.mozilla.org/try", 18 "project": "try", 19 "target_kind": "mochitest", 20 # These ensure this isn't considered a backstop. The pushdate must 21 # be slightly higher than the one in data/pushes.json, and 22 # pushlog_id must not be a multiple of 10. 23 "pushdate": 1593029536, 24 "pushlog_id": "2", 25 }) 26 27 28 def test_generate_graph(optimized_task_graph): 29 """Simply tests that generating the graph does not fail.""" 30 assert len(optimized_task_graph.tasks) > 0 31 32 33 def test_only_important_manifests(params, full_task_graph, filter_tasks): 34 data = push_schedules(params["project"], params["head_rev"]) 35 important_manifests = { 36 m 37 for m, c in data.get("groups", {}).items() 38 if c >= BugbugLoader.CONFIDENCE_THRESHOLD 39 } 40 41 # Ensure we don't schedule unimportant manifests. 42 for task in filter_tasks(full_task_graph, lambda t: t.kind == "mochitest"): 43 attr = task.attributes.get 44 45 if "test_manifests" in task.attributes: 46 unimportant = [ 47 t for t in attr("test_manifests") if t not in important_manifests 48 ] 49 50 # Manifest scheduling is disabled for mochitest-ally. 51 if attr("unittest_suite") in ["mochitest-a11y"]: 52 assert len(unimportant) > 0 53 else: 54 assert unimportant == [] 55 56 57 @pytest.mark.parametrize( 58 "func,min_expected", 59 ( 60 pytest.param( 61 lambda t: ( 62 t.kind == "mochitest" 63 and t.attributes["unittest_suite"] == "mochitest-browser-chrome" 64 ), 65 5, 66 id="mochitest-browser-chrome", 67 ), 68 ), 69 ) 70 def test_tasks_are_scheduled(optimized_task_graph, filter_tasks, func, min_expected): 71 """Ensure the specified tasks are scheduled on mozilla-central.""" 72 tasks = [t.label for t in filter_tasks(optimized_task_graph, func)] 73 assert len(tasks) >= min_expected 74 75 76 @pytest.mark.parametrize( 77 "func", 78 ( 79 pytest.param( 80 lambda t: t.kind == "build" 81 and "shippable" in t.attributes["build_platform"], 82 id="no shippable builds", 83 ), 84 pytest.param( 85 lambda t: t.kind == "build" and "fuzzing" in t.attributes["build_platform"], 86 id="no fuzzing builds", 87 ), 88 pytest.param( 89 lambda t: t.kind == "build" and "ccov" in t.attributes["build_platform"], 90 id="no ccov builds", 91 ), 92 # We should only assert that we have no signed builds on platforms that don't run 93 # xpcshell tests. 94 pytest.param( 95 lambda t: t.kind == "build-signing", 96 id="no build-signing", 97 marks=pytest.mark.xfail(reason="some xpcshell tests require signed builds"), 98 ), 99 pytest.param( 100 lambda t: t.kind == "upload-symbols", 101 id="no upload-symbols", 102 ), 103 ), 104 ) 105 def test_tasks_are_not_scheduled( 106 optimized_task_graph, filter_tasks, print_dependents, func 107 ): 108 tasks = [t.label for t in filter_tasks(optimized_task_graph, func)] 109 for t in tasks: 110 print_dependents(optimized_task_graph, t) 111 assert tasks == [] 112 113 114 if __name__ == "__main__": 115 main()