Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(385)

Side by Side Diff: testing/tools/run_corpus_tests.py

Issue 1407913005: Allow running individual tests. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | testing/tools/run_javascript_tests.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 97
98 test_suppressor = suppressor.Suppressor(finder) 98 test_suppressor = suppressor.Suppressor(finder)
99 image_differ = pngdiffer.PNGDiffer(finder) 99 image_differ = pngdiffer.PNGDiffer(finder)
100 100
101 # test files are under .../pdfium/testing/corpus. 101 # test files are under .../pdfium/testing/corpus.
102 failures = [] 102 failures = []
103 surprises = [] 103 surprises = []
104 walk_from_dir = finder.TestingDir('corpus'); 104 walk_from_dir = finder.TestingDir('corpus');
105 input_file_re = re.compile('^[a-zA-Z0-9_.]+[.]pdf$') 105 input_file_re = re.compile('^[a-zA-Z0-9_.]+[.]pdf$')
106 test_cases = [] 106 test_cases = []
107 for source_dir, _, filename_list in os.walk(walk_from_dir):
108 for input_filename in filename_list:
109 if input_file_re.match(input_filename):
110 input_path = os.path.join(source_dir, input_filename)
111 if os.path.isfile(input_path):
112 test_cases.append((input_filename, source_dir))
113 107
114 if options.num_workers > 1: 108 if len(args):
109 for file_name in args:
110 input_path = os.path.join(walk_from_dir, file_name)
111 if not os.path.isfile(input_path):
112 print "Can't find test file '%s'" % file_name
113 return 1
114
115 test_cases.append((os.path.basename(input_path),
116 os.path.dirname(input_path)))
117 else:
118 for source_dir, _, filename_list in os.walk(walk_from_dir):
119 for input_filename in filename_list:
120 if input_file_re.match(input_filename):
121 input_path = os.path.join(source_dir, input_filename)
122 if os.path.isfile(input_path):
123 test_cases.append((input_filename, source_dir))
124
125 if options.num_workers > 1 and len(test_cases) > 1:
115 try: 126 try:
116 pool = multiprocessing.Pool(options.num_workers) 127 pool = multiprocessing.Pool(options.num_workers)
117 worker_func = functools.partial(test_one_file_parallel, working_dir, 128 worker_func = functools.partial(test_one_file_parallel, working_dir,
118 pdfium_test_path, image_differ) 129 pdfium_test_path, image_differ)
119 worker_results = pool.imap(worker_func, test_cases) 130 worker_results = pool.imap(worker_func, test_cases)
120 for worker_result in worker_results: 131 for worker_result in worker_results:
121 result, output, input_filename, source_dir = worker_result 132 result, output, input_filename, source_dir = worker_result
122 input_path = os.path.join(source_dir, input_filename) 133 input_path = os.path.join(source_dir, input_filename)
123 sys.stdout.write(output) 134 sys.stdout.write(output)
124 handle_result(test_suppressor, input_filename, input_path, result, 135 handle_result(test_suppressor, input_filename, input_path, result,
(...skipping 22 matching lines...) Expand all
147 print '\n\nSummary of Failures:' 158 print '\n\nSummary of Failures:'
148 for failure in failures: 159 for failure in failures:
149 print failure 160 print failure
150 return 1 161 return 1
151 162
152 return 0 163 return 0
153 164
154 165
155 if __name__ == '__main__': 166 if __name__ == '__main__':
156 sys.exit(main()) 167 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | testing/tools/run_javascript_tests.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698