| 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 { | 107 { |
| 108 'masters': { | 108 'masters': { |
| 109 'chromium': {}, | 109 'chromium': {}, |
| 110 'fake_master': { | 110 'fake_master': { |
| 111 'fake_builder': 'gyp_rel_bot', | 111 'fake_builder': 'gyp_rel_bot', |
| 112 'fake_gn_builder': 'gn_rel_bot', | 112 'fake_gn_builder': 'gn_rel_bot', |
| 113 'fake_gyp_crosscompile_builder': 'gyp_crosscompile', | 113 'fake_gyp_crosscompile_builder': 'gyp_crosscompile', |
| 114 'fake_gn_debug_builder': 'gn_debug_goma', | 114 'fake_gn_debug_builder': 'gn_debug_goma', |
| 115 'fake_gyp_builder': 'gyp_debug', | 115 'fake_gyp_builder': 'gyp_debug', |
| 116 'fake_gn_args_bot': '//build/args/bots/fake_master/fake_gn_args_bot.gn', | 116 'fake_gn_args_bot': '//build/args/bots/fake_master/fake_gn_args_bot.gn', |
| 117 'fake_multi_phase': ['gn_phase_1', 'gn_phase_2'], | 117 'fake_multi_phase': { 'phase_1': 'gn_phase_1', 'phase_2': 'gn_phase_2'}, |
| 118 }, | 118 }, |
| 119 }, | 119 }, |
| 120 'configs': { | 120 'configs': { |
| 121 'gyp_rel_bot': ['gyp', 'rel', 'goma'], | 121 'gyp_rel_bot': ['gyp', 'rel', 'goma'], |
| 122 'gn_debug_goma': ['gn', 'debug', 'goma'], | 122 'gn_debug_goma': ['gn', 'debug', 'goma'], |
| 123 'gyp_debug': ['gyp', 'debug', 'fake_feature1'], | 123 'gyp_debug': ['gyp', 'debug', 'fake_feature1'], |
| 124 'gn_rel_bot': ['gn', 'rel', 'goma'], | 124 'gn_rel_bot': ['gn', 'rel', 'goma'], |
| 125 'gyp_crosscompile': ['gyp', 'crosscompile'], | 125 'gyp_crosscompile': ['gyp', 'crosscompile'], |
| 126 'gn_phase_1': ['gn', 'phase_1'], | 126 'gn_phase_1': ['gn', 'phase_1'], |
| 127 'gn_phase_2': ['gn', 'phase_2'], | 127 'gn_phase_2': ['gn', 'phase_2'], |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 sys.stdout = orig_stdout | 461 sys.stdout = orig_stdout |
| 462 | 462 |
| 463 def test_multiple_phases(self): | 463 def test_multiple_phases(self): |
| 464 # Check that not passing a --phase to a multi-phase builder fails. | 464 # Check that not passing a --phase to a multi-phase builder fails. |
| 465 mbw = self.check(['lookup', '-m', 'fake_master', '-b', 'fake_multi_phase'], | 465 mbw = self.check(['lookup', '-m', 'fake_master', '-b', 'fake_multi_phase'], |
| 466 ret=1) | 466 ret=1) |
| 467 self.assertIn('Must specify a build --phase', mbw.out) | 467 self.assertIn('Must specify a build --phase', mbw.out) |
| 468 | 468 |
| 469 # Check that passing a --phase to a single-phase builder fails. | 469 # Check that passing a --phase to a single-phase builder fails. |
| 470 mbw = self.check(['lookup', '-m', 'fake_master', '-b', 'fake_gn_builder', | 470 mbw = self.check(['lookup', '-m', 'fake_master', '-b', 'fake_gn_builder', |
| 471 '--phase', '1'], | 471 '--phase', 'phase_1'], ret=1) |
| 472 ret=1) | |
| 473 self.assertIn('Must not specify a build --phase', mbw.out) | 472 self.assertIn('Must not specify a build --phase', mbw.out) |
| 474 | 473 |
| 475 # Check different ranges; 0 and 3 are out of bounds, 1 and 2 should work. | 474 # Check that passing a wrong phase key to a multi-phase builder fails. |
| 476 mbw = self.check(['lookup', '-m', 'fake_master', '-b', 'fake_multi_phase', | 475 mbw = self.check(['lookup', '-m', 'fake_master', '-b', 'fake_multi_phase', |
| 477 '--phase', '0'], ret=1) | 476 '--phase', 'wrong_phase'], ret=1) |
| 478 self.assertIn('Phase 0 out of bounds', mbw.out) | 477 self.assertIn('Phase wrong_phase doesn\'t exist', mbw.out) |
| 479 | 478 |
| 479 # Check that passing a correct phase key to a multi-phase builder passes. |
| 480 mbw = self.check(['lookup', '-m', 'fake_master', '-b', 'fake_multi_phase', | 480 mbw = self.check(['lookup', '-m', 'fake_master', '-b', 'fake_multi_phase', |
| 481 '--phase', '1'], ret=0) | 481 '--phase', 'phase_1'], ret=0) |
| 482 self.assertIn('phase = 1', mbw.out) | 482 self.assertIn('phase = 1', mbw.out) |
| 483 | 483 |
| 484 mbw = self.check(['lookup', '-m', 'fake_master', '-b', 'fake_multi_phase', | 484 mbw = self.check(['lookup', '-m', 'fake_master', '-b', 'fake_multi_phase', |
| 485 '--phase', '2'], ret=0) | 485 '--phase', 'phase_2'], ret=0) |
| 486 self.assertIn('phase = 2', mbw.out) | 486 self.assertIn('phase = 2', mbw.out) |
| 487 | 487 |
| 488 mbw = self.check(['lookup', '-m', 'fake_master', '-b', 'fake_multi_phase', | |
| 489 '--phase', '3'], ret=1) | |
| 490 self.assertIn('Phase 3 out of bounds', mbw.out) | |
| 491 | |
| 492 def test_validate(self): | 488 def test_validate(self): |
| 493 mbw = self.fake_mbw() | 489 mbw = self.fake_mbw() |
| 494 self.check(['validate'], mbw=mbw, ret=0) | 490 self.check(['validate'], mbw=mbw, ret=0) |
| 495 | 491 |
| 496 def test_bad_validate(self): | 492 def test_bad_validate(self): |
| 497 mbw = self.fake_mbw() | 493 mbw = self.fake_mbw() |
| 498 mbw.files[mbw.default_config] = TEST_BAD_CONFIG | 494 mbw.files[mbw.default_config] = TEST_BAD_CONFIG |
| 499 self.check(['validate'], mbw=mbw, ret=1) | 495 self.check(['validate'], mbw=mbw, ret=1) |
| 500 | 496 |
| 501 def test_gyp_env_hacks(self): | 497 def test_gyp_env_hacks(self): |
| (...skipping 25 matching lines...) Expand all Loading... |
| 527 self.check(['lookup', '-c', 'fake_config'], mbw=mbw, | 523 self.check(['lookup', '-c', 'fake_config'], mbw=mbw, |
| 528 ret=0, | 524 ret=0, |
| 529 out=("GYP_DEFINES='foo=bar baz=1'\n" | 525 out=("GYP_DEFINES='foo=bar baz=1'\n" |
| 530 "GYP_LINK_CONCURRENCY=1\n" | 526 "GYP_LINK_CONCURRENCY=1\n" |
| 531 "LLVM_FORCE_HEAD_REVISION=1\n" | 527 "LLVM_FORCE_HEAD_REVISION=1\n" |
| 532 "python build/gyp_chromium -G output_dir=_path_\n")) | 528 "python build/gyp_chromium -G output_dir=_path_\n")) |
| 533 | 529 |
| 534 | 530 |
| 535 if __name__ == '__main__': | 531 if __name__ == '__main__': |
| 536 unittest.main() | 532 unittest.main() |
| OLD | NEW |