Title: [106721] trunk/Tools
Revision
106721
Author
[email protected]
Date
2012-02-03 17:41:14 -0800 (Fri, 03 Feb 2012)

Log Message

webkitpy: change exit() calls to sys.exit(), fix a leak in outputcapture
https://bugs.webkit.org/show_bug.cgi?id=77781

Reviewed by Eric Seidel.

This change fixes a couple of issues discovered while debugging
test-webkitpy; both calling exit() instead of sys.exit() --
which is discouraged in program code instead of the interpreter
-- and a particular usage of outputcapture were stdin to get whacked
and preventing debugging.

This change introduces a couple of common _exit() methods that
will standardize how webkit-patch exit's, in case we need to do
something different in the future.

* Scripts/webkitpy/common/system/deprecated_logging.py:
(error):
* Scripts/webkitpy/common/system/outputcapture.py:
(OutputCapture.assert_outputs):
* Scripts/webkitpy/tool/bot/queueengine.py:
(QueueEngine.exit_after_handled_error):
* Scripts/webkitpy/tool/commands/abstractsequencedcommand.py:
(AbstractSequencedCommand.execute):
* Scripts/webkitpy/tool/commands/queues.py:
(StyleQueue.handle_script_error):
* Scripts/webkitpy/tool/commands/upload.py:
(MarkBugFixed.execute):
* Scripts/webkitpy/tool/multicommandtool.py:
(Command._exit):
* Scripts/webkitpy/tool/steps/abstractstep.py:
(AbstractStep._exit):
* Scripts/webkitpy/tool/steps/checkstyle.py:
(CheckStyle.run):
* Scripts/webkitpy/tool/steps/commit.py:
(Commit._check_test_expectations):
* Scripts/webkitpy/tool/steps/confirmdiff.py:
(ConfirmDiff.run):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (106720 => 106721)


--- trunk/Tools/ChangeLog	2012-02-04 01:33:46 UTC (rev 106720)
+++ trunk/Tools/ChangeLog	2012-02-04 01:41:14 UTC (rev 106721)
@@ -1,3 +1,43 @@
+2012-02-03  Dirk Pranke  <[email protected]>
+
+        webkitpy: change exit() calls to sys.exit(), fix a leak in outputcapture
+        https://bugs.webkit.org/show_bug.cgi?id=77781
+
+        Reviewed by Eric Seidel.
+
+        This change fixes a couple of issues discovered while debugging
+        test-webkitpy; both calling exit() instead of sys.exit() --
+        which is discouraged in program code instead of the interpreter
+        -- and a particular usage of outputcapture were stdin to get whacked
+        and preventing debugging.
+       
+        This change introduces a couple of common _exit() methods that
+        will standardize how webkit-patch exit's, in case we need to do
+        something different in the future.
+
+        * Scripts/webkitpy/common/system/deprecated_logging.py:
+        (error):
+        * Scripts/webkitpy/common/system/outputcapture.py:
+        (OutputCapture.assert_outputs):
+        * Scripts/webkitpy/tool/bot/queueengine.py:
+        (QueueEngine.exit_after_handled_error):
+        * Scripts/webkitpy/tool/commands/abstractsequencedcommand.py:
+        (AbstractSequencedCommand.execute):
+        * Scripts/webkitpy/tool/commands/queues.py:
+        (StyleQueue.handle_script_error):
+        * Scripts/webkitpy/tool/commands/upload.py:
+        (MarkBugFixed.execute):
+        * Scripts/webkitpy/tool/multicommandtool.py:
+        (Command._exit):
+        * Scripts/webkitpy/tool/steps/abstractstep.py:
+        (AbstractStep._exit):
+        * Scripts/webkitpy/tool/steps/checkstyle.py:
+        (CheckStyle.run):
+        * Scripts/webkitpy/tool/steps/commit.py:
+        (Commit._check_test_expectations):
+        * Scripts/webkitpy/tool/steps/confirmdiff.py:
+        (ConfirmDiff.run):
+
 2012-02-03  Ryosuke Niwa  <[email protected]>
 
         Perf bot build fix.

Modified: trunk/Tools/Scripts/webkitpy/common/system/deprecated_logging.py (106720 => 106721)


--- trunk/Tools/Scripts/webkitpy/common/system/deprecated_logging.py	2012-02-04 01:33:46 UTC (rev 106720)
+++ trunk/Tools/Scripts/webkitpy/common/system/deprecated_logging.py	2012-02-04 01:41:14 UTC (rev 106721)
@@ -41,7 +41,7 @@
 
 def error(string):
     log("ERROR: %s" % string)
