| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2017 The Chromium Authors. All rights reserved. | 2 # Copyright 2017 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 import copy | 6 import copy |
| 7 import difflib | 7 import difflib |
| 8 import itertools | 8 import itertools |
| 9 import logging | 9 import logging |
| 10 import os | 10 import os |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 | 78 |
| 79 @_CompareWithGolden | 79 @_CompareWithGolden |
| 80 def test_ConsoleNullDiff(self): | 80 def test_ConsoleNullDiff(self): |
| 81 with tempfile.NamedTemporaryFile(suffix='.size') as temp_file: | 81 with tempfile.NamedTemporaryFile(suffix='.size') as temp_file: |
| 82 file_format.SaveSizeInfo(self._CloneSizeInfo(), temp_file.name) | 82 file_format.SaveSizeInfo(self._CloneSizeInfo(), temp_file.name) |
| 83 return _RunApp('console.py', '--query', 'Diff(size_info1, size_info2)', | 83 return _RunApp('console.py', '--query', 'Diff(size_info1, size_info2)', |
| 84 temp_file.name, temp_file.name) | 84 temp_file.name, temp_file.name) |
| 85 | 85 |
| 86 @_CompareWithGolden | 86 @_CompareWithGolden |
| 87 def test_ActualDiff(self): | 87 def test_ActualDiff(self): |
| 88 map1 = self._CloneSizeInfo() | 88 size_info1 = self._CloneSizeInfo() |
| 89 map2 = self._CloneSizeInfo() | 89 size_info2 = self._CloneSizeInfo() |
| 90 map1.metadata = {"foo": 1, "bar": [1,2,3], "baz": "yes"} | 90 size_info1.metadata = {"foo": 1, "bar": [1,2,3], "baz": "yes"} |
| 91 map2.metadata = {"foo": 1, "bar": [1,3], "baz": "yes"} | 91 size_info2.metadata = {"foo": 1, "bar": [1,3], "baz": "yes"} |
| 92 map1.symbols -= map1.symbols[0] | 92 size_info1.symbols -= size_info1.symbols[:2] |
| 93 map2.symbols -= map2.symbols[-1] | 93 size_info2.symbols -= size_info2.symbols[-3:] |
| 94 map1.symbols[1].size -= 10 | 94 size_info1.symbols[1].size -= 10 |
| 95 diff = models.Diff(map1, map2) | 95 diff = models.Diff(size_info1, size_info2) |
| 96 return describe.GenerateLines(diff, verbose=True) | 96 return describe.GenerateLines(diff, verbose=True) |
| 97 | 97 |
| 98 @_CompareWithGolden | 98 @_CompareWithGolden |
| 99 def test_SymbolGroupMethods(self): | 99 def test_SymbolGroupMethods(self): |
| 100 all_syms = self._CloneSizeInfo().symbols | 100 all_syms = self._CloneSizeInfo().symbols |
| 101 global_syms = all_syms.WhereNameMatches('GLOBAL') | 101 global_syms = all_syms.WhereNameMatches('GLOBAL') |
| 102 # Tests Filter(), Inverted(), and __sub__(). | 102 # Tests Filter(), Inverted(), and __sub__(). |
| 103 non_global_syms = global_syms.Inverted() | 103 non_global_syms = global_syms.Inverted() |
| 104 self.assertEqual(non_global_syms, (all_syms - global_syms)) | 104 self.assertEqual(non_global_syms, (all_syms - global_syms)) |
| 105 # Tests Sorted() and __add__(). | 105 # Tests Sorted() and __add__(). |
| (...skipping 18 matching lines...) Expand all Loading... |
| 124 if len(argv) > 1 and argv[1] == '--update': | 124 if len(argv) > 1 and argv[1] == '--update': |
| 125 argv.pop(0) | 125 argv.pop(0) |
| 126 global update_goldens | 126 global update_goldens |
| 127 update_goldens = True | 127 update_goldens = True |
| 128 | 128 |
| 129 unittest.main(argv=argv, verbosity=2) | 129 unittest.main(argv=argv, verbosity=2) |
| 130 | 130 |
| 131 | 131 |
| 132 if __name__ == '__main__': | 132 if __name__ == '__main__': |
| 133 main() | 133 main() |
| OLD | NEW |