Commit Graph

124 Commits

Author SHA1 Message Date
Nathan Hakkakzadeh
f284bf6b2f Bug 1100925 - Mach now detects msys2. r=gps
Before, mach would only detect MINGW32 (used with msys). Now it also detects MINGW64 (used with msys2).

MozReview-Commit-ID: 6IrNNmkLKgB
2016-05-31 14:44:53 -07:00
Gregory Szorc
93907bb875 NO BUG - Bump version of mach to 0.6
DONTBUILD (NPOTB)
2016-05-02 13:36:33 -07:00
Andrew Halberstadt
a90c230261 Bug 1255450 - mach settings documentation fix, DONTBUILD, r=me
MozReview-Commit-ID: AQ3w2oCPQeN
2016-04-12 21:03:36 -04:00
Andrew Halberstadt
f7dae1b34e Bug 1255450 - [mach] Create setting for defining command aliases, r=gps
These config options can be defined in ~/.mozbuild/machrc or topsrcdir/machrc.
Aliases work similar to the identically named option in an hgrc.

For example:

[alias]
browser-test = mochitest -f browser
mochitest = mochitest -f plain


MozReview-Commit-ID: CnOocEslRUI
2016-03-23 17:34:35 -04:00
Andrew Halberstadt
a2a7da69c0 Bug 1255450 - [mach] Enable runtime configuration files, r=gps
Runtime configs have been implemented for awhile, but disabled. This patch
enables configuration. Config files will be loaded in the following order
(later files override earlier ones):

1a. $MACHRC
1b. $MOZBUILD_STATE_PATH/machrc (if $MACHRC is unset)
2. topsrcdir/machrc
3. CLI via --settings

Note: .machrc may be used instead of machrc if desired.

MozReview-Commit-ID: IntONAZLGML
2016-03-28 11:18:24 -04:00
Andrew Halberstadt
3597e612f4 Bug 1255450 - [mach] Simplify managing of locale documentation for settings, r=gps
This adds a |mach settings locale-gen| subcommand to automatically generate locale
specific documentation for settings. It also refactors |mach settings-create| to
|mach settings| and moves |mach settings| to |mach settings -l|. Finally it performs
some misc cleanup mostly related to locales.

MozReview-Commit-ID: 1VWLcb9ehAH
2016-03-23 17:49:15 -04:00
Andrew Halberstadt
550a486738 Bug 1255450 - [mach] Implement 'wildcard' settings for enabling sections with user-defined options, r=gps
Some sections should support user-defined options. For example, in an [alias] section, the option names
are not well-defined, rather specified by the user. This patch allows user-defined option names for any
section that has a 'section.*' option defined. Even with 'section.*', option types are still well-defined.

MozReview-Commit-ID: L34W9v9Fy28
2016-03-28 10:52:16 -04:00
Andrew Halberstadt
c0ba13e745 Bug 1255450 - [mach] Replace ConfigProvider class with config_settings attribute, r=gps
Defining settings was a little complicated. First it required overriding a '_register_settings'
method, and then it required making N calls to a second 'register_setting' method within that.

This patch simplifies the process of defining settings by only requiring a
'config_settings' attribute. This attribute should be a list of tuples:

[
  ('<section>.<option>', '<type>', <default>, set(<choices)),
]

`default` and `choices` are optional. Alternatively, 'config_settings' can be a callable
that returns a list of tuples in the same format. This still allows for greater flexibility
for more advanced cases.

MozReview-Commit-ID: F4DTTNJdJsa
2016-03-21 17:55:41 -04:00
Andrew Halberstadt
745135c075 Bug 1262495 - [mach] Allow running root commands that have subcommands on their own, r=gps
For example, say there is a command 'foo' that has a subcommand 'bar'. Prior to this, it was not
possible to run:
./mach foo

as its own independent command. The above would instead print the subcommand help for 'bar'.

MozReview-Commit-ID: JU4dXoxnCyu
2016-04-06 11:41:13 -04:00
Steve Fink
f3940ad6f8 Bug 991343 - Suppress time output when running inside emacs, r=gps
Because I Care.

