OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2015 The PDFium Authors. All rights reserved. | 2 # Copyright 2015 The PDFium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 import cStringIO | 6 import cStringIO |
7 import functools | 7 import functools |
8 import multiprocessing | 8 import multiprocessing |
9 import optparse | 9 import optparse |
10 import os | 10 import os |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 output = sys.stdout | 67 output = sys.stdout |
68 sys.stdout = old_stdout | 68 sys.stdout = old_stdout |
69 sys.stderr = old_stderr | 69 sys.stderr = old_stderr |
70 return (result, output.getvalue(), input_filename, source_dir) | 70 return (result, output.getvalue(), input_filename, source_dir) |
71 except KeyboardInterrupt: | 71 except KeyboardInterrupt: |
72 raise KeyboardInterruptError() | 72 raise KeyboardInterruptError() |
73 | 73 |
74 | 74 |
75 def handle_result(test_suppressor, input_filename, input_path, result, | 75 def handle_result(test_suppressor, input_filename, input_path, result, |
76 surprises, failures): | 76 surprises, failures): |
77 if test_suppressor.IsSuppressed(input_filename): | 77 if test_suppressor.IsResultSuppressed(input_filename): |
78 if result: | 78 if result: |
79 surprises.append(input_path) | 79 surprises.append(input_path) |
80 else: | 80 else: |
81 if not result: | 81 if not result: |
82 failures.append(input_path) | 82 failures.append(input_path) |
83 | 83 |
84 | 84 |
85 def main(): | 85 def main(): |
86 parser = optparse.OptionParser() | 86 parser = optparse.OptionParser() |
87 parser.add_option('--build-dir', default=os.path.join('out', 'Debug'), | 87 parser.add_option('--build-dir', default=os.path.join('out', 'Debug'), |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 print "Can't find test file '%s'" % file_name | 120 print "Can't find test file '%s'" % file_name |
121 return 1 | 121 return 1 |
122 | 122 |
123 test_cases.append((os.path.basename(input_path), | 123 test_cases.append((os.path.basename(input_path), |
124 os.path.dirname(input_path))) | 124 os.path.dirname(input_path))) |
125 else: | 125 else: |
126 for source_dir, _, filename_list in os.walk(walk_from_dir): | 126 for source_dir, _, filename_list in os.walk(walk_from_dir): |
127 for input_filename in filename_list: | 127 for input_filename in filename_list: |
128 if input_file_re.match(input_filename): | 128 if input_file_re.match(input_filename): |
129 input_path = os.path.join(source_dir, input_filename) | 129 input_path = os.path.join(source_dir, input_filename) |
130 if os.path.isfile(input_path): | 130 if not test_suppressor.IsExecutionSuppressed(input_path): |
131 test_cases.append((input_filename, source_dir)) | 131 if os.path.isfile(input_path): |
| 132 test_cases.append((input_filename, source_dir)) |
132 | 133 |
133 if options.num_workers > 1 and len(test_cases) > 1: | 134 if options.num_workers > 1 and len(test_cases) > 1: |
134 try: | 135 try: |
135 pool = multiprocessing.Pool(options.num_workers) | 136 pool = multiprocessing.Pool(options.num_workers) |
136 worker_func = functools.partial(test_one_file_parallel, working_dir, | 137 worker_func = functools.partial(test_one_file_parallel, working_dir, |
137 pdfium_test_path, image_differ) | 138 pdfium_test_path, image_differ) |
138 worker_results = pool.imap(worker_func, test_cases) | 139 worker_results = pool.imap(worker_func, test_cases) |
139 for worker_result in worker_results: | 140 for worker_result in worker_results: |
140 result, output, input_filename, source_dir = worker_result | 141 result, output, input_filename, source_dir = worker_result |
141 input_path = os.path.join(source_dir, input_filename) | 142 input_path = os.path.join(source_dir, input_filename) |
(...skipping 25 matching lines...) Expand all Loading... |
167 print '\n\nSummary of Failures:' | 168 print '\n\nSummary of Failures:' |
168 for failure in failures: | 169 for failure in failures: |
169 print failure | 170 print failure |
170 return 1 | 171 return 1 |
171 | 172 |
172 return 0 | 173 return 0 |
173 | 174 |
174 | 175 |
175 if __name__ == '__main__': | 176 if __name__ == '__main__': |
176 sys.exit(main()) | 177 sys.exit(main()) |
OLD | NEW |