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

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

Issue 912803004: Create run_javascript_tests.py (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: 80 cols Created 5 years, 10 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
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright 2014 The PDFium Authors. All rights reserved.
Lei Zhang 2015/02/10 23:09:29 2015
Tom Sepez 2015/02/10 23:33:31 Done.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 import optparse
7 import os
8 import re
9 import subprocess
10 import sys
11
12 def generate_and_test(bin_filename, input_file_and_ext, source_dir, build_dir):
13 try:
14 source_filename = os.path.join(source_dir, input_file_and_ext)
15 (input_filename, input_extension) = os.path.splitext(input_file_and_ext)
16 expected_filename = os.path.join(source_dir, input_filename + '_expected.txt ')
Lei Zhang 2015/02/10 23:09:29 over 80 chars
Tom Sepez 2015/02/10 23:33:32 Done.
17 working_dir = os.path.join(build_dir, 'gen', 'pdfium', source_dir)
18 pdf_filename = os.path.join(working_dir, input_filename + '.pdf')
19 txt_filename = os.path.join(working_dir, input_filename + '.txt')
20 subprocess.check_call(['testing/tools/fixup_pdf_template.py',
Lei Zhang 2015/02/10 23:09:29 Not sure if this works on Windows. You may want t
Tom Sepez 2015/02/10 23:33:31 A codesearch shows a bunch of these in our existin
21 '--build-dir=' + build_dir, source_filename])
22 with open(txt_filename, 'w') as outfile:
23 subprocess.check_call([bin_filename, pdf_filename], stdout=outfile)
24 subprocess.check_call(['diff', expected_filename, txt_filename])
Lei Zhang 2015/02/10 23:09:30 Not sure if this works on Windows either.
Tom Sepez 2015/02/10 23:33:31 Ditto.
25 except subprocess.CalledProcessError as e:
26 print "FAILURE: " + input_file_and_ext + "; " + str(e)
27
28 def main():
29 parser = optparse.OptionParser()
30 parser.add_option('--build-dir',
31 default=os.path.join('out' , 'Debug'))
32 parser.add_option('--source-dir',
Lei Zhang 2015/02/10 23:09:30 It might be good to make this /path/to/chrome_chec
Tom Sepez 2015/02/10 23:33:31 Actually, in a standlone build, there isn't any /s
Lei Zhang 2015/02/11 00:03:21 Oh right, this is pdfium. In any case, I think it'
33 default=os.path.join('testing', 'resources', 'javascript'))
34 (options, args) = parser.parse_args()
35 bin_filename = os.path.join(options.build_dir, 'pdfium_test')
Lei Zhang 2015/02/10 23:09:29 |bin_filename| -> |pdfium_test_path| ? I tend to
Tom Sepez 2015/02/10 23:33:31 Done.
36 if (sys.platform.startswith('win')):
Lei Zhang 2015/02/10 23:09:29 Should there be a TODO here for Mac?
Lei Zhang 2015/02/10 23:09:30 No need for the outer parenthesis here either. Sty
Tom Sepez 2015/02/10 23:33:31 Added.
Tom Sepez 2015/02/10 23:33:31 Much better.
37 bin_filename = bin_filename + '.exe'
38 input_file_re = re.compile('^[a-zA-Z0-9_.]+[.]in$')
39 for arg in os.listdir(options.source_dir):
Lei Zhang 2015/02/10 23:09:29 Rename |arg| to |pdf_source| ?
Tom Sepez 2015/02/10 23:33:31 Done.
40 if not input_file_re.match(arg):
41 continue
42 generate_and_test(bin_filename, arg, options.source_dir, options.build_dir)
43 return 0
44
45 if __name__ == '__main__':
46 sys.exit(main())
OLDNEW
« testing/tools/fixup_pdf_template.py ('K') | « testing/tools/fixup_pdf_template.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698