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/.
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")) == [
25 @pytest.mark
.parametrize(
26 "input, tests, expected",
30 [{"flavor": "xpcshell", "srcdir_relpath": "xpcshell.js"}],
31 {"xpcshell": ["xpcshell.js"]},
39 "srcdir_relpath": "xpcshell.js",
40 "manifest_relpath": "xpcshell.ini",
43 {"xpcshell": ["xpcshell.ini"]},
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"],
59 ["test/xpcshell.ini"],
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__":