Bug 1640580 - [taskgraph.util.bugbug] Translate WPT paths from relative source directory to WPT ids, r=marco

Differential Revision: https://phabricator.services.mozilla.com/D76719
This commit is contained in:
Andrew Halberstadt 2020-05-25 15:44:58 +00:00
Родитель 653970f0b9
Коммит 3901f12775
3 изменённых файлов: 61 добавлений и 0 удалений

Просмотреть файл

@ -19,6 +19,7 @@ subsuite = taskgraph
[test_transforms_job.py]
[test_try_option_syntax.py]
[test_util_attributes.py]
[test_util_bugbug.py]
[test_util_docker.py]
[test_util_parameterization.py]
[test_util_python_path.py]

Просмотреть файл

@ -0,0 +1,44 @@
# 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 taskgraph.util.bugbug import (
BUGBUG_BASE_URL,
push_schedules,
)
def test_group_translation(responses):
branch = "integration/autoland",
rev = "abcdef"
query = "/push/{}/{}/schedules".format(branch, rev)
url = BUGBUG_BASE_URL + query
responses.add(
responses.GET,
url,
json={
"groups": {
"dom/indexedDB": 1,
"testing/web-platform/tests/IndexedDB": 1,
"testing/web-platform/mozilla/tests/IndexedDB": 1,
}
},
status=200,
)
data = push_schedules(branch, rev)
print(data)
assert sorted(data["groups"]) == [
"/IndexedDB",
"/_mozilla/IndexedDB",
"dom/indexedDB",
]
if __name__ == '__main__':
mozunit.main()

Просмотреть файл

@ -24,6 +24,19 @@ CT_LOW = 0.5
CT_MEDIUM = 0.7
CT_HIGH = 0.9
GROUP_TRANSLATIONS = {
"testing/web-platform/tests": "",
"testing/web-platform/mozilla/tests": "/_mozilla",
}
def translate_group(group):
for prefix, value in GROUP_TRANSLATIONS.items():
if group.startswith(prefix):
return group.replace(prefix, value)
return group
class BugbugTimeoutException(Exception):
pass
@ -60,4 +73,7 @@ def push_schedules(branch, rev):
if r.status_code == 202:
raise BugbugTimeoutException("Timed out waiting for result from '{}'".format(url))
if "groups" in data:
data["groups"] = {translate_group(k): v for k, v in data["groups"].items()}
return data