Chromium Code Reviews| 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 106 'common_dev_configs': ['gn_debug'], | 106 'common_dev_configs': ['gn_debug'], |
| 107 'configs': { | 107 'configs': { |
| 108 'gyp_rel_bot': ['gyp', 'rel', 'goma'], | 108 'gyp_rel_bot': ['gyp', 'rel', 'goma'], |
| 109 'gn_debug': ['gn', 'debug', 'goma'], | 109 'gn_debug': ['gn', 'debug', 'goma'], |
| 110 'gyp_debug': ['gyp', 'debug'], | 110 'gyp_debug': ['gyp', 'debug'], |
| 111 'gn_rel_bot': ['gn', 'rel', 'goma'], | 111 'gn_rel_bot': ['gn', 'rel', 'goma'], |
| 112 'private': ['gyp', 'rel', 'fake_feature1'], | 112 'private': ['gyp', 'rel', 'fake_feature1'], |
| 113 'unsupported': ['gn', 'fake_feature2'], | 113 'unsupported': ['gn', 'fake_feature2'], |
| 114 }, | 114 }, |
| 115 'masters': { | 115 'masters': { |
| 116 'chromium': {}, | |
| 116 'fake_master': { | 117 'fake_master': { |
| 117 'fake_builder': 'gyp_rel_bot', | 118 'fake_builder': 'gyp_rel_bot', |
| 118 'fake_gn_builder': 'gn_rel_bot', | 119 'fake_gn_builder': 'gn_rel_bot', |
| 119 'fake_gyp_builder': 'gyp_debug', | 120 'fake_gyp_builder': 'gyp_debug', |
| 120 }, | 121 }, |
| 121 }, | 122 }, |
| 122 'mixins': { | 123 'mixins': { |
| 123 'fake_feature1': { | 124 'fake_feature1': { |
| 124 'gn_args': 'enable_doom_melon=true', | 125 'gn_args': 'enable_doom_melon=true', |
| 125 'gyp_crosscompile': True, | 126 'gyp_crosscompile': True, |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 391 def test_help(self): | 392 def test_help(self): |
| 392 orig_stdout = sys.stdout | 393 orig_stdout = sys.stdout |
| 393 try: | 394 try: |
| 394 sys.stdout = StringIO.StringIO() | 395 sys.stdout = StringIO.StringIO() |
| 395 self.assertRaises(SystemExit, self.check, ['-h']) | 396 self.assertRaises(SystemExit, self.check, ['-h']) |
| 396 self.assertRaises(SystemExit, self.check, ['help']) | 397 self.assertRaises(SystemExit, self.check, ['help']) |
| 397 self.assertRaises(SystemExit, self.check, ['help', 'gen']) | 398 self.assertRaises(SystemExit, self.check, ['help', 'gen']) |
| 398 finally: | 399 finally: |
| 399 sys.stdout = orig_stdout | 400 sys.stdout = orig_stdout |
| 400 | 401 |
| 401 | |
| 402 def test_validate(self): | 402 def test_validate(self): |
| 403 self.check(['validate'], ret=0) | 403 self.check(['validate'], ret=0) |
| 404 | 404 |
| 405 | 405 |
| 406 TEST_BAD_CONFIG = """\ | |
| 407 { | |
| 408 'common_dev_configs': ['gn_rel_bot_1'], | |
| 409 'configs': { | |
| 410 'gn_rel_bot_1': ['gn', 'rel', 'chrome_with_codecs'], | |
| 411 'gn_rel_bot_2': ['gn', 'rel', 'bad_nested_config'], | |
| 412 }, | |
| 413 'masters': { | |
| 414 'chromium': { | |
| 415 'a': 'gn_rel_bot_1', | |
| 416 'b': 'gn_rel_bot_2', | |
| 417 }, | |
| 418 }, | |
| 419 'mixins': { | |
| 420 'gn': {'type': 'gn'}, | |
| 421 'chrome_with_codecs': { | |
| 422 'gn_args': 'proprietary_codecs=true', | |
| 423 }, | |
| 424 'bad_nested_config': { | |
| 425 'mixins': ['chrome_with_codecs'], | |
| 426 }, | |
| 427 'rel': { | |
| 428 'gn_args': 'is_debug=false', | |
| 429 }, | |
| 430 }, | |
| 431 'private_configs': ['private'], | |
| 432 'unsupported_configs': ['unsupported'], | |
| 433 } | |
| 434 """ | |
| 435 | |
| 436 | |
| 437 TEST_BAD_CONFIG_ERR = """\ | |
| 438 mb config file /fake_src/tools/mb/mb_config.pyl has problems: | |
| 439 Config "gn_rel_bot_1" used by a bot is also listed in "common_dev_configs". | |
| 440 Unknown config "unsupported" referenced from "unsupported_configs". | |
| 441 Unknown config "private" referenced from "private_configs". | |
| 442 Public artifact builder "a" can not contain the "chrome_with_codecs" mixin. | |
| 443 Public artifact builder "b" can not contain the "chrome_with_codecs" mixin.""" | |
| 444 | |
| 445 | |
| 446 class UnitTest2(unittest.TestCase): | |
| 447 def fake_mbw(self, files=None, win32=False): | |
| 448 mbw = FakeMBW(win32=win32) | |
| 449 mbw.files.setdefault(mbw.default_config, TEST_BAD_CONFIG) | |
| 450 if files: | |
| 451 for path, contents in files.items(): | |
| 452 mbw.files[path] = contents | |
| 453 return mbw | |
| 454 | |
| 455 def test_validate(self): | |
| 456 mbw = self.fake_mbw() | |
|
Dirk Pranke
2016/03/09 19:47:07
This is, I think, somewhat more complicated than i
DaleCurtis
2016/03/09 21:36:27
Whoops, yeah it was late when I wrote the other co
| |
| 457 mbw.ParseArgs(['validate']) | |
| 458 self.assertRaisesRegexp(Exception, TEST_BAD_CONFIG_ERR, mbw.args.func) | |
| 459 | |
| 460 | |
| 406 if __name__ == '__main__': | 461 if __name__ == '__main__': |
| 407 unittest.main() | 462 unittest.main() |
| OLD | NEW |