diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
commit | 40a355a42d4a9444dc753c04c6608dade2f06a23 (patch) | |
tree | 871fc667d2de662f171103ce5ec067014ef85e61 /tools/tryselect/test/test_tasks.py | |
parent | Adding upstream version 124.0.1. (diff) | |
download | firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.tar.xz firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.zip |
Adding upstream version 125.0.1.upstream/125.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tools/tryselect/test/test_tasks.py')
-rw-r--r-- | tools/tryselect/test/test_tasks.py | 98 |
1 files changed, 97 insertions, 1 deletions
diff --git a/tools/tryselect/test/test_tasks.py b/tools/tryselect/test/test_tasks.py index 2e99c72d8b..ecf5849741 100644 --- a/tools/tryselect/test/test_tasks.py +++ b/tools/tryselect/test/test_tasks.py @@ -6,7 +6,103 @@ import os import mozunit import pytest -from tryselect.tasks import cache_key, filter_tasks_by_paths, resolve_tests_by_suite +from tryselect.tasks import ( + cache_key, + filter_tasks_by_paths, + filter_tasks_by_worker_type, + resolve_tests_by_suite, +) + + +class task: + def __init__(self, workerType): + self.workerType = workerType + + @property + def task(self): + return {"workerType": self.workerType} + + +@pytest.mark.parametrize( + "tasks, params, expected", + ( + pytest.param( + { + "foobar/xpcshell-1": task("t-unittest-314"), + "foobar/mochitest": task("t-unittest-157"), + "foobar/xpcshell-gpu": task("t-unittest-314-gpu"), + "foobar/xpcshell": task("t-unittest-314"), + }, + {"try_task_config": {"worker-types": ["t-unittest-314"]}}, + [ + "foobar/xpcshell-1", + "foobar/xpcshell", + ], + id="single worker", + ), + pytest.param( + { + "foobar/xpcshell-1": task("t-unittest-314"), + "foobar/mochitest": task("t-unittest-157"), + "foobar/xpcshell-gpu": task("t-unittest-314-gpu"), + "foobar/xpcshell": task("t-unittest-314"), + }, + { + "try_task_config": { + "worker-types": ["t-unittest-314", "t-unittest-314-gpu"] + } + }, + [ + "foobar/xpcshell-1", + "foobar/xpcshell-gpu", + "foobar/xpcshell", + ], + id="multiple workers worker", + ), + pytest.param( + { + "foobar/xpcshell-1": task("t-unittest-314"), + "foobar/mochitest": task("t-unittest-157"), + "foobar/xpcshell-gpu": task("t-unittest-314-gpu"), + "foobar/xpcshell": task("t-unittest-314"), + }, + {"try_task_config": {"worker-types": ["t-unittest-157"]}}, + [ + "foobar/mochitest", + ], + id="single task", + ), + pytest.param( + { + "foobar/xpcshell-1": task("t-unittest-314"), + "foobar/mochitest": task("t-unittest-157"), + "foobar/xpcshell-gpu": task("t-unittest-314-gpu"), + "foobar/xpcshell": task("t-unittest-314"), + }, + {"try_task_config": {"worker-types": []}}, + [ + "foobar/xpcshell-1", + "foobar/mochitest", + "foobar/xpcshell-gpu", + "foobar/xpcshell", + ], + id="no worker", + ), + pytest.param( + { + "foobar/xpcshell-1": task("t-unittest-314"), + "foobar/mochitest": task("t-unittest-157"), + "foobar/xpcshell-gpu": task("t-unittest-314-gpu"), + "foobar/xpcshell": task("t-unittest-314"), + }, + {"try_task_config": {"worker-types": ["fake-worker"]}}, + [], + id="invalid worker", + ), + ), +) +def test_filter_tasks_by_worker_type(patch_resolver, tasks, params, expected): + assert list(filter_tasks_by_worker_type(tasks, params)) == expected def test_filter_tasks_by_paths(patch_resolver): |