Bug 1839315: part 4) Link from `SheetLoadData::mWasAlternate` to spec. r=emilio DONTBUILD
[gecko.git] / tools / tryselect / test / test_tasks.py
blobcdf8cf84c1cadeb26660d4a15d14deb8c7f4a8d7
1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 import os
7 import mozunit
8 import pytest
9 from tryselect.tasks import cache_key, filter_tasks_by_paths, resolve_tests_by_suite
12 def test_filter_tasks_by_paths(patch_resolver):
13 tasks = ["foobar/xpcshell-1", "foobar/mochitest", "foobar/xpcshell"]
15 patch_resolver(["xpcshell"], {})
16 assert list(filter_tasks_by_paths(tasks, "dummy")) == []
18 patch_resolver([], [{"flavor": "xpcshell"}])
19 assert list(filter_tasks_by_paths(tasks, "dummy")) == [
20 "foobar/xpcshell-1",
21 "foobar/xpcshell",
25 @pytest.mark.parametrize(
26 "input, tests, expected",
28 pytest.param(
29 ["xpcshell.js"],
30 [{"flavor": "xpcshell", "srcdir_relpath": "xpcshell.js"}],
31 {"xpcshell": ["xpcshell.js"]},
32 id="single test",
34 pytest.param(
35 ["xpcshell.ini"],
38 "flavor": "xpcshell",
39 "srcdir_relpath": "xpcshell.js",
40 "manifest_relpath": "xpcshell.ini",
43 {"xpcshell": ["xpcshell.ini"]},
44 id="single manifest",
46 pytest.param(
47 ["xpcshell.js", "mochitest.js"],
49 {"flavor": "xpcshell", "srcdir_relpath": "xpcshell.js"},
50 {"flavor": "mochitest", "srcdir_relpath": "mochitest.js"},
53 "xpcshell": ["xpcshell.js"],
54 "mochitest-plain": ["mochitest.js"],
56 id="two tests",
58 pytest.param(
59 ["test/xpcshell.ini"],
62 "flavor": "xpcshell",
63 "srcdir_relpath": "test/xpcshell.js",
64 "manifest_relpath": os.path.join("test", "xpcshell.ini"),
67 {"xpcshell": ["test/xpcshell.ini"]},
68 id="mismatched path separators",
72 def test_resolve_tests_by_suite(patch_resolver, input, tests, expected):
73 patch_resolver([], tests)
74 assert resolve_tests_by_suite(input) == expected
77 @pytest.mark.parametrize(
78 "attr,params,disable_target_task_filter,expected",
80 ("target_task_set", None, False, "target_task_set"),
81 ("target_task_set", {"project": "autoland"}, False, "target_task_set"),
82 ("target_task_set", {"project": "mozilla-central"}, False, "target_task_set"),
83 ("target_task_set", None, True, "target_task_set-uncommon"),
84 ("full_task_set", {"project": "pine"}, False, "full_task_set-pine"),
85 ("full_task_set", None, True, "full_task_set"),
88 def test_cache_key(attr, params, disable_target_task_filter, expected):
89 assert cache_key(attr, params, disable_target_task_filter) == expected
92 if __name__ == "__main__":
93 mozunit.main()