Bug 1575014 - Fix `./mach try --gecko-profile ...`. r=tomprince,ahal

An error crept in, resulting in:
```
[task ...] InterpreterError: InterpreterError: infix: [..] expects integer [..] integer
```

At some point, `suite` became a string name and not an object with a
string `name` member.  However, in the interim, the diversity of
`command` structures has made the template approach untenable.
Therefore, this commit converts `GeckoProfile` to a `TryConfig`.  The
existing test clearly wasn't helpful, and it doesn't really map to a
`TryConfig` test, so it was removed.

Differential Revision: https://phabricator.services.mozilla.com/D41603

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Nick Alexander 2019-09-25 20:18:17 +00:00
Родитель 4b9792db7c
Коммит 3bf9f51b30
6 изменённых файлов: 11 добавлений и 77 удалений

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

@ -131,6 +131,7 @@ try_task_config_schema = Schema({
Optional('templates'): {basestring: object},
Optional('disable-pgo'): bool,
Optional('browsertime'): bool,
Optional('gecko-profile'): bool,
# Keep in sync with JOB_SCHEMA in taskcluster/docker/visual-metrics/run-visual-metrics.py.
Optional('visual-metrics-jobs'): visual_metrics_jobs_schema,
Optional(

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

@ -1,36 +0,0 @@
---
$if: input && task["extra"]
then:
$if: task.extra["suite"]
then:
$if: task.extra.suite["name"] in ["talos", "raptor"]
then:
task:
# We can't use mergeDeep as that will append the command below
# instead of overwriting the original command.
$merge:
- $eval: task
- payload:
$merge:
- $eval: task.payload
- command:
$if: typeof(task.payload.command[0]) == 'array'
then:
# Command is an array of arrays. Assumes the command we want
# to append --gecko-profile to is the first one. Also assumes
# that we can't have a space delimited string here (which is
# the case for now at least).
- $flatten:
- $eval: task.payload.command[0]
- ["--gecko-profile"]
else:
$if: len(task.payload.command) == 1
then:
# Command is an array with a single space delimited string.
# This only happens on Windows.
- "${task.payload.command[0]} --gecko-profile"
else:
# Command is an array of strings.
$flatten:
- $eval: task.payload.command
- ["--gecko-profile"]

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

@ -117,7 +117,7 @@ TASKS = [
'attributes': {},
'task': {
'extra': {
'suite': {'name': 'talos'},
'suite': 'talos',
'treeherder': {
'group': 'tc',
'symbol': 't'
@ -199,34 +199,5 @@ def test_template_rebuild(get_morphed):
assert t.attributes['task_duplicates'] == 4
@pytest.mark.parametrize('command', (
['foo --bar'],
['foo', '--bar'],
[['foo']],
[['foo', '--bar']],
))
def test_template_gecko_profile(get_morphed, command):
tasks = TASKS[:]
for t in tasks:
t['task']['payload']['command'] = command
morphed = get_morphed({
'templates': {
'gecko-profile': True,
}
}, tasks)
for t in morphed.tasks.values():
command = t.task['payload']['command']
if isinstance(command[0], list):
command = command[0]
command = ' '.join(command)
if t.label == 'a':
assert not command.endswith('--gecko-profile')
elif t.label == 'b':
assert command.endswith('--gecko-profile')
if __name__ == '__main__':
main()

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

@ -1321,6 +1321,9 @@ def set_profile(config, tests):
profile = None
if config.params['try_mode'] == 'try_option_syntax':
profile = config.params['try_options']['profile']
else:
profile = config.params['try_task_config'].get('gecko-profile', False)
for test in tests:
if profile and test['suite'] in ['talos', 'raptor']:
test['mozharness']['extra-options'].append('--geckoProfile')

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

@ -193,7 +193,7 @@ class ChemspillPrio(Template):
}
class GeckoProfile(Template):
class GeckoProfile(TryConfig):
arguments = [
[['--gecko-profile'],
{'dest': 'profile',
@ -217,10 +217,11 @@ class GeckoProfile(Template):
}],
]
def context(self, profile, **kwargs):
if not profile:
return
return {'gecko-profile': profile}
def try_config(self, profile, **kwargs):
if profile:
return {
'gecko-profile': True,
}
class Browsertime(TryConfig):

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

@ -40,12 +40,6 @@ TEMPLATE_TESTS = {
(['--rebuild', '1'], SystemExit),
(['--rebuild', '21'], SystemExit),
],
'gecko-profile': [
([], None),
(['--talos-profile'], {'gecko-profile': True}),
(['--geckoProfile'], {'gecko-profile': True}),
(['--gecko-profile'], {'gecko-profile': True}),
],
}