Chromium Code Reviews| Index: tools/mb/mb_unittest.py |
| diff --git a/tools/mb/mb_unittest.py b/tools/mb/mb_unittest.py |
| index 8747ac4e59c7e9a881b8b3254d4c832a588a17b2..98a1b05919b1c1400c4956011402f8efb636f6b1 100755 |
| --- a/tools/mb/mb_unittest.py |
| +++ b/tools/mb/mb_unittest.py |
| @@ -105,13 +105,6 @@ class FakeFile(object): |
| TEST_CONFIG = """\ |
| { |
| - 'configs': { |
| - 'gyp_rel_bot': ['gyp', 'rel', 'goma'], |
| - 'gn_debug_goma': ['gn', 'debug', 'goma'], |
| - 'gyp_debug': ['gyp', 'debug', 'fake_feature1'], |
| - 'gn_rel_bot': ['gn', 'rel', 'goma'], |
| - 'gyp_crosscompile': ['gyp', 'crosscompile'], |
| - }, |
| 'masters': { |
| 'chromium': {}, |
| 'fake_master': { |
| @@ -121,8 +114,18 @@ TEST_CONFIG = """\ |
| 'fake_gn_debug_builder': 'gn_debug_goma', |
| 'fake_gyp_builder': 'gyp_debug', |
| 'fake_gn_args_bot': '//build/args/bots/fake_master/fake_gn_args_bot.gn', |
| + 'fake_multi_phase': ['gn_phase_1', 'gn_phase_2'], |
| }, |
| }, |
| + 'configs': { |
| + 'gyp_rel_bot': ['gyp', 'rel', 'goma'], |
| + 'gn_debug_goma': ['gn', 'debug', 'goma'], |
| + 'gyp_debug': ['gyp', 'debug', 'fake_feature1'], |
| + 'gn_rel_bot': ['gn', 'rel', 'goma'], |
| + 'gyp_crosscompile': ['gyp', 'crosscompile'], |
| + 'gn_phase_1': ['gn', 'phase_1'], |
| + 'gn_phase_2': ['gn', 'phase_2'], |
| + }, |
| 'mixins': { |
| 'crosscompile': { |
| 'gyp_crosscompile': True, |
| @@ -137,6 +140,14 @@ TEST_CONFIG = """\ |
| 'gn_args': 'use_goma=true', |
| 'gyp_defines': 'goma=1', |
| }, |
| + 'phase_1': { |
| + 'gn_args': 'phase=1', |
| + 'gyp_args': 'phase=1', |
| + }, |
| + 'phase_2': { |
| + 'gn_args': 'phase=2', |
| + 'gyp_args': 'phase=2', |
| + }, |
| 'rel': { |
| 'gn_args': 'is_debug=false', |
| }, |
| @@ -489,6 +500,58 @@ class UnitTest(unittest.TestCase): |
| finally: |
| sys.stdout = orig_stdout |
| + def test_multiple_phases(self): |
| + # Check that not passing a --phase to a multi-phase builder fails. |
| + mbw = self.check(['lookup', '-m', 'fake_master', '-b', 'fake_multi_phase'], |
| + ret=1) |
| + self.assertIn('Must specify a build --phase', mbw.out) |
| + |
| + # Check that passing a --phase to a single-phase builder fails. |
| + mbw = self.check(['lookup', '-m', 'fake_master', '-b', 'fake_gn_builder', |
| + '--phase', '1'], |
| + ret=1) |
| + self.assertIn('Must not specify a build --phase', mbw.out) |
| + |
| + # Check different ranges; 0 and 3 are out of bounds, 1 and 2 should work. |
| + mbw = self.check(['lookup', '-m', 'fake_master', '-b', 'fake_multi_phase', |
| + '--phase', '0'], ret=1) |
| + self.assertIn('Phase 0 out of bounds', mbw.out) |
| + |
| + mbw = self.check(['lookup', '-m', 'fake_master', '-b', 'fake_multi_phase', |
| + '--phase', '1'], ret=0) |
| + self.assertIn('phase = 1', mbw.out) |
| + |
| + mbw = self.check(['lookup', '-m', 'fake_master', '-b', 'fake_multi_phase', |
| + '--phase', '2'], ret=0) |
| + self.assertIn('phase = 2', mbw.out) |
| + |
| + mbw = self.check(['lookup', '-m', 'fake_master', '-b', 'fake_multi_phase', |
| + '--phase', '3'], ret=1) |
| + self.assertIn('Phase 3 out of bounds', mbw.out) |
| + |
| + def test_validate(self): |
| + mbw = self.fake_mbw() |
| + self.check(['validate'], mbw=mbw, ret=0) |
| + |
|
kjellander_chromium
2016/12/17 20:55:13
What happened here at line 535-557? It seems like
Dirk Pranke
2016/12/18 02:39:46
Whoops. Looks like you're right :).
|
| + def test_bad_validate(self): |
| + mbw = self.fake_mbw() |
| + mbw.files[mbw.default_config] = TEST_BAD_CONFIG |
| + self.check(['validate'], mbw=mbw, ret=1) |
| + |
| + def test_gyp_env_hacks(self): |
| + mbw = self.fake_mbw() |
| + mbw.files[mbw.default_config] = GYP_HACKS_CONFIG |
| + self.check(['lookup', '-c', 'fake_config'], mbw=mbw, |
| + ret=0, |
| + out=("GYP_DEFINES='foo=bar baz=1'\n" |
| + "GYP_LINK_CONCURRENCY=1\n" |
| + "LLVM_FORCE_HEAD_REVISION=1\n" |
| + "python build/gyp_chromium -G output_dir=_path_\n")) |
| + |
| + |
| +if __name__ == '__main__': |
| + unittest.main() |
| + |
| def test_validate(self): |
| mbw = self.fake_mbw() |
| self.check(['validate'], mbw=mbw, ret=0) |