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

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

Issue 1011243002: Merge to XFA: Return OS status code from python test driver scripts. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: 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_corpus_tests.py ('k') | testing/tools/run_pixel_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 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 12 matching lines...) Expand all
23 txt_path = os.path.join(working_dir, input_root + '.txt') 23 txt_path = os.path.join(working_dir, input_root + '.txt')
24 expected_path = os.path.join(source_dir, input_root + '_expected.txt') 24 expected_path = os.path.join(source_dir, input_root + '_expected.txt')
25 try: 25 try:
26 subprocess.check_call( 26 subprocess.check_call(
27 [fixup_path, '--output-dir=' + working_dir, input_path]) 27 [fixup_path, '--output-dir=' + working_dir, input_path])
28 with open(txt_path, 'w') as outfile: 28 with open(txt_path, 'w') as outfile:
29 subprocess.check_call([pdfium_test_path, pdf_path], stdout=outfile) 29 subprocess.check_call([pdfium_test_path, pdf_path], stdout=outfile)
30 subprocess.check_call(['diff', expected_path, txt_path]) 30 subprocess.check_call(['diff', expected_path, txt_path])
31 except subprocess.CalledProcessError as e: 31 except subprocess.CalledProcessError as e:
32 print "FAILURE: " + input_filename + "; " + str(e) 32 print "FAILURE: " + input_filename + "; " + str(e)
33 return False
34 return True
33 35
34 def main(): 36 def main():
35 parser = optparse.OptionParser() 37 parser = optparse.OptionParser()
36 parser.add_option('--build-dir', default=os.path.join('out', 'Debug'), 38 parser.add_option('--build-dir', default=os.path.join('out', 'Debug'),
37 help='relative path from the base source directory') 39 help='relative path from the base source directory')
38 options, args = parser.parse_args() 40 options, args = parser.parse_args()
39 41
40 # Expect |my_dir| to be .../pdfium/testing/tools. 42 # Expect |my_dir| to be .../pdfium/testing/tools.
41 my_dir = os.path.dirname(os.path.realpath(__file__)) 43 my_dir = os.path.dirname(os.path.realpath(__file__))
42 testing_dir = os.path.dirname(my_dir) 44 testing_dir = os.path.dirname(my_dir)
(...skipping 28 matching lines...) Expand all
71 if sys.platform.startswith('win'): 73 if sys.platform.startswith('win'):
72 pdfium_test_path = pdfium_test_path + '.exe' 74 pdfium_test_path = pdfium_test_path + '.exe'
73 # TODO(tsepez): Mac may require special handling here. 75 # TODO(tsepez): Mac may require special handling here.
74 76
75 # Place generated files under the build directory, not source directory. 77 # Place generated files under the build directory, not source directory.
76 gen_dir = os.path.join(build_dir, 'gen', 'pdfium') 78 gen_dir = os.path.join(build_dir, 'gen', 'pdfium')
77 working_dir = os.path.join(gen_dir, 'testing', 'javascript') 79 working_dir = os.path.join(gen_dir, 'testing', 'javascript')
78 if not os.path.exists(working_dir): 80 if not os.path.exists(working_dir):
79 os.makedirs(working_dir) 81 os.makedirs(working_dir)
80 82
83 os_exit_code = 0
81 input_file_re = re.compile('^[a-zA-Z0-9_.]+[.]in$') 84 input_file_re = re.compile('^[a-zA-Z0-9_.]+[.]in$')
82 for input_filename in os.listdir(source_dir): 85 for input_filename in os.listdir(source_dir):
83 if input_file_re.match(input_filename): 86 if input_file_re.match(input_filename):
84 input_path = os.path.join(source_dir, input_filename) 87 input_path = os.path.join(source_dir, input_filename)
85 if os.path.isfile(input_path): 88 if os.path.isfile(input_path):
86 generate_and_test(input_filename, source_dir, working_dir, 89 if not generate_and_test(input_filename, source_dir, working_dir,
87 fixup_path, pdfium_test_path) 90 fixup_path, pdfium_test_path):
88 return 0 91 os_exit_code = 1
92
93 return os_exit_code
89 94
90 95
91 if __name__ == '__main__': 96 if __name__ == '__main__':
92 sys.exit(main()) 97 sys.exit(main())
OLDNEW
« no previous file with comments | « testing/tools/run_corpus_tests.py ('k') | testing/tools/run_pixel_tests.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698