From 9f93baf8766c2505f9ad28ebfedb4f28ece7aa02 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Thu, 12 Feb 2015 10:19:52 -0800 Subject: 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 --- testing/tools/fixup_pdf_template.py | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'testing/tools/fixup_pdf_template.py') 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()) -- cgit v1.2.3