Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 shutil | 9 import shutil |
| 10 import subprocess | 10 import subprocess |
| 11 import sys | 11 import sys |
| 12 | 12 |
| 13 import common | 13 import common |
| 14 import pngdiffer | 14 import pngdiffer |
| 15 import suppressor | 15 import suppressor |
| 16 | 16 |
| 17 # Nomenclature: | 17 # Nomenclature: |
| 18 # x_root - "x" | 18 # x_root - "x" |
| 19 # x_filename - "x.ext" | 19 # x_filename - "x.ext" |
| 20 # x_path - "path/to/a/b/c/x.ext" | 20 # x_path - "path/to/a/b/c/x.ext" |
| 21 # c_dir - "path/to/a/b/c" | 21 # c_dir - "path/to/a/b/c" |
| 22 | 22 |
| 23 def test_one_file(input_filename, source_dir, working_dir, | 23 def test_one_file(input_filename, source_dir, working_dir, |
| 24 pdfium_test_path, image_differ): | 24 pdfium_test_path, image_differ): |
| 25 input_path = os.path.join(source_dir, input_filename) | 25 input_path = os.path.join(source_dir, input_filename) |
| 26 pdf_path = os.path.join(working_dir, input_filename) | 26 pdf_path = os.path.join(working_dir, input_filename) |
| 27 try: | 27 try: |
| 28 shutil.copyfile(input_path, pdf_path) | 28 shutil.copyfile(input_path, pdf_path) |
| 29 sys.stdout.flush() | 29 sys.stdout.flush() |
| 30 if not os.path.exists(pdfium_test_path): | |
|
Tom Sepez
2015/05/20 23:24:38
This should move to line 49, so we do it once and
| |
| 31 print "FAILURE: Can't find test executable '%s'" % pdfium_test_path | |
| 32 print "Use --build-dir=out\\Release" | |
|
Tom Sepez
2015/05/20 23:24:38
nit: there may be other build dirs besides just ou
| |
| 33 sys.exit(10) | |
| 30 subprocess.check_call([pdfium_test_path, '--png', pdf_path]) | 34 subprocess.check_call([pdfium_test_path, '--png', pdf_path]) |
| 31 except subprocess.CalledProcessError as e: | 35 except subprocess.CalledProcessError as e: |
| 32 print "FAILURE: " + input_filename + "; " + str(e) | 36 print "FAILURE: " + input_filename + "; " + str(e) |
| 33 return False | 37 return False |
| 34 if image_differ.HasDifferences(input_filename, source_dir, working_dir): | 38 if image_differ.HasDifferences(input_filename, source_dir, working_dir): |
| 35 return False | 39 return False |
| 36 return True | 40 return True |
| 37 | 41 |
| 38 def main(): | 42 def main(): |
| 39 parser = optparse.OptionParser() | 43 parser = optparse.OptionParser() |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 68 print '\n\nSummary of Failures:' | 72 print '\n\nSummary of Failures:' |
| 69 for failure in failures: | 73 for failure in failures: |
| 70 print failure | 74 print failure |
| 71 return 1 | 75 return 1 |
| 72 | 76 |
| 73 return 0 | 77 return 0 |
| 74 | 78 |
| 75 | 79 |
| 76 if __name__ == '__main__': | 80 if __name__ == '__main__': |
| 77 sys.exit(main()) | 81 sys.exit(main()) |
| OLD | NEW |