Diff
Modified: trunk/Tools/ChangeLog (227426 => 227427)
--- trunk/Tools/ChangeLog 2018-01-23 19:29:48 UTC (rev 227426)
+++ trunk/Tools/ChangeLog 2018-01-23 19:31:04 UTC (rev 227427)
@@ -1,3 +1,49 @@
+2018-01-23 Basuke Suzuki <[email protected]>
+
+ Add ignore_errors keyword argument to Executive.run_command() for replacing the common pattern of error_handler usage
+ https://bugs.webkit.org/show_bug.cgi?id=180820
+
+ Reviewed by David Kilzer.
+
+ * Scripts/webkitpy/common/checkout/scm/git.py:
+ (Git.in_working_directory):
+ (Git.clone):
+ (Git.read_git_config):
+ (Git.apply_reverse_diff):
+ * Scripts/webkitpy/common/checkout/scm/scm.py:
+ (SCM.run):
+ * Scripts/webkitpy/common/checkout/scm/scm_unittest.py:
+ * Scripts/webkitpy/common/checkout/scm/svn.py:
+ (SVNRepository.has_authorization_for_realm):
+ * Scripts/webkitpy/common/net/credentials_unittest.py:
+ * Scripts/webkitpy/common/system/abstractexecutive.py:
+ (AbstractExecutive.run_command):
+ * Scripts/webkitpy/common/system/executive.py:
+ (Executive.kill_process.is):
+ (Executive.running_pids):
+ (Executive.kill_all):
+ (Executive.run_command):
+ * Scripts/webkitpy/common/system/executive_mock.py:
+ (MockExecutive.run_command):
+ (MockExecutive2.run_command):
+ * Scripts/webkitpy/common/system/executive_unittest.py:
+ (ExecutiveTest.test_run_command_with_bad_command.run_bad_command):
+ * Scripts/webkitpy/common/system/platforminfo.py:
+ (PlatformInfo.xcode_sdk_version):
+ * Scripts/webkitpy/layout_tests/servers/http_server.py:
+ (Lighttpd._check_and_kill):
+ * Scripts/webkitpy/port/base.py:
+ (Port._symbols_string):
+ * Scripts/webkitpy/port/gtk.py:
+ (GtkPort.setup_environ_for_server):
+ * Scripts/webkitpy/port/win.py:
+ (WinPort._runtime_feature_list):
+ (WinPort.read_registry_value):
+ * Scripts/webkitpy/port/win_unittest.py:
+ (WinPortTest.test_runtime_feature_list):
+ * Scripts/webkitpy/tool/commands/analyzechangelog.py:
+ * Scripts/webkitpy/tool/commands/analyzechangelog_unittest.py:
+
2018-01-23 Commit Queue <[email protected]>
Unreviewed, rolling out r227279 and r227373.
Modified: trunk/Tools/Scripts/webkitpy/common/checkout/scm/git.py (227426 => 227427)
--- trunk/Tools/Scripts/webkitpy/common/checkout/scm/git.py 2018-01-23 19:29:48 UTC (rev 227426)
+++ trunk/Tools/Scripts/webkitpy/common/checkout/scm/git.py 2018-01-23 19:31:04 UTC (rev 227427)
@@ -109,7 +109,7 @@
def in_working_directory(cls, path, executive=None):
try:
executive = executive or Executive()
- return executive.run_command([cls.executable_name, 'rev-parse', '--is-inside-work-tree'], cwd=path, error_handler=Executive.ignore_error).rstrip() == "true"
+ return executive.run_command([cls.executable_name, 'rev-parse', '--is-inside-work-tree'], cwd=path, ignore_errors=True).rstrip() == "true"
except OSError as e:
# The Windows bots seem to through a WindowsError when git isn't installed.
return False
@@ -118,7 +118,7 @@
def clone(cls, url, directory, executive=None):
try:
executive = executive or Executive()
- return executive.run_command([cls.executable_name, 'clone', '-v', url, directory], error_handler=Executive.ignore_error)
+ return executive.run_command([cls.executable_name, 'clone', '-v', url, directory], ignore_errors=True)
except OSError as e:
return False
@@ -142,7 +142,7 @@
# Pass the cwd if provided so that we can handle the case of running webkit-patch outside of the working directory.
# FIXME: This should use an Executive.
executive = executive or Executive()
- return executive.run_command([cls.executable_name, "config", "--get-all", key], error_handler=Executive.ignore_error, cwd=cwd).rstrip('\n')
+ return executive.run_command([cls.executable_name, "config", "--get-all", key], ignore_errors=True, cwd=cwd).rstrip('\n')
@staticmethod
def commit_success_regexp():
@@ -400,7 +400,7 @@
# Assume the revision is an svn revision.
git_commit = self.git_commit_from_svn_revision(revision)
# I think this will always fail due to ChangeLogs.
- self._run_git(['revert', '--no-commit', git_commit], error_handler=Executive.ignore_error)
+ self._run_git(['revert', '--no-commit', git_commit], ignore_errors=True)
def revert_files(self, file_paths):
self._run_git(['checkout', 'HEAD'] + file_paths)
Modified: trunk/Tools/Scripts/webkitpy/common/checkout/scm/scm.py (227426 => 227427)
--- trunk/Tools/Scripts/webkitpy/common/checkout/scm/scm.py 2018-01-23 19:29:48 UTC (rev 227426)
+++ trunk/Tools/Scripts/webkitpy/common/checkout/scm/scm.py 2018-01-23 19:31:04 UTC (rev 227427)
@@ -66,12 +66,13 @@
self.checkout_root = self.find_checkout_root(self.cwd)
# A wrapper used by subclasses to create processes.
- def run(self, args, cwd=None, input=None, error_handler=None, return_exit_code=False, return_stderr=True, decode_output=True):
+ def run(self, args, cwd=None, input=None, error_handler=None, ignore_errors=False, return_exit_code=False, return_stderr=True, decode_output=True):
# FIXME: We should set cwd appropriately.
return self._executive.run_command(args,
cwd=cwd,
input=input,
error_handler=error_handler,
+ ignore_errors=ignore_errors,
return_exit_code=return_exit_code,
return_stderr=return_stderr,
decode_output=decode_output)
Modified: trunk/Tools/Scripts/webkitpy/common/checkout/scm/scm_unittest.py (227426 => 227427)
--- trunk/Tools/Scripts/webkitpy/common/checkout/scm/scm_unittest.py 2018-01-23 19:29:48 UTC (rev 227426)
+++ trunk/Tools/Scripts/webkitpy/common/checkout/scm/scm_unittest.py 2018-01-23 19:31:04 UTC (rev 227427)
@@ -265,12 +265,12 @@
"""
command_does_not_exist = ['does_not_exist', 'invalid_option']
self.assertRaises(OSError, run_command, command_does_not_exist)
- self.assertRaises(OSError, run_command, command_does_not_exist, error_handler=Executive.ignore_error)
+ self.assertRaises(OSError, run_command, command_does_not_exist, ignore_errors=True)
command_returns_non_zero = ['/bin/sh', '--invalid-option']
self.assertRaises(ScriptError, run_command, command_returns_non_zero)
# Check if returns error text:
- self.assertTrue(run_command(command_returns_non_zero, error_handler=Executive.ignore_error))
+ self.assertTrue(run_command(command_returns_non_zero, ignore_errors=True))
self.assertRaises(CheckoutNeedsUpdate, commit_error_handler, ScriptError(output=git_failure_message))
self.assertRaises(CheckoutNeedsUpdate, commit_error_handler, ScriptError(output=svn_failure_message))
Modified: trunk/Tools/Scripts/webkitpy/common/checkout/scm/svn.py (227426 => 227427)
--- trunk/Tools/Scripts/webkitpy/common/checkout/scm/svn.py 2018-01-23 19:29:48 UTC (rev 227426)
+++ trunk/Tools/Scripts/webkitpy/common/checkout/scm/svn.py 2018-01-23 19:31:04 UTC (rev 227427)
@@ -60,7 +60,7 @@
if not os.path.isdir(os.path.join(home_directory, ".subversion")):
return False
find_args = ["find", ".subversion", "-type", "f", "-exec", "grep", "-q", realm, "{}", ";", "-print"]
- find_output = self.run(find_args, cwd=home_directory, error_handler=Executive.ignore_error).rstrip()
+ find_output = self.run(find_args, cwd=home_directory, ignore_errors=True).rstrip()
if not find_output or not os.path.isfile(os.path.join(home_directory, find_output)):
return False
# Subversion either stores the password in the credential file, indicated by the presence of the key "password",
Modified: trunk/Tools/Scripts/webkitpy/common/net/credentials_unittest.py (227426 => 227427)
--- trunk/Tools/Scripts/webkitpy/common/net/credentials_unittest.py 2018-01-23 19:29:48 UTC (rev 227426)
+++ trunk/Tools/Scripts/webkitpy/common/net/credentials_unittest.py 2018-01-23 19:31:04 UTC (rev 227427)
@@ -31,7 +31,6 @@
import unittest
from webkitpy.common.net.credentials import Credentials
-from webkitpy.common.system.executive import Executive
from webkitpy.common.system.outputcapture import OutputCapture
from webkitpy.common.system.user_mock import MockUser
from webkitpy.thirdparty.mock import Mock
Modified: trunk/Tools/Scripts/webkitpy/common/system/abstractexecutive.py (227426 => 227427)
--- trunk/Tools/Scripts/webkitpy/common/system/abstractexecutive.py 2018-01-23 19:29:48 UTC (rev 227426)
+++ trunk/Tools/Scripts/webkitpy/common/system/abstractexecutive.py 2018-01-23 19:31:04 UTC (rev 227427)
@@ -116,7 +116,7 @@
escaped_args.append(arg)
return " ".join(escaped_args)
- def run_command(self, args, cwd=None, env=None, input=None, error_handler=None,
+ def run_command(self, args, cwd=None, env=None, input=None, error_handler=None, ignore_errors=False,
return_exit_code=False, return_stderr=True, decode_output=True):
raise NotImplementedError('subclasses must implement')
Modified: trunk/Tools/Scripts/webkitpy/common/system/executive.py (227426 => 227427)
--- trunk/Tools/Scripts/webkitpy/common/system/executive.py 2018-01-23 19:29:48 UTC (rev 227426)
+++ trunk/Tools/Scripts/webkitpy/common/system/executive.py 2018-01-23 19:31:04 UTC (rev 227427)
@@ -174,7 +174,7 @@
task_kill_executable = os.path.join('C:', os.sep, 'WINDOWS', 'system32', 'taskkill.exe')
command = [task_kill_executable, "/f", "/t", "/pid", pid]
# taskkill will exit 128 if the process is not found. We should log.
- self.run_command(command, error_handler=self.ignore_error)
+ self.run_command(command, ignore_errors=True)
return
# According to http://docs.python.org/library/os.html
@@ -271,7 +271,7 @@
running_pids = []
if sys.platform in ("cygwin"):
- ps_process = self.run_command(['ps', '-e'], error_handler=Executive.ignore_error)
+ ps_process = self.run_command(['ps', '-e'], ignore_errors=True)
for line in ps_process.splitlines():
tokens = line.strip().split()
try:
@@ -325,7 +325,7 @@
killCommand = os.path.join('C:', os.sep, 'WINDOWS', 'system32', 'taskkill.exe')
command = [killCommmand, "/f", "/im", image_name]
# taskkill will exit 128 if the process is not found. We should log.
- self.run_command(command, error_handler=self.ignore_error)
+ self.run_command(command, ignore_errors=True)
return
# FIXME: This is inconsistent that kill_all uses TERM and kill_process
@@ -336,7 +336,7 @@
# killall returns 1 if no process can be found and 2 on command error.
# FIXME: We should pass a custom error_handler to allow only exit_code 1.
# We should log in exit_code == 1
- self.run_command(command, error_handler=self.ignore_error)
+ self.run_command(command, ignore_errors=True)
def _compute_stdin(self, input):
"""Returns (stdin, string_to_communicate)"""
@@ -364,6 +364,7 @@
env=None,
input=None,
error_handler=None,
+ ignore_errors=False,
return_exit_code=False,
return_stderr=True,
decode_output=True):
@@ -401,6 +402,11 @@
exit_code=exit_code,
output=output,
cwd=cwd)
+
+ if ignore_errors:
+ assert error_handler is None, "don't specify error_handler if ignore_errors is True"
+ error_handler = Executive.ignore_error
+
(error_handler or self.default_error_handler)(script_error)
return output
Modified: trunk/Tools/Scripts/webkitpy/common/system/executive_mock.py (227426 => 227427)
--- trunk/Tools/Scripts/webkitpy/common/system/executive_mock.py 2018-01-23 19:29:48 UTC (rev 227426)
+++ trunk/Tools/Scripts/webkitpy/common/system/executive_mock.py 2018-01-23 19:31:04 UTC (rev 227427)
@@ -108,6 +108,7 @@
cwd=None,
input=None,
error_handler=None,
+ ignore_errors=False,
return_exit_code=False,
return_stderr=True,
decode_output=False,
@@ -185,6 +186,7 @@
cwd=None,
input=None,
error_handler=None,
+ ignore_errors=False,
return_exit_code=False,
return_stderr=True,
decode_output=False,
@@ -191,6 +193,11 @@
env=None):
self.calls.append(args)
assert(isinstance(args, list) or isinstance(args, tuple))
+
+ if ignore_errors:
+ assert error_handler is None, "don't specify error_handler if ignore_errors is True"
+ error_handler = self.ignore_error
+
if self._exception:
raise self._exception # pylint: disable=E0702
if self._run_command_fn:
Modified: trunk/Tools/Scripts/webkitpy/common/system/executive_unittest.py (227426 => 227427)
--- trunk/Tools/Scripts/webkitpy/common/system/executive_unittest.py 2018-01-23 19:29:48 UTC (rev 227426)
+++ trunk/Tools/Scripts/webkitpy/common/system/executive_unittest.py 2018-01-23 19:31:04 UTC (rev 227427)
@@ -105,7 +105,7 @@
def test_run_command_with_bad_command(self):
def run_bad_command():
- Executive().run_command(["foo_bar_command_blah"], error_handler=Executive.ignore_error, return_exit_code=True)
+ Executive().run_command(["foo_bar_command_blah"], ignore_errors=True, return_exit_code=True)
self.assertRaises(OSError, run_bad_command)
def test_run_command_args_type(self):
Modified: trunk/Tools/Scripts/webkitpy/common/system/platforminfo.py (227426 => 227427)
--- trunk/Tools/Scripts/webkitpy/common/system/platforminfo.py 2018-01-23 19:29:48 UTC (rev 227426)
+++ trunk/Tools/Scripts/webkitpy/common/system/platforminfo.py 2018-01-23 19:31:04 UTC (rev 227427)
@@ -152,7 +152,7 @@
def xcode_sdk_version(self, sdk_name):
if self.is_mac():
# Assumes that xcrun does not write to standard output on failure (e.g. SDK does not exist).
- xcrun_output = self.executive.run_command(['xcrun', '--sdk', sdk_name, '--show-sdk-version'], return_stderr=False, error_handler=Executive.ignore_error).rstrip()
+ xcrun_output = self.executive.run_command(['xcrun', '--sdk', sdk_name, '--show-sdk-version'], return_stderr=False, ignore_errors=True).rstrip()
if xcrun_output:
return Version.from_string(xcrun_output)
return None
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/servers/http_server.py (227426 => 227427)
--- trunk/Tools/Scripts/webkitpy/layout_tests/servers/http_server.py 2018-01-23 19:29:48 UTC (rev 227426)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/servers/http_server.py 2018-01-23 19:31:04 UTC (rev 227427)
@@ -222,7 +222,7 @@
# parent, so we can't use executive.kill_process().
#
# If this is actually working, we should figure out a clean API.
- self._executive.run_command(["taskkill.exe", "/f", "/t", "/pid", self._pid], error_handler=self._executive.ignore_error)
+ self._executive.run_command(["taskkill.exe", "/f", "/t", "/pid", self._pid], ignore_errors=True)
else:
self._executive.kill_process(self._pid)
return False
Modified: trunk/Tools/Scripts/webkitpy/port/base.py (227426 => 227427)
--- trunk/Tools/Scripts/webkitpy/port/base.py 2018-01-23 19:29:48 UTC (rev 227426)
+++ trunk/Tools/Scripts/webkitpy/port/base.py 2018-01-23 19:31:04 UTC (rev 227427)
@@ -1490,7 +1490,7 @@
symbols = ''
for path_to_module in self._modules_to_search_for_symbols():
try:
- symbols += self._executive.run_command([self.nm_command(), path_to_module], error_handler=self._executive.ignore_error)
+ symbols += self._executive.run_command([self.nm_command(), path_to_module], ignore_errors=True)
except OSError as e:
_log.warn("Failed to run nm: %s. Can't determine supported features correctly." % e)
return symbols
Modified: trunk/Tools/Scripts/webkitpy/port/gtk.py (227426 => 227427)
--- trunk/Tools/Scripts/webkitpy/port/gtk.py 2018-01-23 19:29:48 UTC (rev 227426)
+++ trunk/Tools/Scripts/webkitpy/port/gtk.py 2018-01-23 19:31:04 UTC (rev 227427)
@@ -127,7 +127,7 @@
# Configure the software libgl renderer if jhbuild ready and we test inside a virtualized window system
if self._driver_class() in [XvfbDriver, WestonDriver] and self._should_use_jhbuild():
llvmpipe_libgl_path = self.host.executive.run_command(self._jhbuild_wrapper + ['printenv', 'LLVMPIPE_LIBGL_PATH'],
- error_handler=self.host.executive.ignore_error).strip()
+ ignore_errors=True).strip()
dri_libgl_path = os.path.join(llvmpipe_libgl_path, "dri")
if os.path.exists(os.path.join(llvmpipe_libgl_path, "libGL.so")) and os.path.exists(os.path.join(dri_libgl_path, "swrast_dri.so")):
# Force the Gallium llvmpipe software rasterizer
Modified: trunk/Tools/Scripts/webkitpy/port/win.py (227426 => 227427)
--- trunk/Tools/Scripts/webkitpy/port/win.py 2018-01-23 19:29:48 UTC (rev 227426)
+++ trunk/Tools/Scripts/webkitpy/port/win.py 2018-01-23 19:31:04 UTC (rev 227427)
@@ -151,7 +151,7 @@
def _runtime_feature_list(self):
supported_features_command = [self._path_to_driver(), '--print-supported-features']
try:
- output = self._executive.run_command(supported_features_command, error_handler=Executive.ignore_error)
+ output = self._executive.run_command(supported_features_command, ignore_errors=True)
except OSError as e:
_log.warn("Exception running driver: %s, %s. Driver must be built before calling WebKitPort.test_expectations()." % (supported_features_command, e))
return None
@@ -261,7 +261,7 @@
registry_key = reg_path % (root, key)
_log.debug("Reading %s" % (registry_key))
read_registry_command = ["regtool", arch, "get", registry_key]
- int_value = self._executive.run_command(read_registry_command, error_handler=Executive.ignore_error)
+ int_value = self._executive.run_command(read_registry_command, ignore_errors=True)
# regtool doesn't return the type of the entry, so need this ugly hack:
if reg_path in (self.WINDOWS_ERROR_REPORTING_KEY, self.WOW64_WINDOWS_ERROR_REPORTING_KEY):
_log.debug("I got {0}".format(int_value))
Modified: trunk/Tools/Scripts/webkitpy/port/win_unittest.py (227426 => 227427)
--- trunk/Tools/Scripts/webkitpy/port/win_unittest.py 2018-01-23 19:29:48 UTC (rev 227426)
+++ trunk/Tools/Scripts/webkitpy/port/win_unittest.py 2018-01-23 19:31:04 UTC (rev 227427)
@@ -95,10 +95,10 @@
def test_runtime_feature_list(self):
port = self.make_port()
- port._executive.run_command = lambda command, cwd=None, error_handler=None: "Nonsense"
+ port._executive.run_command = lambda command, cwd=None, ignore_errors=False: "Nonsense"
# runtime_features_list returns None when its results are meaningless (it couldn't run DRT or parse the output, etc.)
self.assertEqual(port._runtime_feature_list(), None)
- port._executive.run_command = lambda command, cwd=None, error_handler=None: "SupportedFeatures:foo bar"
+ port._executive.run_command = lambda command, cwd=None, ignore_errors=False: "SupportedFeatures:foo bar"
self.assertEqual(port._runtime_feature_list(), ['foo', 'bar'])
def test_expectations_files(self):
Modified: trunk/Tools/Scripts/webkitpy/tool/commands/analyzechangelog.py (227426 => 227427)
--- trunk/Tools/Scripts/webkitpy/tool/commands/analyzechangelog.py 2018-01-23 19:29:48 UTC (rev 227426)
+++ trunk/Tools/Scripts/webkitpy/tool/commands/analyzechangelog.py 2018-01-23 19:31:04 UTC (rev 227427)
@@ -35,7 +35,6 @@
from webkitpy.common.checkout.changelog import ChangeLog
from webkitpy.common.config.contributionareas import ContributionAreas
from webkitpy.common.system.filesystem import FileSystem
-from webkitpy.common.system.executive import Executive
from webkitpy.tool.multicommandtool import Command
from webkitpy.tool import steps
Modified: trunk/Tools/Scripts/webkitpy/tool/commands/analyzechangelog_unittest.py (227426 => 227427)
--- trunk/Tools/Scripts/webkitpy/tool/commands/analyzechangelog_unittest.py 2018-01-23 19:29:48 UTC (rev 227426)
+++ trunk/Tools/Scripts/webkitpy/tool/commands/analyzechangelog_unittest.py 2018-01-23 19:31:04 UTC (rev 227427)
@@ -31,7 +31,6 @@
from webkitpy.common.config.contributionareas import ContributionAreas
from webkitpy.common.host_mock import MockHost
from webkitpy.common.system.filesystem_mock import MockFileSystem
-from webkitpy.common.system.executive import Executive
from webkitpy.common.system.outputcapture import OutputCapture
from webkitpy.tool.commands.analyzechangelog import AnalyzeChangeLog
from webkitpy.tool.commands.analyzechangelog import ChangeLogAnalyzer