| OLD | NEW |
| 1 # Copyright 2013 the V8 project authors. All rights reserved. | 1 # Copyright 2013 the V8 project authors. All rights reserved. |
| 2 # Redistribution and use in source and binary forms, with or without | 2 # Redistribution and use in source and binary forms, with or without |
| 3 # modification, are permitted provided that the following conditions are | 3 # modification, are permitted provided that the following conditions are |
| 4 # met: | 4 # met: |
| 5 # | 5 # |
| 6 # * Redistributions of source code must retain the above copyright | 6 # * 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 # * Redistributions in binary form must reproduce the above | 8 # * Redistributions in binary form must reproduce the above |
| 9 # copyright notice, this list of conditions and the following | 9 # copyright notice, this list of conditions and the following |
| 10 # disclaimer in the documentation and/or other materials provided | 10 # disclaimer in the documentation and/or other materials provided |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 | 98 |
| 99 @staticmethod | 99 @staticmethod |
| 100 def crashed(data): | 100 def crashed(data): |
| 101 return data['process'].returncode != 0 | 101 return data['process'].returncode != 0 |
| 102 | 102 |
| 103 @staticmethod | 103 @staticmethod |
| 104 def buffer_contents(data): | 104 def buffer_contents(data): |
| 105 data['buffer'].append(data['process'].stdout.read()) | 105 data['buffer'].append(data['process'].stdout.read()) |
| 106 return ''.join(data['buffer']) | 106 return ''.join(data['buffer']) |
| 107 | 107 |
| 108 @staticmethod |
| 109 def analyse_diff(left_data, right_data): |
| 110 left = left_data.split("\n"); |
| 111 right = right_data.split("\n"); |
| 112 for i in range(min(len(left), len(right))): |
| 113 if left[i] != right[i]: |
| 114 message = "differ at token %d" % i |
| 115 for j in range(i-4, i-1): |
| 116 if j >= 0: |
| 117 message += "\n\n%s\n%s" % (left[j], right[j]) |
| 118 message += "\n\n%s\n%s\n" % (left[i], right[i]) |
| 119 logging.info(message) |
| 120 return |
| 121 if len(right) > len(left): |
| 122 logging.info("right longer") |
| 123 return |
| 124 if len(left) > len(right): |
| 125 logging.info("left longer") |
| 126 return |
| 127 |
| 108 def compare_results(self, left, right): | 128 def compare_results(self, left, right): |
| 109 f = left['file'] | 129 f = left['file'] |
| 110 assert f == right['file'] | 130 assert f == right['file'] |
| 111 logging.info('checking results for %s' % f) | 131 logging.info('checking results for %s' % f) |
| 112 if self.crashed(left) or self.crashed(right): | 132 if self.crashed(left) or self.crashed(right): |
| 113 print "%s failed" % f | 133 print "%s failed" % f |
| 114 return | 134 return |
| 115 if left['path'] == self.right_path: | 135 if left['path'] == self.right_path: |
| 116 left, right = right, left | 136 left, right = right, left |
| 117 left_data = self.buffer_contents(left) | 137 left_data = self.buffer_contents(left) |
| 118 right_data = self.buffer_contents(right) | 138 right_data = self.buffer_contents(right) |
| 119 if left_data != right_data: | 139 if left_data != right_data: |
| 120 # TODO(dcarney): analyse differences | 140 self.analyse_diff(left_data, right_data) |
| 121 print "%s failed" % f | 141 print "%s failed" % f |
| 122 return | 142 return |
| 123 print "%s succeeded" % f | 143 print "%s succeeded" % f |
| 124 | 144 |
| 125 def process_complete_processes(self): | 145 def process_complete_processes(self): |
| 126 complete_processes = self.complete_processes | 146 complete_processes = self.complete_processes |
| 127 complete_ids = [] | 147 complete_ids = [] |
| 128 for i, data in complete_processes.iteritems(): | 148 for i, data in complete_processes.iteritems(): |
| 129 if not self.right_path: | 149 if not self.right_path: |
| 130 assert not i in complete_ids | 150 assert not i in complete_ids |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 | 197 |
| 178 if __name__ == '__main__': | 198 if __name__ == '__main__': |
| 179 | 199 |
| 180 parser = argparse.ArgumentParser() | 200 parser = argparse.ArgumentParser() |
| 181 parser.add_argument('-l', '--left-path') | 201 parser.add_argument('-l', '--left-path') |
| 182 parser.add_argument('-r', '--right-path', default='') | 202 parser.add_argument('-r', '--right-path', default='') |
| 183 parser.add_argument('-i', '--input-files-path', default='') | 203 parser.add_argument('-i', '--input-files-path', default='') |
| 184 parser.add_argument('-f', '--single-file', default='') | 204 parser.add_argument('-f', '--single-file', default='') |
| 185 parser.add_argument('-p', '--parallel-process-count', default=1, type=int) | 205 parser.add_argument('-p', '--parallel-process-count', default=1, type=int) |
| 186 parser.add_argument('-e', '--encoding', | 206 parser.add_argument('-e', '--encoding', |
| 187 choices=['latin1', 'utf8', 'utf8to16', 'utf16'], default='utf8') | 207 choices=['latin1', 'utf8', 'utf16', 'utf8to16', 'utf8tolatin1'], |
| 208 default='utf8') |
| 188 parser.add_argument('--use-harmony', action='store_true') | 209 parser.add_argument('--use-harmony', action='store_true') |
| 189 parser.add_argument('-v', '--verbose', action='store_true') | 210 parser.add_argument('-v', '--verbose', action='store_true') |
| 190 args = parser.parse_args() | 211 args = parser.parse_args() |
| 191 | 212 |
| 192 if args.verbose: | 213 if args.verbose: |
| 193 logging.basicConfig(level=logging.INFO) | 214 logging.basicConfig(level=logging.INFO) |
| 194 | 215 |
| 195 files = [] | 216 files = [] |
| 196 if args.input_files_path: | 217 if args.input_files_path: |
| 197 with open(args.input_files_path, 'r') as f: | 218 with open(args.input_files_path, 'r') as f: |
| 198 files = [filename for filename in f.read().split('\n') if filename] | 219 files = [filename for filename in f.read().split('\n') if filename] |
| 199 if args.single_file: | 220 if args.single_file: |
| 200 files.append(args.single_file) | 221 files.append(args.single_file) |
| 201 assert files | 222 assert files |
| 202 | 223 |
| 203 process_runner = ProcessRunner(files, args) | 224 process_runner = ProcessRunner(files, args) |
| 204 process_runner.run() | 225 process_runner.run() |
| OLD | NEW |