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