| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2016 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2016 The Chromium 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 """Helper script to update the test error expectations based on actual results. | 6 """Helper script to update the test error expectations based on actual results. |
| 7 | 7 |
| 8 This is useful for regenerating test expectations after making changes to the | 8 This is useful for regenerating test expectations after making changes to the |
| 9 error format. | 9 error format. |
| 10 | 10 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 import os | 26 import os |
| 27 import sys | 27 import sys |
| 28 import re | 28 import re |
| 29 | 29 |
| 30 | 30 |
| 31 # Regular expression to find the failed errors in test stdout. | 31 # Regular expression to find the failed errors in test stdout. |
| 32 # * Group 1 of the match is the actual error text (backslash-escaped) | 32 # * Group 1 of the match is the actual error text (backslash-escaped) |
| 33 # * Group 2 of the match is file path (relative to //src) where the expected | 33 # * Group 2 of the match is file path (relative to //src) where the expected |
| 34 # errors were read from. | 34 # errors were read from. |
| 35 failed_test_regex = re.compile(r""" | 35 failed_test_regex = re.compile(r""" |
| 36 Value of: errors.ToDebugString\((?:chain)?\) | 36 Value of: errors.ToDebugString\((?:test.chain)?\) |
| 37 Actual: "(.*)" | 37 Actual: "(.*)" |
| 38 (?:.|\n)+? | 38 (?:.|\n)+? |
| 39 Test file: (.*) | 39 Test file: (.*) |
| 40 """, re.MULTILINE) | 40 """, re.MULTILINE) |
| 41 | 41 |
| 42 | 42 |
| 43 # Regular expression to find the ERRORS block (and any text above it) in a PEM | 43 # Regular expression to find the ERRORS block (and any text above it) in a PEM |
| 44 # file. The assumption is that ERRORS is not the very first block in the file | 44 # file. The assumption is that ERRORS is not the very first block in the file |
| 45 # (since it looks for an -----END to precede it). | 45 # (since it looks for an -----END to precede it). |
| 46 # * Group 1 of the match is the ERRORS block content and any comments | 46 # * Group 1 of the match is the ERRORS block content and any comments |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 | 168 |
| 169 for m in failed_test_regex.finditer(test_stdout): | 169 for m in failed_test_regex.finditer(test_stdout): |
| 170 actual_errors = m.group(1) | 170 actual_errors = m.group(1) |
| 171 actual_errors = actual_errors.decode('string-escape') | 171 actual_errors = actual_errors.decode('string-escape') |
| 172 relative_test_path = m.group(2) | 172 relative_test_path = m.group(2) |
| 173 fixup_errors_for_file(actual_errors, get_abs_path(relative_test_path)) | 173 fixup_errors_for_file(actual_errors, get_abs_path(relative_test_path)) |
| 174 | 174 |
| 175 | 175 |
| 176 if __name__ == "__main__": | 176 if __name__ == "__main__": |
| 177 main() | 177 main() |
| OLD | NEW |