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 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 |
(...skipping 21 matching lines...) Expand all Loading... |
32 actual_path = actual_path_template % i; | 32 actual_path = actual_path_template % i; |
33 if not os.path.exists(expected_path): | 33 if not os.path.exists(expected_path): |
34 if i == 0: | 34 if i == 0: |
35 print "WARNING: no expected results files found for " + input_filename | 35 print "WARNING: no expected results files found for " + input_filename |
36 break | 36 break |
37 print "Checking " + actual_path | 37 print "Checking " + actual_path |
38 subprocess.check_call([pdfium_diff_path, expected_path, actual_path]) | 38 subprocess.check_call([pdfium_diff_path, expected_path, actual_path]) |
39 i += 1 | 39 i += 1 |
40 except subprocess.CalledProcessError as e: | 40 except subprocess.CalledProcessError as e: |
41 print "FAILURE: " + input_filename + "; " + str(e) | 41 print "FAILURE: " + input_filename + "; " + str(e) |
| 42 return False |
| 43 return True |
42 | 44 |
43 def main(): | 45 def main(): |
44 parser = optparse.OptionParser() | 46 parser = optparse.OptionParser() |
45 parser.add_option('--build-dir', default=os.path.join('out', 'Debug'), | 47 parser.add_option('--build-dir', default=os.path.join('out', 'Debug'), |
46 help='relative path from the base source directory') | 48 help='relative path from the base source directory') |
47 options, args = parser.parse_args() | 49 options, args = parser.parse_args() |
48 | 50 |
49 # Expect |my_dir| to be .../pdfium/testing/tools. | 51 # Expect |my_dir| to be .../pdfium/testing/tools. |
50 my_dir = os.path.dirname(os.path.realpath(__file__)) | 52 my_dir = os.path.dirname(os.path.realpath(__file__)) |
51 testing_dir = os.path.dirname(my_dir) | 53 testing_dir = os.path.dirname(my_dir) |
(...skipping 24 matching lines...) Expand all Loading... |
76 pdfium_test_path = pdfium_test_path + '.exe' | 78 pdfium_test_path = pdfium_test_path + '.exe' |
77 pdfium_diff_path = pdfium_diff_path + '.exe' | 79 pdfium_diff_path = pdfium_diff_path + '.exe' |
78 # TODO(tsepez): Mac may require special handling here. | 80 # TODO(tsepez): Mac may require special handling here. |
79 | 81 |
80 # Place generated files under the build directory, not source directory. | 82 # Place generated files under the build directory, not source directory. |
81 working_dir = os.path.join(build_dir, 'gen', 'pdfium', 'testing', 'corpus') | 83 working_dir = os.path.join(build_dir, 'gen', 'pdfium', 'testing', 'corpus') |
82 if not os.path.exists(working_dir): | 84 if not os.path.exists(working_dir): |
83 os.makedirs(working_dir) | 85 os.makedirs(working_dir) |
84 | 86 |
85 # test files are under .../pdfium/testing/corpus. | 87 # test files are under .../pdfium/testing/corpus. |
| 88 os_exit_code = 0 |
86 walk_from_dir = os.path.join(testing_dir, 'corpus'); | 89 walk_from_dir = os.path.join(testing_dir, 'corpus'); |
87 input_file_re = re.compile('^[a-zA-Z0-9_.]+[.]pdf$') | 90 input_file_re = re.compile('^[a-zA-Z0-9_.]+[.]pdf$') |
88 for source_dir, _, filename_list in os.walk(walk_from_dir): | 91 for source_dir, _, filename_list in os.walk(walk_from_dir): |
89 for input_filename in filename_list: | 92 for input_filename in filename_list: |
90 if input_file_re.match(input_filename): | 93 if input_file_re.match(input_filename): |
91 input_path = os.path.join(source_dir, input_filename) | 94 input_path = os.path.join(source_dir, input_filename) |
92 if os.path.isfile(input_path): | 95 if os.path.isfile(input_path): |
93 test_one_file(input_filename, source_dir, working_dir, | 96 if not test_one_file(input_filename, source_dir, working_dir, |
94 pdfium_test_path, pdfium_diff_path) | 97 pdfium_test_path, pdfium_diff_path): |
95 return 0 | 98 os_exit_code = 1 |
| 99 |
| 100 return os_exit_code |
96 | 101 |
97 | 102 |
98 if __name__ == '__main__': | 103 if __name__ == '__main__': |
99 sys.exit(main()) | 104 sys.exit(main()) |
OLD | NEW |