| 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 os | 6 import os | 
| 7 import sys | 7 import sys | 
| 8 | 8 | 
| 9 import common | 9 import common | 
| 10 | 10 | 
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 42                      redirect_output=False): | 42                      redirect_output=False): | 
| 43     template_paths = self._GetTemplatePaths( | 43     template_paths = self._GetTemplatePaths( | 
| 44         input_filename, source_dir, working_dir) | 44         input_filename, source_dir, working_dir) | 
| 45     actual_path_template = template_paths[0]; | 45     actual_path_template = template_paths[0]; | 
| 46     expected_path_template = template_paths[1] | 46     expected_path_template = template_paths[1] | 
| 47     platform_expected_path_template = template_paths[2] | 47     platform_expected_path_template = template_paths[2] | 
| 48     i = 0 | 48     i = 0 | 
| 49     while True: | 49     while True: | 
| 50       actual_path = actual_path_template % i | 50       actual_path = actual_path_template % i | 
| 51       expected_path = expected_path_template % i | 51       expected_path = expected_path_template % i | 
|  | 52       # PDFium tests should be platform independent. Platform based results are | 
|  | 53       # used to capture platform dependent implementations. | 
| 52       platform_expected_path = ( | 54       platform_expected_path = ( | 
| 53           platform_expected_path_template % (self.os_name, i)) | 55           platform_expected_path_template % (self.os_name, i)) | 
| 54       if os.path.exists(platform_expected_path): | 56       if (not os.path.exists(expected_path) and | 
| 55         expected_path = platform_expected_path | 57           not os.path.exists(platform_expected_path)): | 
| 56       elif not os.path.exists(expected_path): |  | 
| 57         if i == 0: | 58         if i == 0: | 
| 58           print "WARNING: no expected results files for " + input_filename | 59           print "WARNING: no expected results files for " + input_filename | 
| 59         break | 60         break | 
| 60       print "Checking " + actual_path | 61       print "Checking " + actual_path | 
| 61       sys.stdout.flush() | 62       sys.stdout.flush() | 
| 62       error = common.RunCommand( | 63       if os.path.exists(expected_path): | 
| 63           [self.pdfium_diff_path, expected_path, actual_path], redirect_output) | 64         error = common.RunCommand( | 
|  | 65             [self.pdfium_diff_path, expected_path, actual_path], | 
|  | 66             redirect_output) | 
|  | 67       else: | 
|  | 68         error = 1; | 
| 64       if error: | 69       if error: | 
| 65         print "FAILURE: " + input_filename + "; " + str(error) | 70         # When failed, we check against platform based results. | 
| 66         return True | 71         if os.path.exists(platform_expected_path): | 
|  | 72           error = common.RunCommand( | 
|  | 73               [self.pdfium_diff_path, platform_expected_path, actual_path], | 
|  | 74               redirect_output) | 
|  | 75         if error: | 
|  | 76           print "FAILURE: " + input_filename + "; " + str(error) | 
|  | 77           return True | 
| 67       i += 1 | 78       i += 1 | 
| 68     return False | 79     return False | 
| 69 | 80 | 
| 70   def _GetTemplatePaths(self, input_filename, source_dir, working_dir): | 81   def _GetTemplatePaths(self, input_filename, source_dir, working_dir): | 
| 71     input_root, _ = os.path.splitext(input_filename) | 82     input_root, _ = os.path.splitext(input_filename) | 
| 72     actual_path = os.path.join(working_dir, input_root + self.ACTUAL_TEMPLATE) | 83     actual_path = os.path.join(working_dir, input_root + self.ACTUAL_TEMPLATE) | 
| 73     expected_path = os.path.join( | 84     expected_path = os.path.join( | 
| 74         source_dir, input_root + self.EXPECTED_TEMPLATE) | 85         source_dir, input_root + self.EXPECTED_TEMPLATE) | 
| 75     platform_expected_path = os.path.join( | 86     platform_expected_path = os.path.join( | 
| 76         source_dir, input_root + self.PLATFORM_EXPECTED_TEMPLATE) | 87         source_dir, input_root + self.PLATFORM_EXPECTED_TEMPLATE) | 
| 77     return (actual_path, expected_path, platform_expected_path) | 88     return (actual_path, expected_path, platform_expected_path) | 
| OLD | NEW | 
|---|