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 18 matching lines...) Expand all Loading... |
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.host import Host | 35 from webkitpy.common.host import Host |
36 from webkitpy.layout_tests.models import test_expectations | 36 from webkitpy.layout_tests.models import test_expectations |
37 from webkitpy.layout_tests.port.factory import platform_options | 37 from webkitpy.layout_tests.port.factory import platform_options |
38 | 38 |
39 | |
40 # This mirrors what the shell normally does. | 39 # This mirrors what the shell normally does. |
41 INTERRUPTED_EXIT_STATUS = signal.SIGINT + 128 | 40 INTERRUPTED_EXIT_STATUS = signal.SIGINT + 128 |
42 | 41 |
43 # This is a randomly chosen exit code that can be tested against to | 42 # This is a randomly chosen exit code that can be tested against to |
44 # indicate that an unexpected exception occurred. | 43 # indicate that an unexpected exception occurred. |
45 EXCEPTIONAL_EXIT_STATUS = 254 | 44 EXCEPTIONAL_EXIT_STATUS = 254 |
46 | 45 |
47 _log = logging.getLogger(__name__) | 46 _log = logging.getLogger(__name__) |
48 | 47 |
49 | 48 |
50 def lint(host, options): | 49 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)] | 50 ports_to_lint = [host.port_factory.get(name) for name in host.port_factory.a
ll_port_names(options.platform)] |
52 files_linted = set() | 51 files_linted = set() |
53 | 52 |
54 failures = [] | 53 failures = [] |
55 for port_to_lint in ports_to_lint: | 54 for port_to_lint in ports_to_lint: |
56 expectations_dict = port_to_lint.expectations_dict() | 55 expectations_dict = port_to_lint.expectations_dict() |
57 | 56 |
58 for expectations_file in expectations_dict.keys(): | 57 for expectations_file in expectations_dict.keys(): |
59 if expectations_file in files_linted: | 58 if expectations_file in files_linted: |
60 continue | 59 continue |
61 | 60 |
62 try: | 61 try: |
63 test_expectations.TestExpectations(port_to_lint, | 62 test_expectations.TestExpectations(port_to_lint, |
64 expectations_dict={expectations_file: expectations_dict[expe
ctations_file]}, | 63 expectations_dict={expectatio
ns_file: expectations_dict[expectations_file]}, |
65 is_lint_mode=True) | 64 is_lint_mode=True) |
66 except test_expectations.ParseError as e: | 65 except test_expectations.ParseError as e: |
67 _log.error('') | 66 _log.error('') |
68 for warning in e.warnings: | 67 for warning in e.warnings: |
69 _log.error(warning) | 68 _log.error(warning) |
70 failures.append('%s: %s' % (expectations_file, warning)) | 69 failures.append('%s: %s' % (expectations_file, warning)) |
71 _log.error('') | 70 _log.error('') |
72 files_linted.add(expectations_file) | 71 files_linted.add(expectations_file) |
73 return failures | 72 return failures |
74 | 73 |
75 | 74 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 try: | 141 try: |
143 exit_status = run_checks(host, options, stderr) | 142 exit_status = run_checks(host, options, stderr) |
144 except KeyboardInterrupt: | 143 except KeyboardInterrupt: |
145 exit_status = INTERRUPTED_EXIT_STATUS | 144 exit_status = INTERRUPTED_EXIT_STATUS |
146 except Exception as e: | 145 except Exception as e: |
147 print >> stderr, '\n%s raised: %s' % (e.__class__.__name__, str(e)) | 146 print >> stderr, '\n%s raised: %s' % (e.__class__.__name__, str(e)) |
148 traceback.print_exc(file=stderr) | 147 traceback.print_exc(file=stderr) |
149 exit_status = EXCEPTIONAL_EXIT_STATUS | 148 exit_status = EXCEPTIONAL_EXIT_STATUS |
150 | 149 |
151 return exit_status | 150 return exit_status |
OLD | NEW |