summaryrefslogtreecommitdiff
path: root/testing/tools/fixup_pdf_template.py
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-02-13 16:54:48 -0800
committerTom Sepez <tsepez@chromium.org>2015-02-13 16:54:48 -0800
commitb7cb36aba7d32c506ee921cb7558b8effd4b2fa1 (patch)
treeaec88bf31f8c449cf289f1d2aa11ce326a79e9bc /testing/tools/fixup_pdf_template.py
parent92e856b09dd2fcf6cf46b07b1496053eb0e67851 (diff)
downloadpdfium-b7cb36aba7d32c506ee921cb7558b8effd4b2fa1.tar.xz
Merge to XFA: Run javascript/pixel tests via automated script.
This pulls in: 7435e8e Run pixel tests via automated script. 83c87e5 run_javascript_tests.py: Be more flexible about directory layout. 5898509 Test top-level Document JS properties. 9f93baf Create run_javascript_tests.py TBR=thestig@chromium.org Review URL: https://codereview.chromium.org/923293002
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())