summaryrefslogtreecommitdiffstats
path: root/tools/tryselect/test/test_tasks.py
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--tools/tryselect/test/test_tasks.py59
1 files changed, 59 insertions, 0 deletions
diff --git a/tools/tryselect/test/test_tasks.py b/tools/tryselect/test/test_tasks.py
new file mode 100644
index 0000000000..b338f8fc02
--- /dev/null
+++ b/tools/tryselect/test/test_tasks.py
@@ -0,0 +1,59 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+from __future__ import absolute_import, print_function, unicode_literals
+
+import mozunit
+
+from tryselect.tasks import filter_tasks_by_paths, resolve_tests_by_suite
+
+
+def test_filter_tasks_by_paths(patch_resolver):
+ tasks = ["foobar/xpcshell-1", "foobar/mochitest", "foobar/xpcshell"]
+
+ patch_resolver(["xpcshell"], {})
+ assert list(filter_tasks_by_paths(tasks, "dummy")) == []
+
+ patch_resolver([], [{"flavor": "xpcshell"}])
+ assert list(filter_tasks_by_paths(tasks, "dummy")) == [
+ "foobar/xpcshell-1",
+ "foobar/xpcshell",
+ ]
+
+
+def test_resolve_tests_by_suite(patch_resolver):
+ patch_resolver([], [{"flavor": "xpcshell", "srcdir_relpath": "xpcshell.js"}])
+ assert resolve_tests_by_suite(["xpcshell.js"]) == {
+ "xpcshell": ["xpcshell.js"],
+ }
+
+ patch_resolver(
+ [],
+ [
+ {
+ "flavor": "xpcshell",
+ "srcdir_relpath": "xpcshell.js",
+ "manifest_relpath": "xpcshell.ini",
+ },
+ ],
+ )
+ assert resolve_tests_by_suite(["xpcshell.ini"]) == {
+ "xpcshell": ["xpcshell.ini"],
+ }
+
+ patch_resolver(
+ [],
+ [
+ {"flavor": "xpcshell", "srcdir_relpath": "xpcshell.js"},
+ {"flavor": "mochitest", "srcdir_relpath": "mochitest.js"},
+ ],
+ )
+ assert resolve_tests_by_suite(["xpcshell.js", "mochitest.js"]) == {
+ "xpcshell": ["xpcshell.js"],
+ "mochitest-plain": ["mochitest.js"],
+ }
+
+
+if __name__ == "__main__":
+ mozunit.main()