OLD | NEW |
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 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 self.check(['analyze', '-c', 'gn_debug_goma', '//out/Default', | 292 self.check(['analyze', '-c', 'gn_debug_goma', '//out/Default', |
293 '/tmp/in.json', '/tmp/out.json'], mbw=mbw, ret=0) | 293 '/tmp/in.json', '/tmp/out.json'], mbw=mbw, ret=0) |
294 out = json.loads(mbw.files['/tmp/out.json']) | 294 out = json.loads(mbw.files['/tmp/out.json']) |
295 self.assertEqual(out, { | 295 self.assertEqual(out, { |
296 'status': 'No dependency', | 296 'status': 'No dependency', |
297 'compile_targets': [], | 297 'compile_targets': [], |
298 'test_targets': [], | 298 'test_targets': [], |
299 }) | 299 }) |
300 | 300 |
301 def test_gn_gen(self): | 301 def test_gn_gen(self): |
| 302 mbw = self.fake_mbw() |
302 self.check(['gen', '-c', 'gn_debug_goma', '//out/Default', '-g', '/goma'], | 303 self.check(['gen', '-c', 'gn_debug_goma', '//out/Default', '-g', '/goma'], |
303 ret=0, | 304 mbw=mbw, ret=0, |
304 out=('/fake_src/buildtools/linux64/gn gen //out/Default ' | 305 out=('/fake_src/buildtools/linux64/gn gen //out/Default ' |
305 '\'--args=is_debug=true use_goma=true goma_dir="/goma"\' ' | |
306 '--check\n')) | 306 '--check\n')) |
| 307 self.assertMultiLineEqual(mbw.files['/fake_src/out/Default/args.gn'], |
| 308 ('goma_dir = "/goma"\n' |
| 309 'is_debug = true\n' |
| 310 'use_goma = true\n')) |
307 | 311 |
308 mbw = self.fake_mbw(win32=True) | 312 mbw = self.fake_mbw(win32=True) |
309 self.check(['gen', '-c', 'gn_debug_goma', '-g', 'c:\\goma', '//out/Debug'], | 313 self.check(['gen', '-c', 'gn_debug_goma', '-g', 'c:\\goma', '//out/Debug'], |
310 mbw=mbw, ret=0, | 314 mbw=mbw, ret=0, |
311 out=('c:\\fake_src\\buildtools\\win\\gn.exe gen //out/Debug ' | 315 out=('c:\\fake_src\\buildtools\\win\\gn.exe gen //out/Debug ' |
312 '"--args=is_debug=true use_goma=true goma_dir=\\"' | 316 '--check\n')) |
313 'c:\\goma\\"" --check\n')) | 317 self.assertMultiLineEqual(mbw.files['c:\\fake_src\\out\\Debug\\args.gn'], |
| 318 ('goma_dir = "c:\\\\goma"\n' |
| 319 'is_debug = true\n' |
| 320 'use_goma = true\n')) |
314 | 321 |
315 | 322 |
316 def test_gn_gen_fails(self): | 323 def test_gn_gen_fails(self): |
317 mbw = self.fake_mbw() | 324 mbw = self.fake_mbw() |
318 mbw.Call = lambda cmd, env=None, buffer_output=True: (1, '', '') | 325 mbw.Call = lambda cmd, env=None, buffer_output=True: (1, '', '') |
319 self.check(['gen', '-c', 'gn_debug_goma', '//out/Default'], mbw=mbw, ret=1) | 326 self.check(['gen', '-c', 'gn_debug_goma', '//out/Default'], mbw=mbw, ret=1) |
320 | 327 |
321 def test_gn_gen_swarming(self): | 328 def test_gn_gen_swarming(self): |
322 files = { | 329 files = { |
323 '/tmp/swarming_targets': 'base_unittests\n', | 330 '/tmp/swarming_targets': 'base_unittests\n', |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 ), | 388 ), |
382 } | 389 } |
383 self.check(['run', '-c', 'gn_debug_goma', '//out/Default', | 390 self.check(['run', '-c', 'gn_debug_goma', '//out/Default', |
384 'base_unittests'], files=files, ret=0) | 391 'base_unittests'], files=files, ret=0) |
385 | 392 |
386 def test_gn_lookup(self): | 393 def test_gn_lookup(self): |
387 self.check(['lookup', '-c', 'gn_debug_goma'], ret=0) | 394 self.check(['lookup', '-c', 'gn_debug_goma'], ret=0) |
388 | 395 |
389 def test_gn_lookup_goma_dir_expansion(self): | 396 def test_gn_lookup_goma_dir_expansion(self): |
390 self.check(['lookup', '-c', 'gn_rel_bot', '-g', '/foo'], ret=0, | 397 self.check(['lookup', '-c', 'gn_rel_bot', '-g', '/foo'], ret=0, |
391 out=("/fake_src/buildtools/linux64/gn gen _path_ " | 398 out=('\n' |
392 "'--args=is_debug=false use_goma=true " | 399 'Writing """\\\n' |
393 "goma_dir=\"/foo\"'\n" )) | 400 'goma_dir = "/foo"\n' |
| 401 'is_debug = false\n' |
| 402 'use_goma = true\n' |
| 403 '""" to _path_/args.gn.\n\n' |
| 404 '/fake_src/buildtools/linux64/gn gen _path_\n')) |
394 | 405 |
395 def test_gyp_analyze(self): | 406 def test_gyp_analyze(self): |
396 mbw = self.check(['analyze', '-c', 'gyp_rel_bot', '//out/Release', | 407 mbw = self.check(['analyze', '-c', 'gyp_rel_bot', '//out/Release', |
397 '/tmp/in.json', '/tmp/out.json'], ret=0) | 408 '/tmp/in.json', '/tmp/out.json'], ret=0) |
398 self.assertIn('analyzer', mbw.calls[0]) | 409 self.assertIn('analyzer', mbw.calls[0]) |
399 | 410 |
400 def test_gyp_crosscompile(self): | 411 def test_gyp_crosscompile(self): |
401 mbw = self.fake_mbw() | 412 mbw = self.fake_mbw() |
402 self.check(['gen', '-c', 'gyp_crosscompile', '//out/Release'], | 413 self.check(['gen', '-c', 'gyp_crosscompile', '//out/Release'], |
403 mbw=mbw, ret=0) | 414 mbw=mbw, ret=0) |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 self.check(['validate'], mbw=mbw, ret=0) | 452 self.check(['validate'], mbw=mbw, ret=0) |
442 | 453 |
443 def test_bad_validate(self): | 454 def test_bad_validate(self): |
444 mbw = self.fake_mbw() | 455 mbw = self.fake_mbw() |
445 mbw.files[mbw.default_config] = TEST_BAD_CONFIG | 456 mbw.files[mbw.default_config] = TEST_BAD_CONFIG |
446 self.check(['validate'], mbw=mbw, ret=1) | 457 self.check(['validate'], mbw=mbw, ret=1) |
447 | 458 |
448 | 459 |
449 if __name__ == '__main__': | 460 if __name__ == '__main__': |
450 unittest.main() | 461 unittest.main() |
OLD | NEW |