| OLD | NEW |
| 1 # Copyright (c) 2010 Google Inc. All rights reserved. | 1 # Copyright (c) 2010 Google Inc. All rights reserved. |
| 2 # | 2 # |
| 3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
| 4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
| 5 # met: | 5 # met: |
| 6 # | 6 # |
| 7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
| 8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
| 9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
| 10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 | 56 |
| 57 | 57 |
| 58 def _rebaseline_test(test_file, baseline_target, baseline_move_to, test_config,
log): | 58 def _rebaseline_test(test_file, baseline_target, baseline_move_to, test_config,
log): |
| 59 test_name, _ = os.path.splitext(test_file) | 59 test_name, _ = os.path.splitext(test_file) |
| 60 test_directory = os.path.dirname(test_name) | 60 test_directory = os.path.dirname(test_name) |
| 61 | 61 |
| 62 log('Rebaselining %s...' % test_name) | 62 log('Rebaselining %s...' % test_name) |
| 63 | 63 |
| 64 actual_result_files = _get_actual_result_files(test_file, test_config) | 64 actual_result_files = _get_actual_result_files(test_file, test_config) |
| 65 filesystem = test_config.filesystem | 65 filesystem = test_config.filesystem |
| 66 scm = test_config.scm | 66 git = test_config.git |
| 67 layout_tests_directory = test_config.layout_tests_directory | 67 layout_tests_directory = test_config.layout_tests_directory |
| 68 target_expectations_directory = filesystem.join( | 68 target_expectations_directory = filesystem.join( |
| 69 layout_tests_directory, 'platform', baseline_target, test_directory) | 69 layout_tests_directory, 'platform', baseline_target, test_directory) |
| 70 test_results_directory = test_config.filesystem.join( | 70 test_results_directory = test_config.filesystem.join( |
| 71 test_config.results_directory, test_directory) | 71 test_config.results_directory, test_directory) |
| 72 | 72 |
| 73 # If requested, move current baselines out | 73 # If requested, move current baselines out |
| 74 current_baselines = get_test_baselines(test_file, test_config) | 74 current_baselines = get_test_baselines(test_file, test_config) |
| 75 if baseline_target in current_baselines and baseline_move_to != 'none': | 75 if baseline_target in current_baselines and baseline_move_to != 'none': |
| 76 log(' Moving current %s baselines to %s' % | 76 log(' Moving current %s baselines to %s' % |
| (...skipping 28 matching lines...) Expand all Loading... |
| 105 log(' No current baselines to move') | 105 log(' No current baselines to move') |
| 106 | 106 |
| 107 log(' Updating baselines for %s' % baseline_target) | 107 log(' Updating baselines for %s' % baseline_target) |
| 108 filesystem.maybe_make_directory(target_expectations_directory) | 108 filesystem.maybe_make_directory(target_expectations_directory) |
| 109 for source_file in actual_result_files: | 109 for source_file in actual_result_files: |
| 110 source_path = filesystem.join(test_results_directory, source_file) | 110 source_path = filesystem.join(test_results_directory, source_file) |
| 111 destination_file = source_file.replace('-actual', '-expected') | 111 destination_file = source_file.replace('-actual', '-expected') |
| 112 destination_path = filesystem.join( | 112 destination_path = filesystem.join( |
| 113 target_expectations_directory, destination_file) | 113 target_expectations_directory, destination_file) |
| 114 filesystem.copyfile(source_path, destination_path) | 114 filesystem.copyfile(source_path, destination_path) |
| 115 exit_code = scm.add(destination_path, return_exit_code=True) | 115 exit_code = git.add(destination_path, return_exit_code=True) |
| 116 if exit_code: | 116 if exit_code: |
| 117 log(' Could not update %s in SCM, exit code %d' % | 117 log(' Could not update %s in SCM, exit code %d' % |
| 118 (destination_file, exit_code)) | 118 (destination_file, exit_code)) |
| 119 return False | 119 return False |
| 120 else: | 120 else: |
| 121 log(' Updated %s' % destination_file) | 121 log(' Updated %s' % destination_file) |
| 122 | 122 |
| 123 return True | 123 return True |
| 124 | 124 |
| 125 | 125 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 141 'platform', | 141 'platform', |
| 142 destination_platform, | 142 destination_platform, |
| 143 test_directory) | 143 test_directory) |
| 144 filesystem.maybe_make_directory(destination_directory) | 144 filesystem.maybe_make_directory(destination_directory) |
| 145 | 145 |
| 146 for extension in extensions_to_move: | 146 for extension in extensions_to_move: |
| 147 file_name = test_file_name + '-expected' + extension | 147 file_name = test_file_name + '-expected' + extension |
| 148 source_path = filesystem.join(source_directory, file_name) | 148 source_path = filesystem.join(source_directory, file_name) |
| 149 destination_path = filesystem.join(destination_directory, file_name) | 149 destination_path = filesystem.join(destination_directory, file_name) |
| 150 filesystem.copyfile(source_path, destination_path) | 150 filesystem.copyfile(source_path, destination_path) |
| 151 exit_code = test_config.scm.add(destination_path, return_exit_code=True) | 151 exit_code = test_config.git.add(destination_path, return_exit_code=True) |
| 152 if exit_code: | 152 if exit_code: |
| 153 log(' Could not update %s in SCM, exit code %d' % | 153 log(' Could not update %s in SCM, exit code %d' % |
| 154 (file_name, exit_code)) | 154 (file_name, exit_code)) |
| 155 return False | 155 return False |
| 156 else: | 156 else: |
| 157 log(' Moved %s' % file_name) | 157 log(' Moved %s' % file_name) |
| 158 | 158 |
| 159 return True | 159 return True |
| 160 | 160 |
| 161 | 161 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 elif mode == 'diff-text': | 276 elif mode == 'diff-text': |
| 277 file_name = test_name + '-diff.txt' | 277 file_name = test_name + '-diff.txt' |
| 278 elif mode == 'diff-text-pretty': | 278 elif mode == 'diff-text-pretty': |
| 279 file_name = test_name + '-pretty-diff.html' | 279 file_name = test_name + '-pretty-diff.html' |
| 280 | 280 |
| 281 file_path = os.path.join(self.server.test_config.results_directory, file
_name) | 281 file_path = os.path.join(self.server.test_config.results_directory, file
_name) |
| 282 | 282 |
| 283 # Let results be cached for 60 seconds, so that they can be pre-fetched | 283 # Let results be cached for 60 seconds, so that they can be pre-fetched |
| 284 # by the UI | 284 # by the UI |
| 285 self._serve_file(file_path, cacheable_seconds=60) | 285 self._serve_file(file_path, cacheable_seconds=60) |
| OLD | NEW |