MozReview-Commit-ID: 9An5QwxnBpU
2016-03-11 16:51:24 -08:00
Andrew Halberstadt
858a34d3a7 Bug 1255470 - [mach] don't raise if a subcommand exists and but wasn't found in args, r=gps
This is currently preventing a command from having both args and subcommands at the same
time.

MozReview-Commit-ID: 66frAqamGjv
2016-03-10 11:51:43 -05:00
Andrew Halberstadt
61b45dbe9d Bug 1255467 - Ability for a mach command to dispatch to another's subcommand, r=gps
MozReview-Commit-ID: CN8kJU0NrL0
2016-03-10 11:45:39 -05:00
Dan Minor
48ec2652af Bug 1239296 - add post_dispatch_handler hook to mach r=gps
This adds a post_dispatch_handler hook that will be called after each
mach invocation and uses it to submit data to telemetry.
2016-02-09 10:09:17 -05:00
Robert Longson
b4d19de393 Bug 1240616 - mach mochitest-run suggests deprecated commands as an alternative r=cmanchester 2016-01-19 21:39:16 +00:00
Gijs Kruitbosch
8033b5e500 Bug 1236111 - part 0: improve logging from process mixin, r=gps 2016-01-05 11:13:05 +00:00
Xidorn Quan
db8948e4e1 Bug 1205144 - Remove 'REMOVED' commands from output of mach-commands and mach-debug-commands. r=gps DONTBUILD 2015-09-21 11:32:03 +10:00
James Graham
5fd2c49814 Bug 1192315 - Support remainder arguments from predefined parsers in mach, r=gps
Mach has special handling for remainder arguments which previously
only worked with the decoration form. Extend this to also work when
a command passes in an explict parser
2015-08-07 18:13:05 +01:00
Supradeep T R
f2f7fb068f Bug 1184780 - Use command help instead of main help; r=gps 2015-07-17 13:42:12 -07:00
Gregory Szorc
f055b56c10 Bug 1182677 - Support calling a function during mach command dispatch; r=smacleod
This will give us the ability to execute custom code at command dispatch
time. We can use this for global tests before dispatch.
2015-07-14 13:46:33 -07:00
Supradeep T R
737b72f7b4 Bug 1175968 - Honor '-h' or '--help' only if it appears before '--'; r=gps 2015-07-13 16:58:54 -07:00
Ehsan Akhgari
e08f67b809 Bug 1179488 - Accept any arguments passed to deprecated commands; r=gps
Without this, we throw UnrecognizedArgumentError when running commands
such as `./mach mochitest-plain test`, which causes an error message
such as the below to be emitted:

It looks like you passed an unrecognized argument into mach.

The mochitest-plain command does not accept the arguments: test

This patch will fix the above command to instead print the corresponding
deprecation message.
2015-07-06 18:08:48 -04:00
Andrew Halberstadt
604c4685c7 Bug 1177476 - Fix require_conditions regression in mach, r=gps
This is a regression from bug 1176620 that results in all Firefox mach commands showing up in the help for B2G, even though they don't work there.
2015-06-25 15:44:11 -04:00
Gregory Szorc
59da8c6306 Bug 1176620 - Eliminate MethodHandler; r=ahal
This type is now redundant with our new rich type for capturing all mach
command metadata. Eliminate it and using _MachCommand instead.
2015-06-21 13:17:51 -07:00
Gregory Szorc
35836fc51f Bug 1176620 - Pass fewer arguments into MethodHandler; r=ahal
Simplify construction of mach's MethodHandler instances by by passing in
our new rich type that holds all command metadata.

While we are here, kill the docstring argument, as it can be computed
easily inside MethodHandler.__init__.
2015-06-21 13:07:33 -07:00
Gregory Szorc
d243e65526 Bug 1176620 - Refactor how mach command metadata is stored; r=ahal
Up to this point, mach command metadata has been stored in tuples.
Initially, things weren't so bad. But they have evolved into tuples with
many elements. Adding new attributes is cumbersome. Let's restructure
the code to capture metadata in a dedicated class.

