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

Side by Side Diff: tools/binary_size/libsupersize/integration_test.py

Issue 2817813003: supersize: Add "diff" command (Closed)
Patch Set: review commetns Created 3 years, 8 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
« no previous file with comments | « tools/binary_size/libsupersize/describe.py ('k') | tools/binary_size/libsupersize/main.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 glob
8 import itertools 9 import itertools
9 import logging 10 import logging
10 import os 11 import os
11 import unittest 12 import unittest
12 import subprocess 13 import subprocess
13 import sys 14 import sys
14 import tempfile 15 import tempfile
15 16
16 import archive 17 import archive
17 import describe 18 import describe
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 return itertools.chain(stats, sym_strs) 88 return itertools.chain(stats, sym_strs)
88 89
89 def test_Archive_NoSourcePaths(self): 90 def test_Archive_NoSourcePaths(self):
90 # Just tests that it doesn't crash. 91 # Just tests that it doesn't crash.
91 with tempfile.NamedTemporaryFile(suffix='.size') as temp_file: 92 with tempfile.NamedTemporaryFile(suffix='.size') as temp_file:
92 _RunApp('archive', temp_file.name, '--no-source-paths', 93 _RunApp('archive', temp_file.name, '--no-source-paths',
93 '--map-file', _TEST_MAP_PATH) 94 '--map-file', _TEST_MAP_PATH)
94 archive.LoadAndPostProcessSizeInfo(temp_file.name) 95 archive.LoadAndPostProcessSizeInfo(temp_file.name)
95 96
96 @_CompareWithGolden 97 @_CompareWithGolden
97 def test_ConsoleNullDiff(self): 98 def test_Console(self):
99 with tempfile.NamedTemporaryFile(suffix='.size') as size_file, \
100 tempfile.NamedTemporaryFile(suffix='.txt') as output_file:
101 file_format.SaveSizeInfo(self._CloneSizeInfo(), size_file.name)
102 query = [
103 'ShowExamples()',
104 'ExpandRegex("_foo_")',
105 'Print(size_info, to_file=%r)' % output_file.name,
106 ]
107 ret = _RunApp('console', size_file.name, '--query', '; '.join(query))
108 with open(output_file.name) as f:
109 ret.extend(l.rstrip() for l in f)
110 return ret
111
112 @_CompareWithGolden
113 def test_Diff_NullDiff(self):
98 with tempfile.NamedTemporaryFile(suffix='.size') as temp_file: 114 with tempfile.NamedTemporaryFile(suffix='.size') as temp_file:
99 file_format.SaveSizeInfo(self._CloneSizeInfo(), temp_file.name) 115 file_format.SaveSizeInfo(self._CloneSizeInfo(), temp_file.name)
100 return _RunApp('console', '--query', 'Diff(size_info1, size_info2)', 116 return _RunApp('diff', temp_file.name, temp_file.name)
101 temp_file.name, temp_file.name)
102 117
103 @_CompareWithGolden 118 @_CompareWithGolden
104 def test_ActualDiff(self): 119 def test_ActualDiff(self):
105 size_info1 = self._CloneSizeInfo() 120 size_info1 = self._CloneSizeInfo()
106 size_info2 = self._CloneSizeInfo() 121 size_info2 = self._CloneSizeInfo()
107 size_info1.metadata = {"foo": 1, "bar": [1,2,3], "baz": "yes"} 122 size_info1.metadata = {"foo": 1, "bar": [1,2,3], "baz": "yes"}
108 size_info2.metadata = {"foo": 1, "bar": [1,3], "baz": "yes"} 123 size_info2.metadata = {"foo": 1, "bar": [1,3], "baz": "yes"}
109 size_info1.symbols -= size_info1.symbols[:2] 124 size_info1.symbols -= size_info1.symbols[:2]
110 size_info2.symbols -= size_info2.symbols[-3:] 125 size_info2.symbols -= size_info2.symbols[-3:]
111 size_info1.symbols[1].size -= 10 126 size_info1.symbols[1].size -= 10
(...skipping 27 matching lines...) Expand all
139 describe.GenerateLines(all_syms.GroupByNamespace(depth=1, min_count=2)), 154 describe.GenerateLines(all_syms.GroupByNamespace(depth=1, min_count=2)),
140 ) 155 )
141 156
142 157
143 def main(): 158 def main():
144 argv = sys.argv 159 argv = sys.argv
145 if len(argv) > 1 and argv[1] == '--update': 160 if len(argv) > 1 and argv[1] == '--update':
146 argv.pop(0) 161 argv.pop(0)
147 global update_goldens 162 global update_goldens
148 update_goldens = True 163 update_goldens = True
164 for f in glob.glob(os.path.join(_TEST_DATA_DIR, '*.golden')):
165 os.unlink(f)
149 166
150 unittest.main(argv=argv, verbosity=2) 167 unittest.main(argv=argv, verbosity=2)
151 168
152 169
153 if __name__ == '__main__': 170 if __name__ == '__main__':
154 main() 171 main()
OLDNEW
« no previous file with comments | « tools/binary_size/libsupersize/describe.py ('k') | tools/binary_size/libsupersize/main.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698