-    exit(1)
+    sys.exit(1)
 
 
 # Simple class to split output between multiple destinations

Modified: trunk/Tools/Scripts/webkitpy/common/system/outputcapture.py (106720 => 106721)


--- trunk/Tools/Scripts/webkitpy/common/system/outputcapture.py	2012-02-04 01:33:46 UTC (rev 106720)
+++ trunk/Tools/Scripts/webkitpy/common/system/outputcapture.py	2012-02-04 01:41:14 UTC (rev 106721)
@@ -74,11 +74,14 @@
 
     def assert_outputs(self, testcase, function, args=[], kwargs={}, expected_stdout="", expected_stderr="", expected_exception=None, expected_logs=None):
         self.capture_output()
-        if expected_exception:
-            return_value = testcase.assertRaises(expected_exception, function, *args, **kwargs)
-        else:
-            return_value = function(*args, **kwargs)
-        (stdout_string, stderr_string, logs_string) = self.restore_output()
+        try:
+            if expected_exception:
+                return_value = testcase.assertRaises(expected_exception, function, *args, **kwargs)
+            else:
+                return_value = function(*args, **kwargs)
+        finally:
+            (stdout_string, stderr_string, logs_string) = self.restore_output()
+
         testcase.assertEqual(stdout_string, expected_stdout)
         testcase.assertEqual(stderr_string, expected_stderr)
         if expected_logs is not None:

Modified: trunk/Tools/Scripts/webkitpy/tool/bot/queueengine.py (106720 => 106721)


--- trunk/Tools/Scripts/webkitpy/tool/bot/queueengine.py	2012-02-04 01:33:46 UTC (rev 106720)
+++ trunk/Tools/Scripts/webkitpy/tool/bot/queueengine.py	2012-02-04 01:41:14 UTC (rev 106721)
@@ -28,6 +28,7 @@
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 import os
+import sys
 import time
 import traceback
 
@@ -86,7 +87,7 @@
     @classmethod
     def exit_after_handled_error(cls, error):
         log(error)
-        exit(cls.handled_error_code)
+        sys.exit(cls.handled_error_code)
 
     def run(self):
         self._begin_logging()

Modified: trunk/Tools/Scripts/webkitpy/tool/commands/abstractsequencedcommand.py (106720 => 106721)


--- trunk/Tools/Scripts/webkitpy/tool/commands/abstractsequencedcommand.py	2012-02-04 01:33:46 UTC (rev 106720)
+++ trunk/Tools/Scripts/webkitpy/tool/commands/abstractsequencedcommand.py	2012-02-04 01:41:14 UTC (rev 106721)
@@ -46,6 +46,6 @@
             state = self._prepare_state(options, args, tool)
         except ScriptError, e:
             log(e.message_with_output())
-            exit(e.exit_code or 2)
+            self._exit(e.exit_code or 2)
 
         self._sequence.run_and_handle_errors(tool, options, state)

Modified: trunk/Tools/Scripts/webkitpy/tool/commands/queues.py (106720 => 106721)


--- trunk/Tools/Scripts/webkitpy/tool/commands/queues.py	2012-02-04 01:33:46 UTC (rev 106720)
+++ trunk/Tools/Scripts/webkitpy/tool/commands/queues.py	2012-02-04 01:41:14 UTC (rev 106721)
@@ -30,9 +30,10 @@
 from __future__ import with_statement
 
 import codecs
+import os
+import sys
 import time
 import traceback
-import os
 
 from datetime import datetime
 from optparse import make_option
@@ -440,4 +441,4 @@
             QueueEngine.exit_after_handled_error(script_error)
         message = "Attachment %s did not pass %s:\n\n%s\n\nIf any of these errors are false positives, please file a bug against check-webkit-style." % (state["patch"].id(), cls.name, script_error.message_with_output(output_limit=3*1024))
         tool.bugs.post_comment_to_bug(state["patch"].bug_id(), message, cc=cls.watchers)
-        exit(1)
+        sys.exit(1)

Modified: trunk/Tools/Scripts/webkitpy/tool/commands/upload.py (106720 => 106721)


