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

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
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) != 0:
Tom Sepez 2015/10/28 20:25:48 nit: can just write if len(args):
dsinclair 2015/10/28 20:56:46 Done.
109 for file_name in args:
110 input_path = os.path.join(walk_from_dir, file_name)
111 if os.path.isfile(input_path):
Tom Sepez 2015/10/28 20:25:48 This is to filter out directories, you shouldn't b
dsinclair 2015/10/28 20:56:46 Done.
112 test_cases.append((os.path.basename(input_path),
113 os.path.dirname(input_path)))
Tom Sepez 2015/10/28 20:25:48 nit: this should line up under the above.
dsinclair 2015/10/28 20:56:46 Like this?
114 else:
115 for source_dir, _, filename_list in os.walk(walk_from_dir):
116 for input_filename in filename_list:
117 if input_file_re.match(input_filename):
118 input_path = os.path.join(source_dir, input_filename)
119 if os.path.isfile(input_path):
120 test_cases.append((input_filename, source_dir))
121
122 if options.num_workers > 1 and len(test_cases) > 1:
115 try: 123 try:
116 pool = multiprocessing.Pool(options.num_workers) 124 pool = multiprocessing.Pool(options.num_workers)
117 worker_func = functools.partial(test_one_file_parallel, working_dir, 125 worker_func = functools.partial(test_one_file_parallel, working_dir,
118 pdfium_test_path, image_differ) 126 pdfium_test_path, image_differ)
119 worker_results = pool.imap(worker_func, test_cases) 127 worker_results = pool.imap(worker_func, test_cases)
120 for worker_result in worker_results: 128 for worker_result in worker_results:
121 result, output, input_filename, source_dir = worker_result 129 result, output, input_filename, source_dir = worker_result
122 input_path = os.path.join(source_dir, input_filename) 130 input_path = os.path.join(source_dir, input_filename)
123 sys.stdout.write(output) 131 sys.stdout.write(output)
124 handle_result(test_suppressor, input_filename, input_path, result, 132 handle_result(test_suppressor, input_filename, input_path, result,
(...skipping 22 matching lines...) Expand all
147 print '\n\nSummary of Failures:' 155 print '\n\nSummary of Failures:'
148 for failure in failures: 156 for failure in failures:
149 print failure 157 print failure
150 return 1 158 return 1
151 159
152 return 0 160 return 0
153 161
154 162
155 if __name__ == '__main__': 163 if __name__ == '__main__':
156 sys.exit(main()) 164 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | testing/tools/run_javascript_tests.py » ('j') | testing/tools/run_javascript_tests.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698