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

Side by Side Diff: tools/mb/mb_unittest.py

Issue 1453423002: Remove code for old style of 'analyze' in MB. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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/mb/mb.py ('k') | no next file » | 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/python 1 #!/usr/bin/python
2 # Copyright 2015 The Chromium Authors. All rights reserved. 2 # Copyright 2015 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 """Tests for mb.py.""" 6 """Tests for mb.py."""
7 7
8 import json 8 import json
9 import StringIO 9 import StringIO
10 import os 10 import os
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 # exists but wasn't populated by mb; this should also result in a clobber. 197 # exists but wasn't populated by mb; this should also result in a clobber.
198 del mbw.files['/fake_src/out/Debug/mb_type'] 198 del mbw.files['/fake_src/out/Debug/mb_type']
199 self.check(['gen', '-c', 'gyp_debug', '//out/Debug'], mbw=mbw, ret=0) 199 self.check(['gen', '-c', 'gyp_debug', '//out/Debug'], mbw=mbw, ret=0)
200 self.assertEqual(mbw.rmdirs, 200 self.assertEqual(mbw.rmdirs,
201 ['/fake_src/out/Debug', '/fake_src/out/Debug']) 201 ['/fake_src/out/Debug', '/fake_src/out/Debug'])
202 self.assertEqual(mbw.files['/fake_src/out/Debug/mb_type'], 'gyp') 202 self.assertEqual(mbw.files['/fake_src/out/Debug/mb_type'], 'gyp')
203 203
204 def test_gn_analyze(self): 204 def test_gn_analyze(self):
205 files = {'/tmp/in.json': """{\ 205 files = {'/tmp/in.json': """{\
206 "files": ["foo/foo_unittest.cc"], 206 "files": ["foo/foo_unittest.cc"],
207 "targets": ["foo_unittests", "bar_unittests"]
208 }"""}
209
210 mbw = self.fake_mbw(files)
211 mbw.Call = lambda cmd, env=None, buffer_output=True: (
212 0, 'out/Default/foo_unittests\n', '')
213
214 self.check(['analyze', '-c', 'gn_debug', '//out/Default',
215 '/tmp/in.json', '/tmp/out.json'], mbw=mbw, ret=0)
216 out = json.loads(mbw.files['/tmp/out.json'])
217 self.assertEqual(out, {
218 'status': 'Found dependency',
219 'targets': ['foo_unittests'],
220 'build_targets': ['foo_unittests']
221 })
222
223 def test_gn_analyze_new_logic(self):
224 files = {'/tmp/in.json': """{\
225 "files": ["foo/foo_unittest.cc"],
226 "test_targets": ["foo_unittests", "bar_unittests"], 207 "test_targets": ["foo_unittests", "bar_unittests"],
227 "additional_compile_targets": [] 208 "additional_compile_targets": []
228 }"""} 209 }"""}
229 210
230 mbw = self.fake_mbw(files) 211 mbw = self.fake_mbw(files)
231 mbw.Call = lambda cmd, env=None, buffer_output=True: ( 212 mbw.Call = lambda cmd, env=None, buffer_output=True: (
232 0, 'out/Default/foo_unittests\n', '') 213 0, 'out/Default/foo_unittests\n', '')
233 214
234 self.check(['analyze', '-c', 'gn_debug', '//out/Default', 215 self.check(['analyze', '-c', 'gn_debug', '//out/Default',
235 '/tmp/in.json', '/tmp/out.json'], mbw=mbw, ret=0) 216 '/tmp/in.json', '/tmp/out.json'], mbw=mbw, ret=0)
236 out = json.loads(mbw.files['/tmp/out.json']) 217 out = json.loads(mbw.files['/tmp/out.json'])
237 self.assertEqual(out, { 218 self.assertEqual(out, {
238 'status': 'Found dependency', 219 'status': 'Found dependency',
239 'compile_targets': ['foo_unittests'], 220 'compile_targets': ['foo_unittests'],
240 'test_targets': ['foo_unittests'] 221 'test_targets': ['foo_unittests']
241 }) 222 })
242 223
243 def test_gn_analyze_all(self): 224 def test_gn_analyze_all(self):
244 files = {'/tmp/in.json': """{\ 225 files = {'/tmp/in.json': """{\
245 "files": ["foo/foo_unittest.cc"], 226 "files": ["foo/foo_unittest.cc"],
246 "targets": ["all", "bar_unittests"]
247 }"""}
248 mbw = self.fake_mbw(files)
249 mbw.Call = lambda cmd, env=None, buffer_output=True: (
250 0, 'out/Default/foo_unittests\n', '')
251 self.check(['analyze', '-c', 'gn_debug', '//out/Default',
252 '/tmp/in.json', '/tmp/out.json'], mbw=mbw, ret=0)
253 out = json.loads(mbw.files['/tmp/out.json'])
254 self.assertEqual(out, {
255 'status': 'Found dependency (all)',
256 })
257
258 def test_gn_analyze_all_new_logic(self):
259 files = {'/tmp/in.json': """{\
260 "files": ["foo/foo_unittest.cc"],
261 "test_targets": ["bar_unittests"], 227 "test_targets": ["bar_unittests"],
262 "additional_compile_targets": ["all"] 228 "additional_compile_targets": ["all"]
263 }"""} 229 }"""}
264 mbw = self.fake_mbw(files) 230 mbw = self.fake_mbw(files)
265 mbw.Call = lambda cmd, env=None, buffer_output=True: ( 231 mbw.Call = lambda cmd, env=None, buffer_output=True: (
266 0, 'out/Default/foo_unittests\n', '') 232 0, 'out/Default/foo_unittests\n', '')
267 self.check(['analyze', '-c', 'gn_debug', '//out/Default', 233 self.check(['analyze', '-c', 'gn_debug', '//out/Default',
268 '/tmp/in.json', '/tmp/out.json'], mbw=mbw, ret=0) 234 '/tmp/in.json', '/tmp/out.json'], mbw=mbw, ret=0)
269 out = json.loads(mbw.files['/tmp/out.json']) 235 out = json.loads(mbw.files['/tmp/out.json'])
270 self.assertEqual(out, { 236 self.assertEqual(out, {
271 'status': 'Found dependency (all)', 237 'status': 'Found dependency (all)',
272 'compile_targets': ['all', 'bar_unittests'], 238 'compile_targets': ['all', 'bar_unittests'],
273 'test_targets': ['bar_unittests'], 239 'test_targets': ['bar_unittests'],
274 }) 240 })
275 241
276 def test_gn_analyze_missing_file(self): 242 def test_gn_analyze_missing_file(self):
277 files = {'/tmp/in.json': """{\ 243 files = {'/tmp/in.json': """{\
278 "files": ["foo/foo_unittest.cc"], 244 "files": ["foo/foo_unittest.cc"],
279 "targets": ["bar_unittests"]
280 }"""}
281 mbw = self.fake_mbw(files)
282 mbw.cmds = [
283 (0, '', ''),
284 (1, 'The input matches no targets, configs, or files\n', ''),
285 (1, 'The input matches no targets, configs, or files\n', ''),
286 ]
287
288 self.check(['analyze', '-c', 'gn_debug', '//out/Default',
289 '/tmp/in.json', '/tmp/out.json'], mbw=mbw, ret=0)
290 out = json.loads(mbw.files['/tmp/out.json'])
291 self.assertEqual(out, {
292 'build_targets': [],
293 'targets': [],
294 'status': 'No dependency',
295 })
296
297 def test_gn_analyze_missing_file_new_logic(self):
298 files = {'/tmp/in.json': """{\
299 "files": ["foo/foo_unittest.cc"],
300 "test_targets": ["bar_unittests"], 245 "test_targets": ["bar_unittests"],
301 "additional_compile_targets": [] 246 "additional_compile_targets": []
302 }"""} 247 }"""}
303 mbw = self.fake_mbw(files) 248 mbw = self.fake_mbw(files)
304 mbw.cmds = [ 249 mbw.cmds = [
305 (0, '', ''), 250 (0, '', ''),
306 (1, 'The input matches no targets, configs, or files\n', ''), 251 (1, 'The input matches no targets, configs, or files\n', ''),
307 (1, 'The input matches no targets, configs, or files\n', ''), 252 (1, 'The input matches no targets, configs, or files\n', ''),
308 ] 253 ]
309 254
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 finally: 398 finally:
454 sys.stdout = orig_stdout 399 sys.stdout = orig_stdout
455 400
456 401
457 def test_validate(self): 402 def test_validate(self):
458 self.check(['validate'], ret=0) 403 self.check(['validate'], ret=0)
459 404
460 405
461 if __name__ == '__main__': 406 if __name__ == '__main__':
462 unittest.main() 407 unittest.main()
OLDNEW
« no previous file with comments | « tools/mb/mb.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698