--- trunk/Tools/Scripts/webkitpy/tool/commands/upload.py	2012-02-04 01:33:46 UTC (rev 106720)
+++ trunk/Tools/Scripts/webkitpy/tool/commands/upload.py	2012-02-04 01:41:14 UTC (rev 106721)
@@ -410,7 +410,7 @@
 
         if needs_prompt:
             if not tool.user.confirm("Is this correct?"):
-                exit(1)
+                self._exit(1)
 
         bug_comment = bug_comment_from_svn_revision(svn_revision)
         if options.comment:

Modified: trunk/Tools/Scripts/webkitpy/tool/multicommandtool.py (106720 => 106721)


--- trunk/Tools/Scripts/webkitpy/tool/multicommandtool.py	2012-02-04 01:33:46 UTC (rev 106720)
+++ trunk/Tools/Scripts/webkitpy/tool/multicommandtool.py	2012-02-04 01:41:14 UTC (rev 106721)
@@ -58,6 +58,9 @@
         # This default parser will be used for standalone_help printing.
         self.option_parser = HelpPrintingOptionParser(usage=SUPPRESS_USAGE, add_help_option=False, option_list=self.options)
 
+    def _exit(self, code):
+        sys.exit(code)
+
     # This design is slightly awkward, but we need the
     # the tool to be able to create and modify the option_parser
     # before it knows what Command to run.

Modified: trunk/Tools/Scripts/webkitpy/tool/steps/abstractstep.py (106720 => 106721)


--- trunk/Tools/Scripts/webkitpy/tool/steps/abstractstep.py	2012-02-04 01:33:46 UTC (rev 106720)
+++ trunk/Tools/Scripts/webkitpy/tool/steps/abstractstep.py	2012-02-04 01:41:14 UTC (rev 106721)
@@ -26,6 +26,8 @@
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
+import sys
+
 from webkitpy.common.system.executive import ScriptError
 from webkitpy.common.config.ports import WebKitPort
 from webkitpy.tool.steps.options import Options
@@ -36,6 +38,9 @@
         self._tool = tool
         self._options = options
 
+    def _exit(self, code):
+        sys.exit(code)
+
     def _changed_files(self, state):
         return self.cached_lookup(state, "changed_files")
 

Modified: trunk/Tools/Scripts/webkitpy/tool/steps/checkstyle.py (106720 => 106721)


--- trunk/Tools/Scripts/webkitpy/tool/steps/checkstyle.py	2012-02-04 01:33:46 UTC (rev 106720)
+++ trunk/Tools/Scripts/webkitpy/tool/steps/checkstyle.py	2012-02-04 01:41:14 UTC (rev 106721)
@@ -67,4 +67,4 @@
                 # style-queue do the right thing.
                 raise e
             if not self._tool.user.confirm("Are you sure you want to continue?"):
-                exit(1)
+                self._exit(1)

Modified: trunk/Tools/Scripts/webkitpy/tool/steps/commit.py (106720 => 106721)


--- trunk/Tools/Scripts/webkitpy/tool/steps/commit.py	2012-02-04 01:33:46 UTC (rev 106720)
+++ trunk/Tools/Scripts/webkitpy/tool/steps/commit.py	2012-02-04 01:41:14 UTC (rev 106721)
@@ -26,6 +26,8 @@
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
+import sys
+
 from webkitpy.common.checkout.scm import AuthenticationError, AmbiguousCommitError
 from webkitpy.common.config import urls
 from webkitpy.common.system.deprecated_logging import log
@@ -65,7 +67,7 @@
             self._tool.executive.run_and_throw_if_fail(self._tool.port().check_webkit_style_command() + args, cwd=self._tool.scm().checkout_root)
         except ScriptError, e:
             if not self._tool.user.confirm("Are you sure you want to continue?", default="n"):
-                exit(1)
+                self._exit(1)
 
     def run(self, state):
         self._commit_message = self._tool.checkout().commit_message_for_this_commit(self._options.git_commit).message()

Modified: trunk/Tools/Scripts/webkitpy/tool/steps/confirmdiff.py (106720 => 106721)


--- trunk/Tools/Scripts/webkitpy/tool/steps/confirmdiff.py	2012-02-04 01:33:46 UTC (rev 106720)
+++ trunk/Tools/Scripts/webkitpy/tool/steps/confirmdiff.py	2012-02-04 01:41:14 UTC (rev 106721)
@@ -74,4 +74,4 @@
         if pretty_diff_file:
             pretty_diff_file.close()
         if not diff_correct:
-            exit(1)
+            self._exit(1)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to