--- a/python/mach/mach/commands/commandinfo.py
+++ b/python/mach/mach/commands/commandinfo.py
@@ -18,24 +18,24 @@ class BuiltinCommands(object):
@property
def command_keys(self):
# NOTE 'REMOVED' is a function in testing/mochitest/mach_commands.py
return (k for k, v in self.context.commands.command_handlers.items()
if not v.conditions or v.conditions[0].__name__ != 'REMOVED')
@Command('mach-commands', category='misc',
- description='List all mach commands.')
+ description='List all mach commands.')
def commands(self):
print("\n".join(self.command_keys))
@Command('mach-debug-commands', category='misc',
- description='Show info about available mach commands.')
+ description='Show info about available mach commands.')
@CommandArgument('match', metavar='MATCH', default=None, nargs='?',
- help='Only display commands containing given substring.')
+ help='Only display commands containing given substring.')
def debug_commands(self, match=None):
import inspect
handlers = self.context.commands.command_handlers
for command in sorted(self.command_keys):
if match and match not in command:
continue
@@ -45,9 +45,8 @@ class BuiltinCommands(object):
print(command)
print('=' * len(command))
print('')
print('File: %s' % inspect.getsourcefile(method))
print('Class: %s' % cls.__name__)
print('Method: %s' % handler.method)
print('')
-
--- a/python/mach/mach/config.py
+++ b/python/mach/mach/config.py
@@ -269,17 +269,16 @@ class ConfigSettings(collections.Mapping
@reraise_attribute_error
def __setattr__(self, k, v):
self.__setitem__(k, v)
@reraise_attribute_error
def __delattr__(self, k):
self.__delitem__(k)
-
def __init__(self):
self._config = RawConfigParser()
self._config.optionxform = str
self._settings = {}
self._sections = {}
self._finalized = False
self.loaded_files = set()
--- a/python/mach/mach/decorators.py
+++ b/python/mach/mach/decorators.py
@@ -2,17 +2,16 @@
# 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, unicode_literals
import argparse
import collections
import inspect
-import os
import types
from .base import MachError
from .registrar import Registrar
class _MachCommand(object):
"""Container for mach command metadata.
@@ -180,17 +179,17 @@ def CommandProvider(cls):
continue
# It is a regular command.
if not command.subcommand:
continue
if command.name not in seen_commands:
raise MachError('Command referenced by sub-command does not '
- 'exist: %s' % command.name)
+ 'exist: %s' % command.name)
if command.name not in Registrar.command_handlers:
continue
command.cls = cls
command.method = attr
command.pass_context = pass_context
parent = Registrar.command_handlers[command.name]
@@ -230,16 +229,17 @@ class Command(object):
def __call__(self, func):
if not hasattr(func, '_mach_command'):
func._mach_command = _MachCommand()
func._mach_command |= self._mach_command
return func
+
class SubCommand(object):
"""Decorator for functions or methods that provide a sub-command.
Mach commands can have sub-commands. e.g. ``mach command foo`` or
``mach command bar``. Each sub-command has its own parser and is
effectively its own mach command.
The decorator accepts arguments that define basic attributes of the
@@ -259,16 +259,17 @@ class SubCommand(object):
def __call__(self, func):
if not hasattr(func, '_mach_command'):
func._mach_command = _MachCommand()
func._mach_command |= self._mach_command
return func
+
class CommandArgument(object):
"""Decorator for additional arguments to mach subcommands.
This decorator should be used to add arguments to mach commands. Arguments
to the decorator are proxied to ArgumentParser.add_argument().
For example:
@@ -338,9 +339,8 @@ def SettingsProvider(cls):
raise MachError('@SettingsProvider must contain a config_settings attribute. It '
'may either be a list of tuples, or a callable that returns a list '
'of tuples. Each tuple must be of the form:\n'
'(<section>.<option>, <type_cls>, <description>, <default>, <choices>)\n'
'as specified by ConfigSettings._format_metadata.')
Registrar.register_settings_provider(cls)
return cls
-
--- a/python/mach/mach/dispatcher.py
+++ b/python/mach/mach/dispatcher.py
@@ -63,25 +63,25 @@ class CommandAction(argparse.Action):
this class is instantiated. One of the subtle but important things it does
is tell the argument parser that it's interested in *all* of the remaining
program arguments. So, when the ArgumentParser calls this action, we will
receive the command name plus all of its arguments.
For more, read the docs in __call__.
"""
def __init__(self, option_strings, dest, required=True, default=None,
- registrar=None, context=None):
+ registrar=None, context=None):
# A proper API would have **kwargs here. However, since we are a little
# hacky, we intentionally omit it as a way of detecting potentially
# breaking changes with argparse's implementation.
#
# In a similar vein, default is passed in but is not needed, so we drop
# it.
argparse.Action.__init__(self, option_strings, dest, required=required,
- help=argparse.SUPPRESS, nargs=argparse.REMAINDER)
+ help=argparse.SUPPRESS, nargs=argparse.REMAINDER)
self._mach_registrar = registrar
self._context = context
def __call__(self, parser, namespace, values, option_string=None):
"""This is called when the ArgumentParser has reached our arguments.
Since we always register ourselves with nargs=argparse.REMAINDER,
@@ -271,17 +271,17 @@ class CommandAction(argparse.Action):
continue
if group is None:
title, description, _priority = r.categories[category]
group = parser.add_argument_group(title, description)
description = handler.description
group.add_argument(command, help=description,
- action='store_true')
+ action='store_true')
if disabled_commands and 'disabled' in r.categories:
title, description, _priority = r.categories['disabled']
group = parser.add_argument_group(title, description)
if verbose:
for c in disabled_commands:
group.add_argument(c['command'], help=c['description'],
action='store_true')
@@ -371,17 +371,17 @@ class CommandAction(argparse.Action):
def _handle_subcommand_main_help(self, parser, handler):
parser.usage = '%(prog)s [global arguments] ' + handler.name + \
' subcommand [subcommand arguments]'
group = parser.add_argument_group('Sub Commands')
for subcommand, subhandler in sorted(handler.subcommand_handlers.iteritems()):
group.add_argument(subcommand, help=subhandler.description,
- action='store_true')
+ action='store_true')
if handler.docstring:
parser.description = format_docstring(handler.docstring)
parser.formatter_class = argparse.RawDescriptionHelpFormatter
parser.print_help()
@@ -408,17 +408,17 @@ class CommandAction(argparse.Action):
parser.print_help()
print('')
c_parser.print_help()
def _suggest_command(self, command):
# Make sure we don't suggest any deprecated commands.
names = [h.name for h in self._mach_registrar.command_handlers.values()
- if h.cls.__name__ != 'DeprecatedCommands']
+ if h.cls.__name__ != 'DeprecatedCommands']
# We first try to look for a valid command that is very similar to the given command.
suggested_commands = difflib.get_close_matches(command, names, cutoff=0.8)
# If we find more than one matching command, or no command at all,
# we give command suggestions instead (with a lower matching threshold).
# All commands that start with the given command (for instance:
# 'mochitest-plain', 'mochitest-chrome', etc. for 'mochitest-')
# are also included.
if len(suggested_commands) != 1:
--- a/python/mach/mach/logging.py
+++ b/python/mach/mach/logging.py
@@ -195,25 +195,27 @@ class LoggingManager(object):
# And hook it up.
for logger in self.structured_loggers:
logger.addHandler(handler)
self.json_handlers.append(handler)
def add_terminal_logging(self, fh=sys.stdout, level=logging.INFO,
- write_interval=False, write_times=True):
+ write_interval=False, write_times=True):
"""Enable logging to the terminal."""
formatter = StructuredHumanFormatter(self.start_time,
- write_interval=write_interval, write_times=write_times)
+ write_interval=write_interval,
+ write_times=write_times)
if self.terminal:
formatter = StructuredTerminalFormatter(self.start_time,
- write_interval=write_interval, write_times=write_times)
+ write_interval=write_interval,
+ write_times=write_times)
formatter.set_terminal(self.terminal)
handler = logging.StreamHandler(stream=fh)
handler.setFormatter(formatter)
handler.setLevel(level)
for logger in self.structured_loggers:
logger.addHandler(handler)
--- a/python/mach/mach/main.py
+++ b/python/mach/mach/main.py
@@ -33,17 +33,16 @@ from .decorators import (
)
from .config import ConfigSettings
from .dispatcher import CommandAction
from .logging import LoggingManager
from .registrar import Registrar
-
MACH_ERROR = r'''
The error occurred in mach itself. This is likely a bug in mach itself or a
fundamental problem with a loaded module.
Please consider filing a bug against mach by going to the URL:
https://bugzilla.mozilla.org/enter_bug.cgi?product=Core&component=mach
@@ -98,16 +97,17 @@ containing command providers. The follow
%s
You are seeing this because there is an error in an external module attempting
to implement a mach command. Please fix the error, or uninstall the module from
your system.
'''.lstrip()
+
class ArgumentParser(argparse.ArgumentParser):
"""Custom implementation argument parser to make things look pretty."""
def error(self, message):
"""Custom error reporter to give more helpful text on bad commands."""
if not message.startswith('argument command: invalid choice'):
argparse.ArgumentParser.error(self, message)
assert False
@@ -356,17 +356,17 @@ To see more help for a specific command,
if os.isatty(orig_stdout.fileno()):
os.environ[b'MACH_STDOUT_ISATTY'] = b'1'
return self._run(argv)
except KeyboardInterrupt:
print('mach interrupted by signal or user action. Stopping.')
return 1
- except Exception as e:
+ except Exception:
# _run swallows exceptions in invoked handlers and converts them to
# a proper exit code. So, the only scenario where we should get an
# exception here is if _run itself raises. If _run raises, that's a
# bug in mach (or a loaded command module being silly) and thus
# should be reported differently.
self._print_error_header(argv, sys.stdout)
print(MACH_ERROR)
@@ -388,18 +388,18 @@ To see more help for a specific command,
def _run(self, argv):
# Load settings as early as possible so things in dispatcher.py
# can use them.
for provider in Registrar.settings_providers:
self.settings.register_provider(provider)
self.load_settings(self.settings_paths)
context = CommandContext(cwd=self.cwd,
- settings=self.settings, log_manager=self.log_manager,
- commands=Registrar)
+ settings=self.settings, log_manager=self.log_manager,
+ commands=Registrar)
if self.populate_context_handler:
self.populate_context_handler(context)
context = ContextWrapper(context, self.populate_context_handler)
parser = self.get_argument_parser(context)
if not len(argv):
@@ -411,22 +411,24 @@ To see more help for a specific command,
return 0
try:
args = parser.parse_args(argv)
except NoCommandError:
print(NO_COMMAND_ERROR)
return 1
except UnknownCommandError as e:
- suggestion_message = SUGGESTED_COMMANDS_MESSAGE % (e.verb, ', '.join(e.suggested_commands)) if e.suggested_commands else ''
- print(UNKNOWN_COMMAND_ERROR % (e.verb, e.command, suggestion_message))
+ suggestion_message = SUGGESTED_COMMANDS_MESSAGE % (
+ e.verb, ', '.join(e.suggested_commands)) if e.suggested_commands else ''
+ print(UNKNOWN_COMMAND_ERROR %
+ (e.verb, e.command, suggestion_message))
return 1
except UnrecognizedArgumentError as e:
print(UNRECOGNIZED_ARGUMENT_ERROR % (e.command,
- ' '.join(e.arguments)))
+ ' '.join(e.arguments)))
return 1
# Add JSON logging to a file if requested.
if args.logfile:
self.log_manager.add_json_handler(args.logfile)
# Up the logging level if requested.
log_level = logging.INFO
@@ -437,31 +439,33 @@ To see more help for a specific command,
write_times = True
if args.log_no_times or 'MACH_NO_WRITE_TIMES' in os.environ:
write_times = False
# Always enable terminal logging. The log manager figures out if we are
# actually in a TTY or are a pipe and does the right thing.
self.log_manager.add_terminal_logging(level=log_level,
- write_interval=args.log_interval, write_times=write_times)
+ write_interval=args.log_interval,
+ write_times=write_times)
if args.settings_file:
# Argument parsing has already happened, so settings that apply
# to command line handling (e.g alias, defaults) will be ignored.
self.load_settings(args.settings_file)
if not hasattr(args, 'mach_handler'):
raise MachError('ArgumentParser result missing mach handler info.')
handler = getattr(args, 'mach_handler')
try:
return Registrar._run_command_handler(handler, context=context,
- debug_command=args.debug_command, **vars(args.command_args))
+ debug_command=args.debug_command,
+ **vars(args.command_args))
except KeyboardInterrupt as ki:
raise ki
except FailedCommandError as e:
print(e.message)
return e.exit_code
except Exception as e:
exc_type, exc_value, exc_tb = sys.exc_info()
@@ -472,17 +476,17 @@ To see more help for a specific command,
# of calling the @Command method itself. This likely means a
# mismatch between @CommandArgument and arguments to the method.
# e.g. there exists a @CommandArgument without the corresponding
# argument on the method. We handle that here until the module
# loader grows the ability to validate better.
if not len(stack):
print(COMMAND_ERROR)
self._print_exception(sys.stdout, exc_type, exc_value,
- traceback.extract_tb(exc_tb))
+ traceback.extract_tb(exc_tb))
return 1
# Split the frames into those from the module containing the
# command and everything else.
command_frames = []
other_frames = []
initial_file = stack[0][0]
@@ -506,17 +510,17 @@ To see more help for a specific command,
self._print_exception(sys.stdout, exc_type, exc_value, stack)
return 1
def log(self, level, action, params, format_str):
"""Helper method to record a structured log event."""
self.logger.log(level, format_str,
- extra={'action': action, 'params': params})
+ extra={'action': action, 'params': params})
def _print_error_header(self, argv, fh):
fh.write('Error running mach:\n\n')
fh.write(' ')
fh.write(repr(argv))
fh.write('\n\n')
def _print_exception(self, fh, exc_type, exc_value, stack):
@@ -537,16 +541,17 @@ To see more help for a specific command,
searched for in this order:
machrc, .machrc
"""
if isinstance(paths, basestring):
paths = [paths]
valid_names = ('machrc', '.machrc')
+
def find_in_dir(base):
if os.path.isfile(base):
return base
for name in valid_names:
path = os.path.join(base, name)
if os.path.isfile(path):
return path
@@ -555,50 +560,52 @@ To see more help for a specific command,
files = filter(bool, files)
self.settings.load_files(files)
def get_argument_parser(self, context):
"""Returns an argument parser for the command-line interface."""
parser = ArgumentParser(add_help=False,
- usage='%(prog)s [global arguments] command [command arguments]')
+ usage='%(prog)s [global arguments] '
+ 'command [command arguments]')
# Order is important here as it dictates the order the auto-generated
# help messages are printed.
global_group = parser.add_argument_group('Global Arguments')
global_group.add_argument('-v', '--verbose', dest='verbose',
- action='store_true', default=False,
- help='Print verbose output.')
+ action='store_true', default=False,
+ help='Print verbose output.')
global_group.add_argument('-l', '--log-file', dest='logfile',
- metavar='FILENAME', type=argparse.FileType('ab'),
- help='Filename to write log data to.')
+ metavar='FILENAME', type=argparse.FileType('ab'),
+ help='Filename to write log data to.')
global_group.add_argument('--log-interval', dest='log_interval',
- action='store_true', default=False,
- help='Prefix log line with interval from last message rather '
- 'than relative time. Note that this is NOT execution time '
- 'if there are parallel operations.')
+ action='store_true', default=False,
+ help='Prefix log line with interval from last message rather '
+ 'than relative time. Note that this is NOT execution time '
+ 'if there are parallel operations.')
suppress_log_by_default = False
if 'INSIDE_EMACS' in os.environ:
suppress_log_by_default = True
global_group.add_argument('--log-no-times', dest='log_no_times',
- action='store_true', default=suppress_log_by_default,
- help='Do not prefix log lines with times. By default, mach will '
- 'prefix each output line with the time since command start.')
+ action='store_true', default=suppress_log_by_default,
+ help='Do not prefix log lines with times. By default, '
+ 'mach will prefix each output line with the time since '
+ 'command start.')
global_group.add_argument('-h', '--help', dest='help',
- action='store_true', default=False,
- help='Show this help message.')
+ action='store_true', default=False,
+ help='Show this help message.')
global_group.add_argument('--debug-command', action='store_true',
- help='Start a Python debugger when command is dispatched.')
+ help='Start a Python debugger when command is dispatched.')
global_group.add_argument('--settings', dest='settings_file',
- metavar='FILENAME', default=None,
- help='Path to settings file.')
+ metavar='FILENAME', default=None,
+ help='Path to settings file.')
for args, kwargs in self.global_arguments:
global_group.add_argument(*args, **kwargs)
# We need to be last because CommandAction swallows all remaining
# arguments and argparse parses arguments in the order they were added.
parser.add_argument('command', action=CommandAction,
- registrar=Registrar, context=context)
+ registrar=Registrar, context=context)
return parser
--- a/python/mach/mach/mixin/logging.py
+++ b/python/mach/mach/mixin/logging.py
@@ -46,10 +46,9 @@ class LoggingMixin(object):
Example Usage
-------------
self.log(logging.DEBUG, 'login', {'username': 'johndoe'},
'User login: {username}')
"""
self._logger.log(level, format_str,
- extra={'action': action, 'params': params})
-
+ extra={'action': action, 'params': params})
--- a/python/mach/mach/mixin/process.py
+++ b/python/mach/mach/mixin/process.py
@@ -36,19 +36,19 @@ if os.environ.get('MSYSTEM', None) in ('
if not _current_shell.lower().endswith('.exe'):
_current_shell += '.exe'
class ProcessExecutionMixin(LoggingMixin):
"""Mix-in that provides process execution functionality."""
def run_process(self, args=None, cwd=None, append_env=None,
- explicit_env=None, log_name=None, log_level=logging.INFO,
- line_handler=None, require_unix_environment=False,
- ensure_exit_code=0, ignore_children=False, pass_thru=False):
+ explicit_env=None, log_name=None, log_level=logging.INFO,
+ line_handler=None, require_unix_environment=False,
+ ensure_exit_code=0, ignore_children=False, pass_thru=False):
"""Runs a single process to completion.
Takes a list of arguments to run where the first item is the
executable. Runs the command in the specified directory and
with optional environment variables.
append_env -- Dict of environment variables to append to the current
set of environment variables.
@@ -126,18 +126,19 @@ class ProcessExecutionMixin(LoggingMixin
# waiting.
while status is None:
try:
status = proc.wait()
except KeyboardInterrupt:
pass
else:
p = ProcessHandlerMixin(args, cwd=cwd, env=use_env,
- processOutputLine=[handleLine], universal_newlines=True,
- ignore_children=ignore_children)
+ processOutputLine=[handleLine],
+ universal_newlines=True,
+ ignore_children=ignore_children)
p.run()
p.processOutput()
status = p.wait()
if ensure_exit_code is False:
return status
if ensure_exit_code is True:
--- a/python/mach/mach/registrar.py
+++ b/python/mach/mach/registrar.py
@@ -24,21 +24,21 @@ class MachRegistrar(object):
self.categories = {}
self.require_conditions = False
def register_command_handler(self, handler):
name = handler.name
if not handler.category:
raise MachError('Cannot register a mach command without a '
- 'category: %s' % name)
+ 'category: %s' % name)
if handler.category not in self.categories:
raise MachError('Cannot register a command to an undefined '
- 'category: %s -> %s' % (name, handler.category))
+ 'category: %s -> %s' % (name, handler.category))
self.command_handlers[name] = handler
self.commands_by_category[handler.category].add(name)
def register_settings_provider(self, cls):
self.settings_providers.add(cls)
def register_category(self, name, title, description, priority=50):
--- a/python/mach/mach/terminal.py
+++ b/python/mach/mach/terminal.py
@@ -67,9 +67,8 @@ class TerminalFooter(object):
self.fh.write(self.t.move_down())
self.fh.write(self.t.move_x(0))
def clear(self):
raise Exception('clear() must be implemented.')
def draw(self):
raise Exception('draw() must be implemented.')
-
--- a/python/mach/mach/test/common.py
+++ b/python/mach/mach/test/common.py
@@ -4,20 +4,20 @@
from __future__ import unicode_literals
from StringIO import StringIO
import os
import unittest
from mach.main import Mach
-from mach.base import CommandContext
here = os.path.abspath(os.path.dirname(__file__))
+
class TestBase(unittest.TestCase):
provider_dir = os.path.join(here, 'providers')
def get_mach(self, provider_file=None, entry_point=None, context_handler=None):
m = Mach(os.getcwd())
m.define_category('testing', 'Mach unittest', 'Testing for mach core', 10)
m.populate_context_handler = context_handler
--- a/python/mach/mach/test/providers/conditions.py
+++ b/python/mach/mach/test/providers/conditions.py
@@ -4,24 +4,27 @@
from __future__ import unicode_literals
from mach.decorators import (
CommandProvider,
Command,
)
+
def is_foo(cls):
"""Foo must be true"""
return cls.foo
+
def is_bar(cls):
"""Bar must be true"""
return cls.bar
+
@CommandProvider
class ConditionsProvider(object):
foo = True
bar = False
@Command('cmd_foo', category='testing', conditions=[is_foo])
def run_foo(self):
pass
@@ -29,16 +32,17 @@ class ConditionsProvider(object):
@Command('cmd_bar', category='testing', conditions=[is_bar])
def run_bar(self):
pass
@Command('cmd_foobar', category='testing', conditions=[is_foo, is_bar])
def run_foobar(self):
pass
+
@CommandProvider
class ConditionsContextProvider(object):
def __init__(self, context):
self.foo = context.foo
self.bar = context.bar
@Command('cmd_foo_ctx', category='testing', conditions=[is_foo])
def run_foo(self):
--- a/python/mach/mach/test/providers/conditions_invalid.py
+++ b/python/mach/mach/test/providers/conditions_invalid.py
@@ -4,13 +4,14 @@
from __future__ import unicode_literals
from mach.decorators import (
CommandProvider,
Command,
)
+
@CommandProvider
class ConditionsProvider(object):
@Command('cmd_foo', category='testing', conditions=["invalid"])
def run_foo(self):
pass
--- a/python/mach/mach/test/providers/throw.py
+++ b/python/mach/mach/test/providers/throw.py
@@ -1,16 +1,14 @@
# 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 unicode_literals
-import time
-
from mach.decorators import (
CommandArgument,
CommandProvider,
Command,
)
from mach.test.providers import throw2
@@ -21,9 +19,8 @@ class TestCommandProvider(object):
@CommandArgument('--message', '-m', default='General Error')
def throw(self, message):
raise Exception(message)
@Command('throw_deep', category='testing')
@CommandArgument('--message', '-m', default='General Error')
def throw_deep(self, message):
throw2.throw_deep(message)
-
--- a/python/mach/mach/test/providers/throw2.py
+++ b/python/mach/mach/test/providers/throw2.py
@@ -1,13 +1,15 @@
# 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/.
# This file exists to trigger the differences in mach error reporting between
# exceptions that occur in mach command modules themselves and in the things
# they call.
+
def throw_deep(message):
return throw_real(message)
+
def throw_real(message):
raise Exception(message)
--- a/python/mach/mach/test/test_conditions.py
+++ b/python/mach/mach/test/test_conditions.py
@@ -18,24 +18,24 @@ def _populate_context(context, key=None)
if key is None:
return
if key == 'foo':
return True
if key == 'bar':
return False
raise AttributeError(key)
+
class TestConditions(TestBase):
"""Tests for conditionally filtering commands."""
def _run_mach(self, args, context_handler=None):
return TestBase._run_mach(self, args, 'conditions.py',
context_handler=context_handler)
-
def test_conditions_pass(self):
"""Test that a command which passes its conditions is runnable."""
self.assertEquals((0, '', ''), self._run_mach(['cmd_foo']))
self.assertEquals((0, '', ''), self._run_mach(['cmd_foo_ctx'], _populate_context))
def test_invalid_context_message(self):
"""Test that commands which do not pass all their conditions
@@ -60,17 +60,17 @@ class TestConditions(TestBase):
self.assertEquals(fail_msg.rstrip(), stdout.rstrip())
def test_invalid_type(self):
"""Test that a condition which is not callable raises an exception."""
m = Mach(os.getcwd())
m.define_category('testing', 'Mach unittest', 'Testing for mach core', 10)
self.assertRaises(MachError, m.load_commands_from_file,
- os.path.join(self.provider_dir, 'conditions_invalid.py'))
+ os.path.join(self.provider_dir, 'conditions_invalid.py'))
def test_help_message(self):
"""Test that commands that are not runnable do not show up in help."""
result, stdout, stderr = self._run_mach(['help'], _populate_context)
self.assertIn('cmd_foo', stdout)
self.assertNotIn('cmd_bar', stdout)
self.assertNotIn('cmd_foobar', stdout)
--- a/python/mach/mach/test/test_config.py
+++ b/python/mach/mach/test/test_config.py
@@ -35,16 +35,17 @@ baz = /baz/foo.c
"""
CONFIG2 = r"""
[foo]
bar = value2
"""
+
@SettingsProvider
class Provider1(object):
config_settings = [
('foo.bar', StringType, 'desc'),
('foo.baz', PathType, 'desc'),
]
--- a/python/mach/mach/test/test_error_output.py
+++ b/python/mach/mach/test/test_error_output.py
@@ -15,25 +15,25 @@ from mozunit import main
class TestErrorOutput(TestBase):
def _run_mach(self, args):
return TestBase._run_mach(self, args, 'throw.py')
def test_command_error(self):
result, stdout, stderr = self._run_mach(['throw', '--message',
- 'Command Error'])
+ 'Command Error'])
self.assertEqual(result, 1)
self.assertIn(COMMAND_ERROR, stdout)
def test_invoked_error(self):
result, stdout, stderr = self._run_mach(['throw_deep', '--message',
- 'Deep stack'])
+ 'Deep stack'])
self.assertEqual(result, 1)
self.assertIn(MODULE_ERROR, stdout)
if __name__ == '__main__':
main()
--- a/python/mach/mach/test/test_logger.py
+++ b/python/mach/mach/test/test_logger.py
@@ -35,13 +35,13 @@ class TestStructuredHumanFormatter(unitt
self.assertEqual(relevant, 'Test: s\xe9curit\xe9')
logger = DummyLogger(on_record)
value = 's\xe9curit\xe9'
logger.log(logging.INFO, 'Test: {utf}',
- extra={'action': 'action', 'params': {'utf': value}})
+ extra={'action': 'action', 'params': {'utf': value}})
if __name__ == '__main__':
main()
--- a/python/mach/setup.py
+++ b/python/mach/setup.py
@@ -31,9 +31,8 @@ setup(
install_requires=[
'blessings',
'mozfile',
'mozprocess',
'six',
],
tests_require=['mock'],
)
-
--- a/tools/lint/flake8.yml
+++ b/tools/lint/flake8.yml
@@ -1,14 +1,15 @@
---
flake8:
description: Python linter
include:
- config/mozunit.py
- layout/tools/reftest
+ - python/mach
- python/mach_commands.py
- python/mozlint
- security/manager
- taskcluster
- testing/firefox-ui
- testing/mach_commands.py
- testing/marionette/client
- testing/marionette/harness