Before, there existed a separate attribute on the @Command or
@SubCommand decorated method for each mach decorator: @Command,
@CommandArgument, @CommandArgumentGroup. With the magic of __ior__,
we can now capture all metadata on a single type. This simplies
processing, as we now only look at a single attribute on methods:
_mach_command.

Before, we used separate attributes to distinguish between mach commands
and mach sub-commands. Now that we have a type that can hold all data,
we combine things into the _mach_command attribute and look for the
presence of the "subcommand" attribute on this type to identify
sub-commands.
2015-06-21 12:59:29 -07:00
Gregory Szorc
185b48868a Bug 1176620 - Use absolute_import in mach; r=ahal
To help ensure Python 3 compatibility.
2015-06-21 11:56:05 -07:00
Gregory Szorc
b8437eff88 Bug 1173633 - Print docstrings of mach command handlers in help output; r=ahal
`mach help <command>` currently only displays a brief description of the
command along with its arguments. Sometimes more detailed help text is
needed.

With this commit, the docstrings of mach command handlers will appear in
the output of `mach help <command>` if they are defined.

I've implemented basic docstrings for the three flavors of mach commands
(normal command, main subcommand, subcommand) to demonstate things work.

My hope is others will start to fill in docstrings once this feature
lands so the output for `mach help` can serve as a better learning guide
for new contributors.
2015-06-11 08:32:02 -07:00
Andrew Halberstadt
b83ddd237a Bug 1164597 - Consolidate all mochitest mach commands into single |mach mochitest|, r=chmanchester 2015-05-05 16:41:59 -04:00
Andrew Halberstadt
232aa054a7 Bug 1163112 - [mach core] Consolidate functionality between Main._run and Registrar.dispatch, r=gps 2015-05-08 17:03:15 -04:00
Andrew Halberstadt
0d9ffcd73a Bug 1154006 - [mach] Ability to lazy load parsers passed in via the @Command decorator, r=gps 2015-04-13 15:36:56 -04:00
Andrew Halberstadt
5b6bf2825c Bug 1140441 - Add substring matching option to |mach mach-debug-commands|, r=gps 2015-03-06 11:25:55 -05:00
Gregory Szorc
0d9a7864e0 Bug 1139100 - Apply proper checking for command existence; r=ahal
Previously, we raised errors attempting to register a mach sub-command
if the parent command was not defined on the Registrar. This broke B2G
because its mach command Registrar imposes restrictions on which
commands it exposes. Commands there were not getting registered on the
Registrar, leading mach to give a false positive that the parent command
was never defined.

We change the verification logic to take present but unregistered
commands into consideration and to skip registering sub-commands if the
parent isn't present in the Registrar.
2015-03-04 11:03:07 -08:00
Gregory Szorc
c26a49ed7e Bug 1129798 - Use pdb.runcall to debug mach commands; r=ahal
The previous debugger was setting a breakpoint in the mach dispatcher.
This required users to step into the main function to be called into.
Using pdb.runcall(), the debugger starts at the first line in the
executed command, which is far more useful.
2015-02-04 22:49:06 -08:00
Gregory Szorc
5724222212 Bug 1115278 - Fix mach documentation issues; r=glandium
terminal.py had an ambiguous |import logging| that was importing
mach.logging from Sphinx. We fix it.

