summaryrefslogtreecommitdiff
path: root/testing/tools/fixup_pdf_template.py
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-02-12 10:19:52 -0800
committerTom Sepez <tsepez@chromium.org>2015-02-12 10:19:52 -0800
commit9f93baf8766c2505f9ad28ebfedb4f28ece7aa02 (patch)
tree7d7b8c618a2132c23a6759f98bfd80cee01d1d70 /testing/tools/fixup_pdf_template.py
parent6e7ceb8225de25b66d27d620c9521e19de023504 (diff)
downloadpdfium-9f93baf8766c2505f9ad28ebfedb4f28ece7aa02.tar.xz
Create run_javascript_tests.py
Top level script driver for testing/resources/javascript. Converts each input template file in that directory to a .pdf file in the working directory (typically out/Debug/gen/pdfium/testing/resources/javascript), invokes pdfium_test on it to generate , and crudely diffs the expected output. We can now remove generated .pdfs from source control, keeping only the hand-editable .in templates. R=thestig@chromium.org Review URL: https://codereview.chromium.org/912803004
Diffstat (limited to 'testing/tools/fixup_pdf_template.py')
-rwxr-xr-xtesting/tools/fixup_pdf_template.py26
1 files changed, 18 insertions, 8 deletions
diff --git a/testing/tools/fixup_pdf_template.py b/testing/tools/fixup_pdf_template.py
index 87996a42cd..a43db55ee9 100755
--- a/testing/tools/fixup_pdf_template.py
+++ b/testing/tools/fixup_pdf_template.py
@@ -70,22 +70,32 @@ class TemplateProcessor:
self.offset += len(line)
return line
-def expand_file(input_filename):
- (input_root, extension) = os.path.splitext(input_filename)
- output_filename = input_root + '.pdf'
+
+def expand_file(input_path, output_path):
processor = TemplateProcessor()
try:
- with open(input_filename, 'r') as infile:
- with open(output_filename, 'w') as outfile:
+ with open(input_path, 'r') as infile:
+ with open(output_path, 'w') as outfile:
for line in infile:
outfile.write(processor.process_line(line))
except IOError:
- print >> sys.stderr, 'failed to process %s' % input_filename
+ print >> sys.stderr, 'failed to process %s' % input_path
+
def main():
- for arg in sys.argv[1:]:
- expand_file(arg)
+ parser = optparse.OptionParser()
+ parser.add_option('--output-dir', default='')
+ options, args = parser.parse_args()
+ for testcase_path in args:
+ testcase_filename = os.path.basename(testcase_path)
+ testcase_root, _ = os.path.splitext(testcase_filename)
+ output_dir = os.path.dirname(testcase_path)
+ if options.output_dir:
+ output_dir = options.output_dir
+ output_path = os.path.join(output_dir, testcase_root + '.pdf')
+ expand_file(testcase_path, output_path)
return 0
+
if __name__ == '__main__':
sys.exit(main())