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

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

Issue 1886753002: Reland Combined test runner. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase to master Created 4 years, 8 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
« no previous file with comments | « testing/tools/run_corpus_tests.py ('k') | testing/tools/run_pixel_tests.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2015 The PDFium Authors. All rights reserved. 2 # Copyright 2015 The PDFium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import optparse
7 import os
8 import re
9 import subprocess
10 import sys 6 import sys
11 7
12 import common 8 import test_runner
13
14 # Nomenclature:
15 # x_root - "x"
16 # x_filename - "x.ext"
17 # x_path - "path/to/a/b/c/x.ext"
18 # c_dir - "path/to/a/b/c"
19
20 def generate_and_test(input_filename, source_dir, working_dir,
21 fixup_path, pdfium_test_path, text_diff_path,
22 drmem_wrapper):
23 input_root, _ = os.path.splitext(input_filename)
24 input_path = os.path.join(source_dir, input_root + '.in')
25 pdf_path = os.path.join(working_dir, input_root + '.pdf')
26 txt_path = os.path.join(working_dir, input_root + '.txt')
27 expected_path = os.path.join(source_dir, input_root + '_expected.txt')
28 try:
29 sys.stdout.flush()
30 subprocess.check_call(
31 [sys.executable, fixup_path, '--output-dir=' + working_dir, input_path])
32 with open(txt_path, 'w') as outfile:
33 # add Dr. Memory wrapper if exist
34 cmd_to_run = common.DrMemoryWrapper(drmem_wrapper, input_root)
35 cmd_to_run.extend([pdfium_test_path, pdf_path])
36 # run test
37 subprocess.check_call(cmd_to_run, stdout=outfile)
38 subprocess.check_call(
39 [sys.executable, text_diff_path, expected_path, txt_path])
40 except subprocess.CalledProcessError as e:
41 print "FAILURE: " + input_filename + "; " + str(e)
42 return False
43 return True
44 9
45 def main(): 10 def main():
46 parser = optparse.OptionParser() 11 runner = test_runner.TestRunner('javascript')
47 parser.add_option('--build-dir', default=os.path.join('out', 'Debug'), 12 return runner.Run()
48 help='relative path from the base source directory')
49 parser.add_option('-j', default=1,
50 dest='num_workers', type='int',
51 help='run NUM_WORKERS jobs in parallel (currently ignored)')
52 parser.add_option('--wrapper', default='', dest="wrapper",
53 help='Dr. Memory wrapper for running test under Dr. Memory')
54 options, args = parser.parse_args()
55
56 finder = common.DirectoryFinder(options.build_dir)
57 fixup_path = finder.ScriptPath('fixup_pdf_template.py')
58 text_diff_path = finder.ScriptPath('text_diff.py')
59 source_dir = finder.TestingDir(os.path.join('resources', 'javascript'))
60 pdfium_test_path = finder.ExecutablePath('pdfium_test')
61 if not os.path.exists(pdfium_test_path):
62 print "FAILURE: Can't find test executable '%s'" % pdfium_test_path
63 print "Use --build-dir to specify its location."
64 return 1
65 working_dir = finder.WorkingDir(os.path.join('testing', 'javascript'))
66 if not os.path.exists(working_dir):
67 os.makedirs(working_dir)
68
69 feature_string = subprocess.check_output([pdfium_test_path, '--show-config'])
70 if "V8" not in feature_string.strip().split(","):
71 print "V8 not enabled, skipping."
72 return 0
73
74 input_files = []
75 if len(args):
76 for file_name in args:
77 input_files.append(file_name.replace(".pdf", ".in"))
78 else:
79 input_files = os.listdir(source_dir)
80
81 failures = []
82 input_file_re = re.compile('^[a-zA-Z0-9_.]+[.]in$')
83 for input_filename in input_files:
84 if input_file_re.match(input_filename):
85 input_path = os.path.join(source_dir, input_filename)
86 if os.path.isfile(input_path):
87 if not generate_and_test(input_filename, source_dir, working_dir,
88 fixup_path, pdfium_test_path, text_diff_path,
89 options.wrapper):
90 failures.append(input_path)
91
92 if failures:
93 failures.sort()
94 print '\n\nSummary of Failures:'
95 for failure in failures:
96 print failure
97 return 1
98 return 0
99
100 13
101 if __name__ == '__main__': 14 if __name__ == '__main__':
102 sys.exit(main()) 15 sys.exit(main())
OLDNEW
« no previous file with comments | « testing/tools/run_corpus_tests.py ('k') | testing/tools/run_pixel_tests.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698