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

Side by Side Diff: net/data/verify_certificate_chain_unittest/rebase-errors.py

Issue 2337373003: Add error details to ParseCertificate test data. (Closed)
Patch Set: rename Created 4 years, 3 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
OLDNEW
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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 81
82 82
83 def fixup_pem_file(path, actual_errors): 83 def fixup_pem_file(path, actual_errors):
84 """Updates the ERRORS block in the test .pem file""" 84 """Updates the ERRORS block in the test .pem file"""
85 contents = read_file_to_string(path) 85 contents = read_file_to_string(path)
86 86
87 prog = re.compile(kErrorsBlockPattern, re.MULTILINE | re.DOTALL) 87 prog = re.compile(kErrorsBlockPattern, re.MULTILINE | re.DOTALL)
88 m = prog.search(contents) 88 m = prog.search(contents)
89 89
90 if not m: 90 if not m:
91 print "Couldn't find ERRORS block in %s" % (path) 91 contents += '\n' + common.text_data_to_pem('ERRORS', actual_errors)
92 return 92 else:
93 93 contents = replace_string(contents, m.start(1), m.end(1),
94 contents = replace_string(contents, m.start(1), m.end(1), 94 common.text_data_to_pem('ERRORS', actual_errors))
95 common.text_data_to_pem('ERRORS', actual_errors))
96 95
97 # Update the file. 96 # Update the file.
98 write_string_to_file(contents, path) 97 write_string_to_file(contents, path)
99 98
100 99
101 def fixup_py_file(path, actual_errors): 100 def fixup_py_file(path, actual_errors):
102 """Replaces the 'errors = XXX' section of the test's python script""" 101 """Replaces the 'errors = XXX' section of the test's python script"""
103 contents = read_file_to_string(path) 102 contents = read_file_to_string(path)
104 103
105 # This assumes that the errors variable uses triple quotes. 104 # This assumes that the errors variable uses triple quotes.
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 156
158 for m in prog.finditer(test_stdout): 157 for m in prog.finditer(test_stdout):
159 actual_errors = m.group(1) 158 actual_errors = m.group(1)
160 actual_errors = actual_errors.decode('string-escape') 159 actual_errors = actual_errors.decode('string-escape')
161 relative_test_path = m.group(2) 160 relative_test_path = m.group(2)
162 fixup_errors_for_file(actual_errors, get_abs_path(relative_test_path)) 161 fixup_errors_for_file(actual_errors, get_abs_path(relative_test_path))
163 162
164 163
165 if __name__ == "__main__": 164 if __name__ == "__main__":
166 main() 165 main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698