fune/tools/tryselect/test/test_push.py
Andrew Halberstadt 7e9c59f478 Bug 1752677 - Add a task config to set the 'existing_tasks' parameter, r=releng-reviewers,bhearsum,jcristau
This adds the `-E/--use-existing-tasks` flag to the `fuzzy` or `chooser`
selectors. For example:

  ./mach try fuzzy -E

This queries the Treeherder API to find your latest try push, then any tasks
that exist on that push, but aren't explicitly selected this time, will be
replaced with those older tasks.

You can also run:

  ./mach try fuzzy -E task-id=<task id>

Where `<task id>` is the id of the Decision task from the push you would like
to use as the base.

Differential Revision: https://phabricator.services.mozilla.com/D200380
2024-02-03 02:29:38 +00:00

54 lines
1.4 KiB
Python

import mozunit
import pytest
from tryselect import push
@pytest.mark.parametrize(
"method,labels,params,routes,expected",
(
pytest.param(
"fuzzy",
["task-foo", "task-bar"],
None,
None,
{
"parameters": {
"optimize_target_tasks": False,
"try_task_config": {
"env": {"TRY_SELECTOR": "fuzzy"},
"tasks": ["task-bar", "task-foo"],
},
},
"version": 2,
},
id="basic",
),
pytest.param(
"fuzzy",
["task-foo"],
{"existing_tasks": {"task-foo": "123", "task-bar": "abc"}},
None,
{
"parameters": {
"existing_tasks": {"task-bar": "abc"},
"optimize_target_tasks": False,
"try_task_config": {
"env": {"TRY_SELECTOR": "fuzzy"},
"tasks": ["task-foo"],
},
},
"version": 2,
},
id="existing_tasks",
),
),
)
def test_generate_try_task_config(method, labels, params, routes, expected):
assert (
push.generate_try_task_config(method, labels, params=params, routes=routes)
== expected
)
if __name__ == "__main__":
mozunit.main()