| OLD | NEW |
| 1 # Copyright (C) 2012 Google Inc. All rights reserved. | 1 # Copyright (C) 2012 Google Inc. All rights reserved. |
| 2 # | 2 # |
| 3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
| 4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
| 5 # met: | 5 # met: |
| 6 # | 6 # |
| 7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
| 8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
| 9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
| 10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 | 28 |
| 29 import json | 29 import json |
| 30 import logging | 30 import logging |
| 31 import optparse | 31 import optparse |
| 32 import signal | 32 import signal |
| 33 import traceback | 33 import traceback |
| 34 | 34 |
| 35 from webkitpy.common import exit_codes |
| 35 from webkitpy.common.host import Host | 36 from webkitpy.common.host import Host |
| 36 from webkitpy.layout_tests.models import test_expectations | 37 from webkitpy.layout_tests.models import test_expectations |
| 37 from webkitpy.layout_tests.port.factory import platform_options | 38 from webkitpy.layout_tests.port.factory import platform_options |
| 38 | 39 |
| 39 | 40 |
| 40 # This mirrors what the shell normally does. | |
| 41 INTERRUPTED_EXIT_STATUS = signal.SIGINT + 128 | |
| 42 | |
| 43 # This is a randomly chosen exit code that can be tested against to | |
| 44 # indicate that an unexpected exception occurred. | |
| 45 EXCEPTIONAL_EXIT_STATUS = 254 | |
| 46 | |
| 47 _log = logging.getLogger(__name__) | 41 _log = logging.getLogger(__name__) |
| 48 | 42 |
| 49 | 43 |
| 50 def lint(host, options): | 44 def lint(host, options): |
| 51 ports_to_lint = [host.port_factory.get(name) for name in host.port_factory.a
ll_port_names(options.platform)] | 45 ports_to_lint = [host.port_factory.get(name) for name in host.port_factory.a
ll_port_names(options.platform)] |
| 52 files_linted = set() | 46 files_linted = set() |
| 53 | 47 |
| 54 failures = [] | 48 failures = [] |
| 55 for port_to_lint in ports_to_lint: | 49 for port_to_lint in ports_to_lint: |
| 56 expectations_dict = port_to_lint.all_expectations_dict() | 50 expectations_dict = port_to_lint.all_expectations_dict() |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 # to run tests against the test platform interactively, which is useful
for | 129 # to run tests against the test platform interactively, which is useful
for |
| 136 # debugging test failures. | 130 # debugging test failures. |
| 137 from webkitpy.common.host_mock import MockHost | 131 from webkitpy.common.host_mock import MockHost |
| 138 host = MockHost() | 132 host = MockHost() |
| 139 else: | 133 else: |
| 140 host = Host() | 134 host = Host() |
| 141 | 135 |
| 142 try: | 136 try: |
| 143 exit_status = run_checks(host, options, stderr) | 137 exit_status = run_checks(host, options, stderr) |
| 144 except KeyboardInterrupt: | 138 except KeyboardInterrupt: |
| 145 exit_status = INTERRUPTED_EXIT_STATUS | 139 exit_status = exit_codes.INTERRUPTED_EXIT_STATUS |
| 146 except Exception as error: # pylint: disable=broad-except | 140 except Exception as error: # pylint: disable=broad-except |
| 147 print >> stderr, '\n%s raised: %s' % (error.__class__.__name__, error) | 141 print >> stderr, '\n%s raised: %s' % (error.__class__.__name__, error) |
| 148 traceback.print_exc(file=stderr) | 142 traceback.print_exc(file=stderr) |
| 149 exit_status = EXCEPTIONAL_EXIT_STATUS | 143 exit_status = exit_codes.EXCEPTIONAL_EXIT_STATUS |
| 150 | 144 |
| 151 return exit_status | 145 return exit_status |
| OLD | NEW |