Changeset 106721 in webkit


Ignore:
Timestamp:
Feb 3, 2012 5:41:14 PM (12 years ago)
Author:
dpranke@chromium.org
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):

Location:
trunk/Tools
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r106714 r106721  
     12012-02-03  Dirk Pranke  <dpranke@chromium.org>
     2
     3        webkitpy: change exit() calls to sys.exit(), fix a leak in outputcapture
     4        https://bugs.webkit.org/show_bug.cgi?id=77781
     5
     6        Reviewed by Eric Seidel.
     7
     8        This change fixes a couple of issues discovered while debugging
     9        test-webkitpy; both calling exit() instead of sys.exit() --
     10        which is discouraged in program code instead of the interpreter
     11        -- and a particular usage of outputcapture were stdin to get whacked
     12        and preventing debugging.
     13       
     14        This change introduces a couple of common _exit() methods that
     15        will standardize how webkit-patch exit's, in case we need to do
     16        something different in the future.
     17
     18        * Scripts/webkitpy/common/system/deprecated_logging.py:
     19        (error):
     20        * Scripts/webkitpy/common/system/outputcapture.py:
     21        (OutputCapture.assert_outputs):
     22        * Scripts/webkitpy/tool/bot/queueengine.py:
     23        (QueueEngine.exit_after_handled_error):
     24        * Scripts/webkitpy/tool/commands/abstractsequencedcommand.py:
     25        (AbstractSequencedCommand.execute):
     26        * Scripts/webkitpy/tool/commands/queues.py:
     27        (StyleQueue.handle_script_error):
     28        * Scripts/webkitpy/tool/commands/upload.py:
     29        (MarkBugFixed.execute):
     30        * Scripts/webkitpy/tool/multicommandtool.py:
     31        (Command._exit):
     32        * Scripts/webkitpy/tool/steps/abstractstep.py:
     33        (AbstractStep._exit):
     34        * Scripts/webkitpy/tool/steps/checkstyle.py:
     35        (CheckStyle.run):
     36        * Scripts/webkitpy/tool/steps/commit.py:
     37        (Commit._check_test_expectations):
     38        * Scripts/webkitpy/tool/steps/confirmdiff.py:
     39        (ConfirmDiff.run):
     40
    1412012-02-03  Ryosuke Niwa  <rniwa@webkit.org>
    242
  • trunk/Tools/Scripts/webkitpy/common/system/deprecated_logging.py

    r58036 r106721  
    4242def error(string):
    4343    log("ERROR: %s" % string)
    44     exit(1)
     44    sys.exit(1)
    4545
    4646
  • trunk/Tools/Scripts/webkitpy/common/system/outputcapture.py

    r101533 r106721  
    7575    def assert_outputs(self, testcase, function, args=[], kwargs={}, expected_stdout="", expected_stderr="", expected_exception=None, expected_logs=None):
    7676        self.capture_output()
    77         if expected_exception:
    78             return_value = testcase.assertRaises(expected_exception, function, *args, **kwargs)
    79         else:
    80             return_value = function(*args, **kwargs)
    81         (stdout_string, stderr_string, logs_string) = self.restore_output()
     77        try:
     78            if expected_exception:
     79                return_value = testcase.assertRaises(expected_exception, function, *args, **kwargs)
     80            else:
     81                return_value = function(*args, **kwargs)
     82        finally:
     83            (stdout_string, stderr_string, logs_string) = self.restore_output()
     84
    8285        testcase.assertEqual(stdout_string, expected_stdout)
    8386        testcase.assertEqual(stderr_string, expected_stderr)
  • trunk/Tools/Scripts/webkitpy/tool/bot/queueengine.py

    r89618 r106721  
    2929
    3030import os
     31import sys
    3132import time
    3233import traceback
     
    8788    def exit_after_handled_error(cls, error):
    8889        log(error)
    89         exit(cls.handled_error_code)
     90        sys.exit(cls.handled_error_code)
    9091
    9192    def run(self):
  • trunk/Tools/Scripts/webkitpy/tool/commands/abstractsequencedcommand.py

    r73951 r106721  
    4747        except ScriptError, e:
    4848            log(e.message_with_output())
    49             exit(e.exit_code or 2)
     49            self._exit(e.exit_code or 2)
    5050
    5151        self._sequence.run_and_handle_errors(tool, options, state)
  • trunk/Tools/Scripts/webkitpy/tool/commands/queues.py

    r100697 r106721  
    3131
    3232import codecs
     33import os
     34import sys
    3335import time
    3436import traceback
    35 import os
    3637
    3738from datetime import datetime
     
    441442        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))
    442443        tool.bugs.post_comment_to_bug(state["patch"].bug_id(), message, cc=cls.watchers)
    443         exit(1)
     444        sys.exit(1)
  • trunk/Tools/Scripts/webkitpy/tool/commands/upload.py

    r101834 r106721  
    411411        if needs_prompt:
    412412            if not tool.user.confirm("Is this correct?"):
    413                 exit(1)
     413                self._exit(1)
    414414
    415415        bug_comment = bug_comment_from_svn_revision(svn_revision)
  • trunk/Tools/Scripts/webkitpy/tool/multicommandtool.py

    r67916 r106721  
    5959        self.option_parser = HelpPrintingOptionParser(usage=SUPPRESS_USAGE, add_help_option=False, option_list=self.options)
    6060
     61    def _exit(self, code):
     62        sys.exit(code)
     63
    6164    # This design is slightly awkward, but we need the
    6265    # the tool to be able to create and modify the option_parser
  • trunk/Tools/Scripts/webkitpy/tool/steps/abstractstep.py

    r101834 r106721  
    2727# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2828
     29import sys
     30
    2931from webkitpy.common.system.executive import ScriptError
    3032from webkitpy.common.config.ports import WebKitPort
     
    3638        self._tool = tool
    3739        self._options = options
     40
     41    def _exit(self, code):
     42        sys.exit(code)
    3843
    3944    def _changed_files(self, state):
  • trunk/Tools/Scripts/webkitpy/tool/steps/checkstyle.py

    r97521 r106721  
    6868                raise e
    6969            if not self._tool.user.confirm("Are you sure you want to continue?"):
    70                 exit(1)
     70                self._exit(1)
  • trunk/Tools/Scripts/webkitpy/tool/steps/commit.py

    r105213 r106721  
    2626# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    2727# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     28
     29import sys
    2830
    2931from webkitpy.common.checkout.scm import AuthenticationError, AmbiguousCommitError
     
    6668        except ScriptError, e:
    6769            if not self._tool.user.confirm("Are you sure you want to continue?", default="n"):
    68                 exit(1)
     70                self._exit(1)
    6971
    7072    def run(self, state):
  • trunk/Tools/Scripts/webkitpy/tool/steps/confirmdiff.py

    r60666 r106721  
    7575            pretty_diff_file.close()
    7676        if not diff_correct:
    77             exit(1)
     77            self._exit(1)
Note: See TracChangeset for help on using the changeset viewer.