tools/compare-locales/mach_commands.py
author Lukasz Anforowicz <lukasza@chromium.org>
Mon, 09 Apr 2018 14:33:07 +0000
changeset 466985 861650deaddc7dfc160136f40bf3f7c83c504e09
parent 433051 c6d94140d11b651cae7bdf8b44ddc028ebea94eb
child 496287 84e2040e592add53094c718a6d766d9559ab2498
permissions -rw-r--r--
Bug 1452097 [wpt PR 9952] - Make 2 tests immune to legitimate races between cross-origin subframes, a=testonly Automatic update from web-platform-testsMake 2 tests immune to legitimate races between cross-origin subframes Bug: 820589 Change-Id: I16c02746c61f42fafead5f96ae436b331fba4f85 Reviewed-on: https://chromium-review.googlesource.com/957587 Commit-Queue: Ɓukasz Anforowicz <lukasza@chromium.org> Reviewed-by: Alex Moshchuk <alexmos@chromium.org> Cr-Commit-Position: refs/heads/master@{#542360} wpt-commits: 1f638e87c2b4411c53121108efc7aa19df8bc543 wpt-pr: 9952 wpt-commits: 1f638e87c2b4411c53121108efc7aa19df8bc543 wpt-pr: 9952

# 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

from mach.decorators import (
    CommandArgument,
    CommandProvider,
    Command,
)

from mach.base import (
    FailedCommandError,
)


@CommandProvider
class CompareLocales(object):
    """Run compare-locales."""

    @Command('compare-locales', category='testing',
             description='Run source checks on a localization.')
    @CommandArgument('config_paths', metavar='l10n.toml', nargs='+',
                     help='TOML or INI file for the project')
    @CommandArgument('l10n_base_dir', metavar='l10n-base-dir',
                     help='Parent directory of localizations')
    @CommandArgument('locales', nargs='*', metavar='locale-code',
                     help='Locale code and top-level directory of '
                          'each localization')
    @CommandArgument('-m', '--merge',
                     help='''Use this directory to stage merged files''')
    @CommandArgument('-D', action='append', metavar='var=value',
                     default=[], dest='defines',
                     help='Overwrite variables in TOML files')
    @CommandArgument('--unified', action="store_true",
                     help="Show output for all projects unified")
    @CommandArgument('--full', action="store_true",
                     help="Compare projects that are disabled")
    def compare(self, **kwargs):
        from compare_locales.commands import CompareLocales

        class ErrorHelper(object):
            '''Dummy ArgumentParser to marshall compare-locales
            commandline errors to mach exceptions.
            '''
            def error(self, msg):
                raise FailedCommandError(msg)

            def exit(self, message=None, status=0):
                raise FailedCommandError(message, exit_code=status)

        cmd = CompareLocales()
        cmd.parser = ErrorHelper()
        return cmd.handle(**kwargs)