| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # | 2 # |
| 3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 """ Output file objects for generator. """ | 7 """ Output file objects for generator. """ |
| 8 | 8 |
| 9 import difflib | 9 import difflib |
| 10 import os | 10 import os |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 inline = inlines[index] | 29 inline = inlines[index] |
| 30 outline = outlines[index] | 30 outline = outlines[index] |
| 31 | 31 |
| 32 if inline == outline: continue | 32 if inline == outline: continue |
| 33 | 33 |
| 34 # If the line is not an exact match, check for comment deltas | 34 # If the line is not an exact match, check for comment deltas |
| 35 inwords = inline.split() | 35 inwords = inline.split() |
| 36 outwords = outline.split() | 36 outwords = outline.split() |
| 37 | 37 |
| 38 if not inwords or not outwords: return False | 38 if not inwords or not outwords: return False |
| 39 if inwords[0] != outwords[0] or inwords[0] != '/*': return False | 39 if inwords[0] != outwords[0] or inwords[0] not in ('/*', '*'): return False |
| 40 | 40 |
| 41 # Neither the year, nor the modified date need an exact match | 41 # Neither the year, nor the modified date need an exact match |
| 42 if inwords[1] == 'Copyright': | 42 if inwords[1] == 'Copyright': |
| 43 if inwords[4:] == outwords[4:]: continue | 43 if inwords[4:] == outwords[4:]: continue |
| 44 elif inwords[1] == 'From': | 44 elif inwords[1] == 'From': # Un-wrapped modified date. |
| 45 if inwords[0:4] == outwords[0:4]: | 45 if inwords[0:4] == outwords[0:4]: continue |
| 46 continue | 46 elif inwords[1] == 'modified': # Wrapped modified date. |
| 47 if inwords[0:2] == outwords[0:2]: continue |
| 47 return False | 48 return False |
| 48 return True | 49 return True |
| 49 | 50 |
| 50 | 51 |
| 51 # | 52 # |
| 52 # IDLOutFile | 53 # IDLOutFile |
| 53 # | 54 # |
| 54 # IDLOutFile provides a temporary output file. By default, the object will | 55 # IDLOutFile provides a temporary output file. By default, the object will |
| 55 # not write the output if the file already exists, and matches what will be | 56 # not write the output if the file already exists, and matches what will be |
| 56 # written. This prevents the timestamp from changing to optimize cases where | 57 # written. This prevents the timestamp from changing to optimize cases where |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 # Test conditionally writing the file skipping | 167 # Test conditionally writing the file skipping |
| 167 errors += TestFile(filename, stringlist, force=False, update=False) | 168 errors += TestFile(filename, stringlist, force=False, update=False) |
| 168 | 169 |
| 169 # Test conditionally writing the file updating | 170 # Test conditionally writing the file updating |
| 170 errors += TestFile(filename, stringlist + ['X'], force=False, update=True) | 171 errors += TestFile(filename, stringlist + ['X'], force=False, update=True) |
| 171 | 172 |
| 172 # Clean up file | 173 # Clean up file |
| 173 os.remove(filename) | 174 os.remove(filename) |
| 174 if not errors: InfoOut.Log('All tests pass.') | 175 if not errors: InfoOut.Log('All tests pass.') |
| 175 sys.exit(errors) | 176 sys.exit(errors) |
| 176 | |
| OLD | NEW |