Closed Bug 1179488 Opened 11 years ago Closed 11 years ago

Accept any arguments passed to deprecated commands

Categories

(Firefox Build System :: Mach Core, enhancement)

enhancement
Not set
normal

Tracking

(firefox42 fixed)

RESOLVED FIXED
mozilla42
Tracking Status
firefox42 --- fixed

People

(Reporter: ehsan.akhgari, Assigned: ehsan.akhgari)

Details

Attachments

(1 file)

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.
Comment on attachment 8628491 [details] [diff] [review] Accept any arguments passed to deprecated commands Review of attachment 8628491 [details] [diff] [review]: ----------------------------------------------------------------- See comment for preferred resolution. ::: python/mach/mach/dispatcher.py @@ +229,5 @@ > if extra: > setattr(command_namespace, name, extra) > else: > setattr(command_namespace, name, options.get('default', [])) > + elif extra and not handler.cls.__name__ == 'DeprecatedCommands': The DeprecatedCommands class comes from testing/mochitest/mach_commands.py. This is touching code in mach core. It is therefore a layering violation to check for the presence of a class defined outside the mach core. The proper way to do this is to implement a "deprecated commands" mach feature or change the arguments of the deprecated commands to accept all arguments. e.g.: @CommandArgument('args', nargs=argparse.REMAINDER)
Attachment #8628491 - Flags: review?(gps)
(In reply to Gregory Szorc [:gps] from comment #2) > ::: python/mach/mach/dispatcher.py > @@ +229,5 @@ > > if extra: > > setattr(command_namespace, name, extra) > > else: > > setattr(command_namespace, name, options.get('default', [])) > > + elif extra and not handler.cls.__name__ == 'DeprecatedCommands': > > The DeprecatedCommands class comes from testing/mochitest/mach_commands.py. > This is touching code in mach core. It is therefore a layering violation to > check for the presence of a class defined outside the mach core. dispatcher.py already depends on this *exact* same pattern <http://mxr.mozilla.org/mozilla-central/source/python/mach/mach/dispatcher.py#114>. > The proper way to do this is to implement a "deprecated commands" mach > feature or change the arguments of the deprecated commands to accept all > arguments. e.g.: > > @CommandArgument('args', nargs=argparse.REMAINDER) Do you mean doing that for all DeprecatedCommands forever is better than handling this in a central place?
Flags: needinfo?(gps)
Comment on attachment 8628491 [details] [diff] [review] Accept any arguments passed to deprecated commands Review of attachment 8628491 [details] [diff] [review]: ----------------------------------------------------------------- OK. Since we already have the cls.__name__ == 'DeprecatedCommands' hack in dispatcher.py, this is acceptable. ::: python/mach/mach/dispatcher.py @@ +229,5 @@ > if extra: > setattr(command_namespace, name, extra) > else: > setattr(command_namespace, name, options.get('default', [])) > + elif extra and not handler.cls.__name__ == 'DeprecatedCommands': and handler.cls.__name__ != 'DeprecatedCommands':
Attachment #8628491 - Flags: review+
Flags: needinfo?(gps)
Thanks! BTW, if there is a less hacky way to detect the type of this object than looking at its class name, please let me know how and I'll fix it.
Assignee: nobody → ehsan
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla42
Product: Core → Firefox Build System
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: