Bug 1617229 - [tryselect] Remove no longer needed preset migration code r=gbrown

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Andrew Halberstadt 2020-02-21 19:42:19 +00:00
parent 58b6e80452
commit 63ccd789be
4 changed files with 0 additions and 151 deletions

View File

@ -101,14 +101,9 @@ class TrySelect(MachCommandBase):
special preset handling. They can all save and load presets the same
way.
"""
from tryselect.preset import migrate_old_presets
from tryselect.util.dicttools import merge
user_presets = self.presets.handlers[0]
# TODO: Remove after Jan 1, 2020.
migrate_old_presets(user_presets)
if preset_action == 'list':
self.presets.list()
sys.exit()

View File

@ -4,13 +4,10 @@
from __future__ import absolute_import, print_function, unicode_literals
import ConfigParser
import os
import subprocess
from collections import defaultdict
import yaml
from mozboot.util import get_state_dir
class PresetHandler(object):
@ -97,49 +94,3 @@ class MergedHandler(object):
val = '\n '.join([''] + val.splitlines() + ['']) # indent all lines by 2 spaces
print("Presets from {}:".format(handler.path))
print(val)
def migrate_old_presets(presets):
"""Move presets from the old `autotry.ini` format to the new
`try_presets.yml` one.
Args:
presets (PresetHandler): Handler to migrate old presets into.
"""
from .selectors.syntax import AutoTry, SyntaxParser
old_preset_path = os.path.join(get_state_dir(), 'autotry.ini')
if os.path.isfile(presets.path) or not os.path.isfile(old_preset_path):
return
print("migrating saved presets from '{}' to '{}'".format(old_preset_path, presets.path))
config = ConfigParser.ConfigParser()
config.read(old_preset_path)
unknown = defaultdict(list)
for section in config.sections():
for name, value in config.items(section):
kwargs = {}
if section == 'fuzzy': # try fuzzy
kwargs['query'] = [value]
kwargs['selector'] = 'fuzzy'
elif section == 'try': # try syntax
parser = SyntaxParser()
kwargs = vars(parser.parse_args(AutoTry.split_try_string(value)))
kwargs = {k: v for k, v in kwargs.items() if v != parser.get_default(k)}
kwargs['selector'] = 'syntax'
else:
unknown[section].append("{} = {}".format(name, value))
continue
presets.save(name, **kwargs)
os.remove(old_preset_path)
if unknown:
for section, values in unknown.items():
print("""
warning: unknown section '{}', the following presets were not migrated:
{}
""".format(section, '\n '.join(values)).lstrip())

View File

@ -2,4 +2,3 @@
[test_fuzzy.t]
[test_message.t]
[test_preset.t]
[test_preset_migration.t]

View File

@ -1,96 +0,0 @@
$ . $TESTDIR/setup.sh
$ cd $topsrcdir
Test migration of syntax preset
$ cat > $MOZBUILD_STATE_PATH/autotry.ini << EOF
> [try]
> foo = -b o -p all -u mochitest -t none --tag bar
> EOF
$ ls $MOZBUILD_STATE_PATH/autotry.ini
*/mozbuild/autotry.ini (glob)
$ ./mach try syntax $testargs --list-presets
migrating saved presets from '*/mozbuild/autotry.ini' to '*/mozbuild/try_presets.yml' (glob)
Presets from */mozbuild/try_presets.yml: (glob)
foo:
builds: o
platforms:
- all
selector: syntax
tags:
- bar
talos:
- none
tests:
- mochitest
$ ./mach try syntax $testargs --preset foo
Commit message:
try: -b o -p all -u mochitest -t none --tag bar
Pushed via `mach try syntax`
$ ls $MOZBUILD_STATE_PATH/autotry.ini
*/mozbuild/autotry.ini': No such file or directory (glob)
[2]
Test migration of fuzzy preset
$ rm $MOZBUILD_STATE_PATH/try_presets.yml
$ cat > $MOZBUILD_STATE_PATH/autotry.ini << EOF
> [fuzzy]
> foo = 'foo | 'bar
> EOF
$ ls $MOZBUILD_STATE_PATH/autotry.ini
*/mozbuild/autotry.ini (glob)
$ ./mach try fuzzy $testargs --preset foo
migrating saved presets from '*/mozbuild/autotry.ini' to '*/mozbuild/try_presets.yml' (glob)
Commit message:
Fuzzy query='foo | 'bar
Pushed via `mach try fuzzy`
Calculated try_task_config.json:
{
"env": {
"TRY_SELECTOR": "fuzzy"
},
"tasks": [
"test/foo-debug",
"test/foo-opt"
],
"version": 1
}
$ ls $MOZBUILD_STATE_PATH/autotry.ini
*/mozbuild/autotry.ini': No such file or directory (glob)
[2]
$ ./mach try fuzzy $testargs --list-presets
Presets from */mozbuild/try_presets.yml: (glob)
foo:
query:
- '''foo | ''bar'
selector: fuzzy
Test unknown section prints message
$ rm $MOZBUILD_STATE_PATH/try_presets.yml
$ cat > $MOZBUILD_STATE_PATH/autotry.ini << EOF
> [unknown]
> foo = bar
> baz = foo
> [again]
> invalid = ?
> EOF
$ ./mach try $testargs
migrating saved presets from '*/mozbuild/autotry.ini' to '*/mozbuild/try_presets.yml' (glob)
warning: unknown section 'unknown', the following presets were not migrated:
foo = bar
baz = foo
warning: unknown section 'again', the following presets were not migrated:
invalid = ?
Either platforms or jobs must be specified as an argument to autotry.
[1]