| 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 contextlib | 6 import contextlib |
| 7 import copy | 7 import copy |
| 8 import difflib | 8 import difflib |
| 9 import glob | 9 import glob |
| 10 import itertools | 10 import itertools |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 size_info2.symbols -= [a1, a2, a3] | 229 size_info2.symbols -= [a1, a2, a3] |
| 230 d = diff.Diff(size_info1, size_info2) | 230 d = diff.Diff(size_info1, size_info2) |
| 231 self.assertEquals(d.symbols.size, -a1.size) | 231 self.assertEquals(d.symbols.size, -a1.size) |
| 232 self.assertEquals(d.symbols.removed_count, 3) | 232 self.assertEquals(d.symbols.removed_count, 3) |
| 233 | 233 |
| 234 # Adding all 3 aliases should change size. | 234 # Adding all 3 aliases should change size. |
| 235 d = diff.Diff(size_info2, size_info1) | 235 d = diff.Diff(size_info2, size_info1) |
| 236 self.assertEquals(d.symbols.size, a1.size) | 236 self.assertEquals(d.symbols.size, a1.size) |
| 237 self.assertEquals(d.symbols.added_count, 3) | 237 self.assertEquals(d.symbols.added_count, 3) |
| 238 | 238 |
| 239 def test_Diff_Clustering(self): |
| 240 size_info1 = self._CloneSizeInfo() |
| 241 size_info2 = self._CloneSizeInfo() |
| 242 S = '.text' |
| 243 size_info1.symbols += [ |
| 244 models.Symbol(S, 11, name='.L__unnamed_1193', object_path='a'), # 1 |
| 245 models.Symbol(S, 22, name='.L__unnamed_1194', object_path='a'), # 2 |
| 246 models.Symbol(S, 33, name='.L__unnamed_1195', object_path='b'), # 3 |
| 247 models.Symbol(S, 44, name='.L__bar_195', object_path='b'), # 4 |
| 248 models.Symbol(S, 55, name='.L__bar_1195', object_path='b'), # 5 |
| 249 ] |
| 250 size_info2.symbols += [ |
| 251 models.Symbol(S, 33, name='.L__unnamed_2195', object_path='b'), # 3 |
| 252 models.Symbol(S, 11, name='.L__unnamed_2194', object_path='a'), # 1 |
| 253 models.Symbol(S, 22, name='.L__unnamed_2193', object_path='a'), # 2 |
| 254 models.Symbol(S, 44, name='.L__bar_2195', object_path='b'), # 4 |
| 255 models.Symbol(S, 55, name='.L__bar_295', object_path='b'), # 5 |
| 256 ] |
| 257 d = diff.Diff(size_info1, size_info2) |
| 258 self.assertEquals(d.symbols.added_count, 0) |
| 259 self.assertEquals(d.symbols.size, 0) |
| 260 |
| 261 |
| 239 @_CompareWithGolden() | 262 @_CompareWithGolden() |
| 240 def test_FullDescription(self): | 263 def test_FullDescription(self): |
| 241 return describe.GenerateLines(self._CloneSizeInfo().Cluster(), | 264 return describe.GenerateLines(self._CloneSizeInfo().Cluster(), |
| 242 recursive=True, verbose=True) | 265 recursive=True, verbose=True) |
| 243 | 266 |
| 244 @_CompareWithGolden() | 267 @_CompareWithGolden() |
| 245 def test_SymbolGroupMethods(self): | 268 def test_SymbolGroupMethods(self): |
| 246 all_syms = self._CloneSizeInfo().symbols | 269 all_syms = self._CloneSizeInfo().symbols |
| 247 global_syms = all_syms.WhereNameMatches('GLOBAL') | 270 global_syms = all_syms.WhereNameMatches('GLOBAL') |
| 248 # Tests Filter(), Inverted(), and __sub__(). | 271 # Tests Filter(), Inverted(), and __sub__(). |
| (...skipping 23 matching lines...) Expand all Loading... |
| 272 global update_goldens | 295 global update_goldens |
| 273 update_goldens = True | 296 update_goldens = True |
| 274 for f in glob.glob(os.path.join(_TEST_DATA_DIR, '*.golden')): | 297 for f in glob.glob(os.path.join(_TEST_DATA_DIR, '*.golden')): |
| 275 os.unlink(f) | 298 os.unlink(f) |
| 276 | 299 |
| 277 unittest.main(argv=argv, verbosity=2) | 300 unittest.main(argv=argv, verbosity=2) |
| 278 | 301 |
| 279 | 302 |
| 280 if __name__ == '__main__': | 303 if __name__ == '__main__': |
| 281 main() | 304 main() |
| OLD | NEW |