OLD | NEW |
1 # Copyright (C) 2010 Chris Jerdonek (cjerdonek@webkit.org) | 1 # Copyright (C) 2010 Chris Jerdonek (cjerdonek@webkit.org) |
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 | 4 # modification, are permitted provided that the following conditions |
5 # are met: | 5 # are met: |
6 # 1. Redistributions of source code must retain the above copyright | 6 # 1. Redistributions of source code must retain the above copyright |
7 # notice, this list of conditions and the following disclaimer. | 7 # notice, this list of conditions and the following disclaimer. |
8 # 2. Redistributions in binary form must reproduce the above copyright | 8 # 2. Redistributions in binary form must reproduce the above copyright |
9 # notice, this list of conditions and the following disclaimer in the | 9 # notice, this list of conditions and the following disclaimer in the |
10 # documentation and/or other materials provided with the distribution. | 10 # documentation and/or other materials provided with the distribution. |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 for path in paths: | 69 for path in paths: |
70 rel_path = filesystem.relpath(path, checkout_root) | 70 rel_path = filesystem.relpath(path, checkout_root) |
71 if rel_path.startswith(filesystem.pardir): | 71 if rel_path.startswith(filesystem.pardir): |
72 # Then the path is not below the checkout root. Since all | 72 # Then the path is not below the checkout root. Since all |
73 # paths should be interpreted relative to the same root, | 73 # paths should be interpreted relative to the same root, |
74 # do not interpret any of the paths as relative to the | 74 # do not interpret any of the paths as relative to the |
75 # checkout root. Interpret all of them relative to the | 75 # checkout root. Interpret all of them relative to the |
76 # current working directory, and do not change the current | 76 # current working directory, and do not change the current |
77 # working directory. | 77 # working directory. |
78 _log.warn( | 78 _log.warn( |
79 """Path-dependent style checks may not work correctly: | 79 """Path-dependent style checks may not work correctly: |
80 | 80 |
81 One of the given paths is outside the WebKit checkout of the current | 81 One of the given paths is outside the WebKit checkout of the current |
82 working directory: | 82 working directory: |
83 | 83 |
84 Path: %s | 84 Path: %s |
85 Checkout root: %s | 85 Checkout root: %s |
86 | 86 |
87 Pass only files below the checkout root to ensure correct results. | 87 Pass only files below the checkout root to ensure correct results. |
88 See the help documentation for more info. | 88 See the help documentation for more info. |
89 """ | 89 """ |
90 % (path, checkout_root)) | 90 % (path, checkout_root)) |
91 | 91 |
92 return paths | 92 return paths |
93 rel_paths.append(rel_path) | 93 rel_paths.append(rel_path) |
94 # If we got here, the conversion was successful. | 94 # If we got here, the conversion was successful. |
95 paths = rel_paths | 95 paths = rel_paths |
96 | 96 |
97 _log.debug("Changing to checkout root: " + checkout_root) | 97 _log.debug("Changing to checkout root: " + checkout_root) |
98 filesystem.chdir(checkout_root) | 98 filesystem.chdir(checkout_root) |
99 | 99 |
100 return paths | 100 return paths |
101 | 101 |
102 | 102 |
103 class CheckWebKitStyle(object): | 103 class CheckWebKitStyle(object): |
| 104 |
104 def _engage_awesome_stderr_hacks(self): | 105 def _engage_awesome_stderr_hacks(self): |
105 # Change stderr to write with replacement characters so we don't die | 106 # Change stderr to write with replacement characters so we don't die |
106 # if we try to print something containing non-ASCII characters. | 107 # if we try to print something containing non-ASCII characters. |
107 stderr = codecs.StreamReaderWriter(sys.stderr, | 108 stderr = codecs.StreamReaderWriter(sys.stderr, |
108 codecs.getreader('utf8'), | 109 codecs.getreader('utf8'), |
109 codecs.getwriter('utf8'), | 110 codecs.getwriter('utf8'), |
110 'replace') | 111 'replace') |
111 # Setting an "encoding" attribute on the stream is necessary to | 112 # Setting an "encoding" attribute on the stream is necessary to |
112 # prevent the logging module from raising an error. See | 113 # prevent the logging module from raising an error. See |
113 # the checker.configure_logging() function for more information. | 114 # the checker.configure_logging() function for more information. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 patch_checker = PatchReader(file_reader) | 154 patch_checker = PatchReader(file_reader) |
154 patch_checker.check(patch) | 155 patch_checker.check(patch) |
155 | 156 |
156 error_count = style_processor.error_count | 157 error_count = style_processor.error_count |
157 file_count = file_reader.file_count | 158 file_count = file_reader.file_count |
158 delete_only_file_count = file_reader.delete_only_file_count | 159 delete_only_file_count = file_reader.delete_only_file_count |
159 | 160 |
160 _log.info("Total errors found: %d in %d files" % (error_count, file_coun
t)) | 161 _log.info("Total errors found: %d in %d files" % (error_count, file_coun
t)) |
161 # We fail when style errors are found or there are no checked files. | 162 # We fail when style errors are found or there are no checked files. |
162 return error_count > 0 or (file_count == 0 and delete_only_file_count ==
0) | 163 return error_count > 0 or (file_count == 0 and delete_only_file_count ==
0) |
OLD | NEW |