Index: testing/tools/run_javascript_tests.py |
diff --git a/testing/tools/run_javascript_tests.py b/testing/tools/run_javascript_tests.py |
new file mode 100755 |
index 0000000000000000000000000000000000000000..9739980b33ec1f9b1b299ab08592ea4b1a75a85e |
--- /dev/null |
+++ b/testing/tools/run_javascript_tests.py |
@@ -0,0 +1,46 @@ |
+#!/usr/bin/env python |
+# 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.
|
+# Use of this source code is governed by a BSD-style license that can be |
+# found in the LICENSE file. |
+ |
+import optparse |
+import os |
+import re |
+import subprocess |
+import sys |
+ |
+def generate_and_test(bin_filename, input_file_and_ext, source_dir, build_dir): |
+ try: |
+ source_filename = os.path.join(source_dir, input_file_and_ext) |
+ (input_filename, input_extension) = os.path.splitext(input_file_and_ext) |
+ 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.
|
+ working_dir = os.path.join(build_dir, 'gen', 'pdfium', source_dir) |
+ pdf_filename = os.path.join(working_dir, input_filename + '.pdf') |
+ txt_filename = os.path.join(working_dir, input_filename + '.txt') |
+ 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
|
+ '--build-dir=' + build_dir, source_filename]) |
+ with open(txt_filename, 'w') as outfile: |
+ subprocess.check_call([bin_filename, pdf_filename], stdout=outfile) |
+ 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.
|
+ except subprocess.CalledProcessError as e: |
+ print "FAILURE: " + input_file_and_ext + "; " + str(e) |
+ |
+def main(): |
+ parser = optparse.OptionParser() |
+ parser.add_option('--build-dir', |
+ default=os.path.join('out' , 'Debug')) |
+ 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'
|
+ default=os.path.join('testing', 'resources', 'javascript')) |
+ (options, args) = parser.parse_args() |
+ 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.
|
+ 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.
|
+ bin_filename = bin_filename + '.exe' |
+ input_file_re = re.compile('^[a-zA-Z0-9_.]+[.]in$') |
+ 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.
|
+ if not input_file_re.match(arg): |
+ continue |
+ generate_and_test(bin_filename, arg, options.source_dir, options.build_dir) |
+ return 0 |
+ |
+if __name__ == '__main__': |
+ sys.exit(main()) |