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

Side by Side Diff: testing/tools/run_javascript_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 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 24 matching lines...) Expand all
35 except subprocess.CalledProcessError as e: 35 except subprocess.CalledProcessError as e:
36 print "FAILURE: " + input_filename + "; " + str(e) 36 print "FAILURE: " + input_filename + "; " + str(e)
37 return False 37 return False
38 return True 38 return True
39 39
40 def main(): 40 def main():
41 parser = optparse.OptionParser() 41 parser = optparse.OptionParser()
42 parser.add_option('--build-dir', default=os.path.join('out', 'Debug'), 42 parser.add_option('--build-dir', default=os.path.join('out', 'Debug'),
43 help='relative path from the base source directory') 43 help='relative path from the base source directory')
44 options, args = parser.parse_args() 44 options, args = parser.parse_args()
45
45 finder = common.DirectoryFinder(options.build_dir) 46 finder = common.DirectoryFinder(options.build_dir)
46 fixup_path = finder.ScriptPath('fixup_pdf_template.py') 47 fixup_path = finder.ScriptPath('fixup_pdf_template.py')
47 text_diff_path = finder.ScriptPath('text_diff.py') 48 text_diff_path = finder.ScriptPath('text_diff.py')
48 source_dir = finder.TestingDir(os.path.join('resources', 'javascript')) 49 source_dir = finder.TestingDir(os.path.join('resources', 'javascript'))
49 pdfium_test_path = finder.ExecutablePath('pdfium_test') 50 pdfium_test_path = finder.ExecutablePath('pdfium_test')
50 if not os.path.exists(pdfium_test_path): 51 if not os.path.exists(pdfium_test_path):
51 print "FAILURE: Can't find test executable '%s'" % pdfium_test_path 52 print "FAILURE: Can't find test executable '%s'" % pdfium_test_path
52 print "Use --build-dir to specify its location." 53 print "Use --build-dir to specify its location."
53 return 1 54 return 1
54 working_dir = finder.WorkingDir(os.path.join('testing', 'javascript')) 55 working_dir = finder.WorkingDir(os.path.join('testing', 'javascript'))
55 if not os.path.exists(working_dir): 56 if not os.path.exists(working_dir):
56 os.makedirs(working_dir) 57 os.makedirs(working_dir)
57 58
59 input_files = []
60 for file_name in args:
61 file_name = file_name.replace(".pdf", ".in")
62 input_files.append(file_name)
Tom Sepez 2015/10/28 20:25:48 nit: assignment not needed, combine with previous
dsinclair 2015/10/28 20:56:46 Done.
63
64 if len(input_files) == 0:
Tom Sepez 2015/10/28 20:25:48 Why not do the same if len(args): ... else: as in
dsinclair 2015/10/28 20:56:46 Done.
65 input_files = os.listdir(source_dir)
66
58 failures = [] 67 failures = []
59 input_file_re = re.compile('^[a-zA-Z0-9_.]+[.]in$') 68 input_file_re = re.compile('^[a-zA-Z0-9_.]+[.]in$')
60 for input_filename in os.listdir(source_dir): 69 for input_filename in input_files:
61 if input_file_re.match(input_filename): 70 if input_file_re.match(input_filename):
62 input_path = os.path.join(source_dir, input_filename) 71 input_path = os.path.join(source_dir, input_filename)
63 if os.path.isfile(input_path): 72 if os.path.isfile(input_path):
64 if not generate_and_test(input_filename, source_dir, working_dir, 73 if not generate_and_test(input_filename, source_dir, working_dir,
65 fixup_path, pdfium_test_path, text_diff_path): 74 fixup_path, pdfium_test_path, text_diff_path):
66 failures.append(input_path) 75 failures.append(input_path)
67 76
68 if failures: 77 if failures:
69 failures.sort() 78 failures.sort()
70 print '\n\nSummary of Failures:' 79 print '\n\nSummary of Failures:'
71 for failure in failures: 80 for failure in failures:
72 print failure 81 print failure
73 return 1 82 return 1
74 return 0 83 return 0
75 84
76 85
77 if __name__ == '__main__': 86 if __name__ == '__main__':
78 sys.exit(main()) 87 sys.exit(main())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698