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

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

Issue 2160353003: Implement multi-phase build support in MB. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 4 years, 5 months 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_config.pyl ('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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 98
99 def write(self, contents): 99 def write(self, contents):
100 self.buf += contents 100 self.buf += contents
101 101
102 def close(self): 102 def close(self):
103 self.files[self.name] = self.buf 103 self.files[self.name] = self.buf
104 104
105 105
106 TEST_CONFIG = """\ 106 TEST_CONFIG = """\
107 { 107 {
108 'configs': {
109 'gyp_rel_bot': ['gyp', 'rel', 'goma'],
110 'gn_debug_goma': ['gn', 'debug', 'goma'],
111 'gyp_debug': ['gyp', 'debug', 'fake_feature1'],
112 'gn_rel_bot': ['gn', 'rel', 'goma'],
113 'gyp_crosscompile': ['gyp', 'crosscompile'],
114 },
115 'masters': { 108 'masters': {
116 'chromium': {}, 109 'chromium': {},
117 'fake_master': { 110 'fake_master': {
118 'fake_builder': 'gyp_rel_bot', 111 'fake_builder': 'gyp_rel_bot',
119 'fake_gn_builder': 'gn_rel_bot', 112 'fake_gn_builder': 'gn_rel_bot',
120 'fake_gyp_crosscompile_builder': 'gyp_crosscompile', 113 'fake_gyp_crosscompile_builder': 'gyp_crosscompile',
121 'fake_gn_debug_builder': 'gn_debug_goma', 114 'fake_gn_debug_builder': 'gn_debug_goma',
122 'fake_gyp_builder': 'gyp_debug', 115 'fake_gyp_builder': 'gyp_debug',
123 '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'],
124 }, 118 },
125 }, 119 },
120 'configs': {
121 'gyp_rel_bot': ['gyp', 'rel', 'goma'],
122 'gn_debug_goma': ['gn', 'debug', 'goma'],
123 'gyp_debug': ['gyp', 'debug', 'fake_feature1'],
124 'gn_rel_bot': ['gn', 'rel', 'goma'],
125 'gyp_crosscompile': ['gyp', 'crosscompile'],
126 'gn_phase_1': ['gn', 'phase_1'],
127 'gn_phase_2': ['gn', 'phase_2'],
128 },
126 'mixins': { 129 'mixins': {
127 'crosscompile': { 130 'crosscompile': {
128 'gyp_crosscompile': True, 131 'gyp_crosscompile': True,
129 }, 132 },
130 'fake_feature1': { 133 'fake_feature1': {
131 'gn_args': 'enable_doom_melon=true', 134 'gn_args': 'enable_doom_melon=true',
132 'gyp_defines': 'doom_melon=1', 135 'gyp_defines': 'doom_melon=1',
133 }, 136 },
134 'gyp': {'type': 'gyp'}, 137 'gyp': {'type': 'gyp'},
135 'gn': {'type': 'gn'}, 138 'gn': {'type': 'gn'},
136 'goma': { 139 'goma': {
137 'gn_args': 'use_goma=true', 140 'gn_args': 'use_goma=true',
138 'gyp_defines': 'goma=1', 141 'gyp_defines': 'goma=1',
139 }, 142 },
143 'phase_1': {
144 'gn_args': 'phase=1',
145 'gyp_args': 'phase=1',
146 },
147 'phase_2': {
148 'gn_args': 'phase=2',
149 'gyp_args': 'phase=2',
150 },
140 'rel': { 151 'rel': {
141 'gn_args': 'is_debug=false', 152 'gn_args': 'is_debug=false',
142 }, 153 },
143 'debug': { 154 'debug': {
144 'gn_args': 'is_debug=true', 155 'gn_args': 'is_debug=true',
145 }, 156 },
146 }, 157 },
147 } 158 }
148 """ 159 """
149 160
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 def test_help(self): 493 def test_help(self):
483 orig_stdout = sys.stdout 494 orig_stdout = sys.stdout
484 try: 495 try:
485 sys.stdout = StringIO.StringIO() 496 sys.stdout = StringIO.StringIO()
486 self.assertRaises(SystemExit, self.check, ['-h']) 497 self.assertRaises(SystemExit, self.check, ['-h'])
487 self.assertRaises(SystemExit, self.check, ['help']) 498 self.assertRaises(SystemExit, self.check, ['help'])
488 self.assertRaises(SystemExit, self.check, ['help', 'gen']) 499 self.assertRaises(SystemExit, self.check, ['help', 'gen'])
489 finally: 500 finally:
490 sys.stdout = orig_stdout 501 sys.stdout = orig_stdout
491 502
503 def test_multiple_phases(self):
504 # Check that not passing a --phase to a multi-phase builder fails.
505 mbw = self.check(['lookup', '-m', 'fake_master', '-b', 'fake_multi_phase'],
506 ret=1)
507 self.assertIn('Must specify a build --phase', mbw.out)
508
509 # Check that passing a --phase to a single-phase builder fails.
510 mbw = self.check(['lookup', '-m', 'fake_master', '-b', 'fake_gn_builder',
511 '--phase', '1'],
512 ret=1)
513 self.assertIn('Must not specify a build --phase', mbw.out)
514
515 # Check different ranges; 0 and 3 are out of bounds, 1 and 2 should work.
516 mbw = self.check(['lookup', '-m', 'fake_master', '-b', 'fake_multi_phase',
517 '--phase', '0'], ret=1)
518 self.assertIn('Phase 0 out of bounds', mbw.out)
519
520 mbw = self.check(['lookup', '-m', 'fake_master', '-b', 'fake_multi_phase',
521 '--phase', '1'], ret=0)
522 self.assertIn('phase = 1', mbw.out)
523
524 mbw = self.check(['lookup', '-m', 'fake_master', '-b', 'fake_multi_phase',
525 '--phase', '2'], ret=0)
526 self.assertIn('phase = 2', mbw.out)
527
528 mbw = self.check(['lookup', '-m', 'fake_master', '-b', 'fake_multi_phase',
529 '--phase', '3'], ret=1)
530 self.assertIn('Phase 3 out of bounds', mbw.out)
531
492 def test_validate(self): 532 def test_validate(self):
493 mbw = self.fake_mbw() 533 mbw = self.fake_mbw()
494 self.check(['validate'], mbw=mbw, ret=0) 534 self.check(['validate'], mbw=mbw, ret=0)
535
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 :).
536 def test_bad_validate(self):
537 mbw = self.fake_mbw()
538 mbw.files[mbw.default_config] = TEST_BAD_CONFIG
539 self.check(['validate'], mbw=mbw, ret=1)
540
541 def test_gyp_env_hacks(self):
542 mbw = self.fake_mbw()
543 mbw.files[mbw.default_config] = GYP_HACKS_CONFIG
544 self.check(['lookup', '-c', 'fake_config'], mbw=mbw,
545 ret=0,
546 out=("GYP_DEFINES='foo=bar baz=1'\n"
547 "GYP_LINK_CONCURRENCY=1\n"
548 "LLVM_FORCE_HEAD_REVISION=1\n"
549 "python build/gyp_chromium -G output_dir=_path_\n"))
550
551
552 if __name__ == '__main__':
553 unittest.main()
554
555 def test_validate(self):
556 mbw = self.fake_mbw()
557 self.check(['validate'], mbw=mbw, ret=0)
495 558
496 def test_bad_validate(self): 559 def test_bad_validate(self):
497 mbw = self.fake_mbw() 560 mbw = self.fake_mbw()
498 mbw.files[mbw.default_config] = TEST_BAD_CONFIG 561 mbw.files[mbw.default_config] = TEST_BAD_CONFIG
499 self.check(['validate'], mbw=mbw, ret=1) 562 self.check(['validate'], mbw=mbw, ret=1)
500 563
501 def test_gyp_env_hacks(self): 564 def test_gyp_env_hacks(self):
502 mbw = self.fake_mbw() 565 mbw = self.fake_mbw()
503 mbw.files[mbw.default_config] = GYP_HACKS_CONFIG 566 mbw.files[mbw.default_config] = GYP_HACKS_CONFIG
504 self.check(['lookup', '-c', 'fake_config'], mbw=mbw, 567 self.check(['lookup', '-c', 'fake_config'], mbw=mbw,
505 ret=0, 568 ret=0,
506 out=("GYP_DEFINES='foo=bar baz=1'\n" 569 out=("GYP_DEFINES='foo=bar baz=1'\n"
507 "GYP_LINK_CONCURRENCY=1\n" 570 "GYP_LINK_CONCURRENCY=1\n"
508 "LLVM_FORCE_HEAD_REVISION=1\n" 571 "LLVM_FORCE_HEAD_REVISION=1\n"
509 "python build/gyp_chromium -G output_dir=_path_\n")) 572 "python build/gyp_chromium -G output_dir=_path_\n"))
510 573
511 574
512 if __name__ == '__main__': 575 if __name__ == '__main__':
513 unittest.main() 576 unittest.main()
OLDNEW
« no previous file with comments | « tools/mb/mb_config.pyl ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698