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

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

Issue 1036073002: Replace linux-specific code in test scripts. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Use sys.executable Created 5 years, 9 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 | « no previous file | testing/tools/run_javascript_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 6 import optparse
7 import os 7 import os
8 import re 8 import re
9 import subprocess 9 import subprocess
10 import shutil
10 import sys 11 import sys
11 12
12 # Nomenclature: 13 # Nomenclature:
13 # x_root - "x" 14 # x_root - "x"
14 # x_filename - "x.ext" 15 # x_filename - "x.ext"
15 # x_path - "path/to/a/b/c/x.ext" 16 # x_path - "path/to/a/b/c/x.ext"
16 # c_dir - "path/to/a/b/c" 17 # c_dir - "path/to/a/b/c"
17 18
18 def extract_suppressions(filename): 19 def extract_suppressions(filename):
19 with open(filename) as f: 20 with open(filename) as f:
20 suppressions = [y for y in [ 21 suppressions = [y for y in [
21 x.split('#')[0].strip() for x in f.readlines()] if y] 22 x.split('#')[0].strip() for x in f.readlines()] if y]
22 return suppressions 23 return suppressions
23 24
24 def test_one_file(input_filename, source_dir, working_dir, 25 def test_one_file(input_filename, source_dir, working_dir,
25 pdfium_test_path, pdfium_diff_path): 26 pdfium_test_path, pdfium_diff_path):
26 input_root, _ = os.path.splitext(input_filename) 27 input_root, _ = os.path.splitext(input_filename)
27 input_path = os.path.join(source_dir, input_filename) 28 input_path = os.path.join(source_dir, input_filename)
28 pdf_path = os.path.join(working_dir, input_filename) 29 pdf_path = os.path.join(working_dir, input_filename)
29 actual_path_template = os.path.join(working_dir, input_root + '.pdf.%d.png') 30 actual_path_template = os.path.join(working_dir, input_root + '.pdf.%d.png')
30 expected_path_template = os.path.join(source_dir, 31 expected_path_template = os.path.join(source_dir,
31 input_root + '_expected.pdf.%d.png') 32 input_root + '_expected.pdf.%d.png')
32 try: 33 try:
34 shutil.copyfile(input_path, pdf_path)
33 sys.stdout.flush() 35 sys.stdout.flush()
34 subprocess.check_call(['cp', input_path, pdf_path])
35 subprocess.check_call([pdfium_test_path, '--png', pdf_path]) 36 subprocess.check_call([pdfium_test_path, '--png', pdf_path])
36 i = 0; 37 i = 0;
37 while True: 38 while True:
38 expected_path = expected_path_template % i; 39 expected_path = expected_path_template % i;
39 actual_path = actual_path_template % i; 40 actual_path = actual_path_template % i;
40 if not os.path.exists(expected_path): 41 if not os.path.exists(expected_path):
41 if i == 0: 42 if i == 0:
42 print "WARNING: no expected results files found for " + input_filename 43 print "WARNING: no expected results files found for " + input_filename
43 break 44 break
44 print "Checking " + actual_path 45 print "Checking " + actual_path
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 print '\n\nSummary of Failures:' 135 print '\n\nSummary of Failures:'
135 for failure in failures: 136 for failure in failures:
136 print failure 137 print failure
137 return 1 138 return 1
138 139
139 return 0 140 return 0
140 141
141 142
142 if __name__ == '__main__': 143 if __name__ == '__main__':
143 sys.exit(main()) 144 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | testing/tools/run_javascript_tests.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698