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

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

Issue 1803293002: Only enforce the 'chromium' check in MB for the default config file. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tweak exception clauses Created 4 years, 9 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.py ('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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 'rel': { 173 'rel': {
174 'gn_args': 'is_debug=false', 174 'gn_args': 'is_debug=false',
175 }, 175 },
176 }, 176 },
177 'private_configs': ['private'], 177 'private_configs': ['private'],
178 'unsupported_configs': ['unsupported'], 178 'unsupported_configs': ['unsupported'],
179 } 179 }
180 """ 180 """
181 181
182 182
183 TEST_BAD_CONFIG_ERR = """\ 183 TEST_BAD_CONFIG_ERR = """\
DaleCurtis 2016/03/16 16:42:22 It doesn't look like this is used anymore; remove?
184 mb config file /fake_src/tools/mb/mb_config.pyl has problems: 184 mb config file /fake_src/tools/mb/mb_config.pyl has problems:
185 Config "gn_rel_bot_1" used by a bot is also listed in "common_dev_configs". 185 Config "gn_rel_bot_1" used by a bot is also listed in "common_dev_configs".
186 Unknown config "unsupported" referenced from "unsupported_configs". 186 Unknown config "unsupported" referenced from "unsupported_configs".
187 Unknown config "private" referenced from "private_configs". 187 Unknown config "private" referenced from "private_configs".
188 Public artifact builder "a" can not contain the "chrome_with_codecs" mixin. 188 Public artifact builder "a" can not contain the "chrome_with_codecs" mixin.
189 Public artifact builder "b" can not contain the "chrome_with_codecs" mixin.""" 189 Public artifact builder "b" can not contain the "chrome_with_codecs" mixin."""
190 190
191 191
192 class UnitTest(unittest.TestCase): 192 class UnitTest(unittest.TestCase):
193 def fake_mbw(self, files=None, win32=False): 193 def fake_mbw(self, files=None, win32=False):
194 mbw = FakeMBW(win32=win32) 194 mbw = FakeMBW(win32=win32)
195 mbw.files.setdefault(mbw.default_config, TEST_CONFIG) 195 mbw.files.setdefault(mbw.default_config, TEST_CONFIG)
196 if files: 196 if files:
197 for path, contents in files.items(): 197 for path, contents in files.items():
198 mbw.files[path] = contents 198 mbw.files[path] = contents
199 return mbw 199 return mbw
200 200
201 def check(self, args, mbw=None, files=None, out=None, err=None, ret=None, 201 def check(self, args, mbw=None, files=None, out=None, err=None, ret=None):
202 exception=None):
203 if not mbw: 202 if not mbw:
204 mbw = self.fake_mbw(files) 203 mbw = self.fake_mbw(files)
205 mbw.ParseArgs(args)
206 204
207 actual_ret = None 205 actual_ret = mbw.Main(args)
208 if exception is not None:
209 self.assertRaisesRegexp(Exception, exception, mbw.args.func)
210 else:
211 actual_ret = mbw.args.func()
212 206
213 self.assertEqual(actual_ret, ret) 207 self.assertEqual(actual_ret, ret)
214 if out is not None: 208 if out is not None:
215 self.assertEqual(mbw.out, out) 209 self.assertEqual(mbw.out, out)
216 if err is not None: 210 if err is not None:
217 self.assertEqual(mbw.err, err) 211 self.assertEqual(mbw.err, err)
218 return mbw 212 return mbw
219 213
220 def test_clobber(self): 214 def test_clobber(self):
221 files = { 215 files = {
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 orig_stdout = sys.stdout 433 orig_stdout = sys.stdout
440 try: 434 try:
441 sys.stdout = StringIO.StringIO() 435 sys.stdout = StringIO.StringIO()
442 self.assertRaises(SystemExit, self.check, ['-h']) 436 self.assertRaises(SystemExit, self.check, ['-h'])
443 self.assertRaises(SystemExit, self.check, ['help']) 437 self.assertRaises(SystemExit, self.check, ['help'])
444 self.assertRaises(SystemExit, self.check, ['help', 'gen']) 438 self.assertRaises(SystemExit, self.check, ['help', 'gen'])
445 finally: 439 finally:
446 sys.stdout = orig_stdout 440 sys.stdout = orig_stdout
447 441
448 def test_validate(self): 442 def test_validate(self):
449 self.check(['validate'], ret=0) 443 mbw = self.fake_mbw()
444 mbw.files[mbw.default_config] = TEST_CONFIG
445 self.check(['validate'], mbw=mbw, ret=0)
450 446
451 def test_bad_validate(self): 447 def test_bad_validate(self):
452 mbw = self.fake_mbw() 448 mbw = self.fake_mbw()
453 mbw.files[mbw.default_config] = TEST_BAD_CONFIG 449 mbw.files[mbw.default_config] = TEST_BAD_CONFIG
454 self.check(['validate'], mbw=mbw, exception=TEST_BAD_CONFIG_ERR) 450 self.check(['validate'], mbw=mbw, ret=1)
455 451
456 452
457 if __name__ == '__main__': 453 if __name__ == '__main__':
458 unittest.main() 454 unittest.main()
OLDNEW
« no previous file with comments | « tools/mb/mb.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698