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

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

Issue 1026903002: Flush stdout before launching sub-processes. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: No need to change return os status code Created 5 years, 9 months 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 | « testing/tools/run_javascript_tests.py ('k') | no next file » | 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 optparse 6 import optparse
7 import os 7 import os
8 import re 8 import re
9 import subprocess 9 import subprocess
10 import sys 10 import sys
11 11
12 # Nomenclature: 12 # Nomenclature:
13 # x_root - "x" 13 # x_root - "x"
14 # x_filename - "x.ext" 14 # x_filename - "x.ext"
15 # x_path - "path/to/a/b/c/x.ext" 15 # x_path - "path/to/a/b/c/x.ext"
16 # c_dir - "path/to/a/b/c" 16 # c_dir - "path/to/a/b/c"
17 17
18 def generate_and_test(input_filename, source_dir, working_dir, 18 def generate_and_test(input_filename, source_dir, working_dir,
19 fixup_path, pdfium_test_path, pdfium_diff_path): 19 fixup_path, pdfium_test_path, pdfium_diff_path):
20 input_root, _ = os.path.splitext(input_filename) 20 input_root, _ = os.path.splitext(input_filename)
21 input_path = os.path.join(source_dir, input_root + '.in') 21 input_path = os.path.join(source_dir, input_root + '.in')
22 pdf_path = os.path.join(working_dir, input_root + '.pdf') 22 pdf_path = os.path.join(working_dir, input_root + '.pdf')
23 actual_path_template = os.path.join(working_dir, input_root + '.pdf.%d.png') 23 actual_path_template = os.path.join(working_dir, input_root + '.pdf.%d.png')
24 expected_path_template = os.path.join(source_dir, 24 expected_path_template = os.path.join(source_dir,
25 input_root + '_expected.pdf.%d.png') 25 input_root + '_expected.pdf.%d.png')
26 try: 26 try:
27 sys.stdout.flush()
27 subprocess.check_call( 28 subprocess.check_call(
28 [fixup_path, '--output-dir=' + working_dir, input_path]) 29 [fixup_path, '--output-dir=' + working_dir, input_path])
29 subprocess.check_call([pdfium_test_path, '--png', pdf_path]) 30 subprocess.check_call([pdfium_test_path, '--png', pdf_path])
30 i = 0; 31 i = 0;
31 while True: 32 while True:
32 expected_path = expected_path_template % i; 33 expected_path = expected_path_template % i;
33 actual_path = actual_path_template % i; 34 actual_path = actual_path_template % i;
34 if not os.path.exists(expected_path): 35 if not os.path.exists(expected_path):
35 if i == 0: 36 if i == 0:
36 print "WARNING: no expected results files found for " + input_filename 37 print "WARNING: no expected results files found for " + input_filename
37 break 38 break
38 print "Checking " + actual_path 39 print "Checking " + actual_path
40 sys.stdout.flush()
39 subprocess.check_call([pdfium_diff_path, expected_path, actual_path]) 41 subprocess.check_call([pdfium_diff_path, expected_path, actual_path])
40 i += 1 42 i += 1
41 except subprocess.CalledProcessError as e: 43 except subprocess.CalledProcessError as e:
42 print "FAILURE: " + input_filename + "; " + str(e) 44 print "FAILURE: " + input_filename + "; " + str(e)
43 return False 45 return False
44 return True 46 return True
45 47
46 def main(): 48 def main():
47 parser = optparse.OptionParser() 49 parser = optparse.OptionParser()
48 parser.add_option('--build-dir', default=os.path.join('out', 'Debug'), 50 parser.add_option('--build-dir', default=os.path.join('out', 'Debug'),
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 pdfium_test_path = pdfium_test_path + '.exe' 87 pdfium_test_path = pdfium_test_path + '.exe'
86 pdfium_diff_path = pdfium_diff_path + '.exe' 88 pdfium_diff_path = pdfium_diff_path + '.exe'
87 # TODO(tsepez): Mac may require special handling here. 89 # TODO(tsepez): Mac may require special handling here.
88 90
89 # Place generated files under the build directory, not source directory. 91 # Place generated files under the build directory, not source directory.
90 gen_dir = os.path.join(build_dir, 'gen', 'pdfium') 92 gen_dir = os.path.join(build_dir, 'gen', 'pdfium')
91 working_dir = os.path.join(gen_dir, 'testing', 'pixel') 93 working_dir = os.path.join(gen_dir, 'testing', 'pixel')
92 if not os.path.exists(working_dir): 94 if not os.path.exists(working_dir):
93 os.makedirs(working_dir) 95 os.makedirs(working_dir)
94 96
95 os_exit_code = 0 97 failures = []
96 input_file_re = re.compile('^[a-zA-Z0-9_.]+[.]in$') 98 input_file_re = re.compile('^[a-zA-Z0-9_.]+[.]in$')
97 for input_filename in os.listdir(source_dir): 99 for input_filename in os.listdir(source_dir):
98 if input_file_re.match(input_filename): 100 if input_file_re.match(input_filename):
99 input_path = os.path.join(source_dir, input_filename) 101 input_path = os.path.join(source_dir, input_filename)
100 if os.path.isfile(input_path): 102 if os.path.isfile(input_path):
101 if not generate_and_test(input_filename, source_dir, working_dir, 103 if not generate_and_test(input_filename, source_dir, working_dir,
102 fixup_path, pdfium_test_path, pdfium_diff_path) : 104 fixup_path, pdfium_test_path, pdfium_diff_path) :
103 os_exit_code = 1 105 failures.append(input_path)
104 106
105 return os_exit_code 107 if failures:
106 108 print '\n\nSummary of Failures:'
109 for failure in failures:
110 print failure
111 return 1
112 return 0
107 113
108 if __name__ == '__main__': 114 if __name__ == '__main__':
109 sys.exit(main()) 115 sys.exit(main())
OLDNEW
« no previous file with comments | « testing/tools/run_javascript_tests.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698