There was also a poorly formed link in the mach commands documentation.
We fix it.
2014-12-24 10:26:34 -08:00
Gregory Szorc
122658253a Bug 1108399 - Implement mach sub-command dispatching; r=ahal 2014-12-06 22:33:12 -08:00
Gregory Szorc
9a9ca81a03 Bug 1108399 - Handle help on mach sub-commands; r=ahal 2014-12-06 22:39:32 -08:00
Gregory Szorc
83d847a354 Bug 1108399 - Split command group populating into own function; r=ahal
An upcoming patch will reuse this code. Split it out into its own
function.
2014-12-07 11:56:31 -08:00
Gregory Szorc
5c9c715038 Bug 1108399 - Introduce decorator for mach sub-commands; r=ahal
With this patch, we now have the ability to declare mach sub-commands.
Subsequent patches will implement dispatching for sub-commands.
2014-12-07 11:40:39 -08:00
Gregory Szorc
cab32f370f Bug 1108399 - Properly name command help function; r=ahal
We will soon have proper sub-commands. Let's fix function names.
2014-12-06 21:58:46 -08:00
Gregory Szorc
06c94040fe Bug 1108399 - Remove outdated comment about hooking up conditional commands; r=ahal
mach conditions are implemented elsewhere. This comment can die.
2014-12-06 21:53:16 -08:00
Gregory Szorc
318fd6e02d Bug 1108399 - Fix docs for mach decorators; r=ahal
Documentation was referencing sub commands. The proper terminology is
"command."
2014-12-06 21:15:27 -08:00
Gregory Szorc
5af0c6abf1 Bug 1108399 - Properly link to Python docs; r=ahal
There were a few parts of the docs that were linking to Python types
incorrectly. Let's fix that.
2014-12-07 11:37:54 -08:00
Gregory Szorc
bfe6799d76 Bug 1108399 - Split mach documentation into multiple articles; r=ahal
The main mach docs page is a bit long. Let's split it into multiple
articles to increase readability going forward.
2014-12-07 11:34:06 -08:00
Gregory Szorc
39a76e34a5 Bug 1108399 - Improve code linking in mach docs; r=ahal
Now that mach's docs are part of a proper Sphinx install, link to
Python type docs. While we're here, we also clean up formatting of code
samples.
2014-12-07 11:23:46 -08:00
Gregory Szorc
907c3c2ef9 Bug 1108399 - Move mach docs into sphinx; r=ahal
mach has restructured text documentation. Let's expose it to the in-tree
Sphinx config so we can increase visibility of the documentation.
2014-12-07 10:40:19 -08:00
Gregory Szorc
f7ae0b6d2f Bug 1107968 - Add --debug-command to mach; r=ahal
People often seek to learn how mach commands work. A common way to do
this is to launch a debugger and step through the code as it is
executing. But this requires someone to first find and modify the mach
command. This involves overhead.

This patch adds a global --debug-command argument to mach. When present,
we launch an interactive debugger right before command dispatch. This
allows people to easily enter a debugger to see what mach commands are
doing, hopefully lowering the barrier to understanding and contributing.
2014-12-05 10:19:49 -08:00
Nicholas Nethercote
5645be40ed Bug 1077272 - Allow argument groups in mach commands. r=gps. 2014-10-08 15:11:50 -07:00
Mike Hommey
711c2629f1 Bug 1076649 - Remove the '+' prefixing from mach commands with allow_all_arguments=True. r=gps
The reason to use '+' prefixing was to distinguish between options to the
mach command itself, and options that are passed down to whatever the
command does (like mach run passing down args to the built application).
That makes things unnecessarily awkward, and quite non-standard.

Instead, use standard '-' prefixing, and pass all the unknown arguments
down. If there is overlap between the known arguments and arguments supported
by the underlying tool (like -remote when using mach run), it is possible to
use '--' to mark all following arguments as being targetted at the underlying
tool.

For instance:
    mach run -- -remote something
would run
    firefox -remote something
while
    mach run -remote something
would run
    firefox something

As allow_all_arguments is redundant with the presence of a argparse.REMAINDER
CommandArgument, allow_all_arguments is removed. The only mach command with a
argparse.REMAINDER CommandArgument without allow_all_arguments was "mach dmd",
and it did so because it didn't want to use '+' prefixes.
2014-10-07 07:36:27 +09:00
Ahmed Kachkach
ed94ab0fae Bug 1057694 - Command suggestions in mach. r=gps 2014-08-26 16:17:00 +02:00
Sylvestre Ledru
4198ca2238 Bug 1051987 - Remove useless option which wasn't supposed to go in the commit 2014-08-18 15:33:51 +02:00