Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1326)

Unified Diff: third_party/WebKit/Tools/Scripts/webkitpy/tool/multi_command_tool.py

Issue 2075073002: Revert of Use an explicit list of webkit-patch commands instead of using auto-discovery. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Tools/Scripts/webkitpy/tool/multi_command_tool.py
diff --git a/third_party/WebKit/Tools/Scripts/webkitpy/tool/multi_command_tool.py b/third_party/WebKit/Tools/Scripts/webkitpy/tool/multi_command_tool.py
index f4f85b1006a56bdc98b6370a4f2b3829ffdb0021..ad10d1a73f6d98b63afdbbd48bbd907037ad245d 100644
--- a/third_party/WebKit/Tools/Scripts/webkitpy/tool/multi_command_tool.py
+++ b/third_party/WebKit/Tools/Scripts/webkitpy/tool/multi_command_tool.py
@@ -35,6 +35,7 @@
import logging
import sys
+from webkitpy.tool.commands.command import Command
from webkitpy.tool.commands.command import HelpPrintingOptionParser
from webkitpy.tool.commands.help_command import HelpCommand
@@ -47,14 +48,28 @@
def __init__(self, name=None, commands=None):
self._name = name or optparse.OptionParser(prog=name).get_prog_name() # OptionParser has nice logic for fetching the name.
- self.commands = commands or []
+ # Allow the unit tests to disable command auto-discovery.
+ self.commands = commands or [cls() for cls in self._find_all_commands() if cls.name]
self.help_command = self.command_by_name(HelpCommand.name)
- # Require the help command, even if the manual test list doesn't include one.
+ # Require a help command, even if the manual test list doesn't include one.
if not self.help_command:
self.help_command = HelpCommand()
self.commands.append(self.help_command)
for command in self.commands:
command.bind_to_tool(self)
+
+ @classmethod
+ def _add_all_subclasses(cls, class_to_crawl, seen_classes):
+ for subclass in class_to_crawl.__subclasses__():
+ if subclass not in seen_classes:
+ seen_classes.add(subclass)
+ cls._add_all_subclasses(subclass, seen_classes)
+
+ @classmethod
+ def _find_all_commands(cls):
+ commands = set()
+ cls._add_all_subclasses(Command, commands)
+ return sorted(commands)
def name(self):
return self._name

Powered by Google App Engine
This is Rietveld 408576698