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 sys | 10 import sys |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 'gyp_defaults': 'doom_melon=0', | 114 'gyp_defaults': 'doom_melon=0', |
115 }, | 115 }, |
116 'gyp': {'type': 'gyp'}, | 116 'gyp': {'type': 'gyp'}, |
117 'gn': {'type': 'gn'}, | 117 'gn': {'type': 'gn'}, |
118 'goma': { | 118 'goma': { |
119 'gn_args': 'use_goma=true goma_dir="$(goma_dir)"', | 119 'gn_args': 'use_goma=true goma_dir="$(goma_dir)"', |
120 'gyp_defines': 'goma=1 gomadir="$(goma_dir)"', | 120 'gyp_defines': 'goma=1 gomadir="$(goma_dir)"', |
121 }, | 121 }, |
122 'rel': { | 122 'rel': { |
123 'gn_args': 'is_debug=false', | 123 'gn_args': 'is_debug=false', |
124 'gyp_config': 'Release', | |
125 }, | 124 }, |
126 'debug': { | 125 'debug': { |
127 'gn_args': 'is_debug=true', | 126 'gn_args': 'is_debug=true', |
128 'gyp_config': 'Debug', | |
129 }, | 127 }, |
130 }, | 128 }, |
131 'private_configs': ['private'], | 129 'private_configs': ['private'], |
132 'unsupported_configs': ['unsupported'], | 130 'unsupported_configs': ['unsupported'], |
133 } | 131 } |
134 """ | 132 """ |
135 | 133 |
136 | 134 |
137 class UnitTest(unittest.TestCase): | 135 class UnitTest(unittest.TestCase): |
138 def fake_mbw(self, files=None): | 136 def fake_mbw(self, files=None): |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 self.check(['gen', '-c', 'gyp_rel_bot', '//out/Release'], ret=0) | 295 self.check(['gen', '-c', 'gyp_rel_bot', '//out/Release'], ret=0) |
298 | 296 |
299 def test_gyp_gen_fails(self): | 297 def test_gyp_gen_fails(self): |
300 mbw = self.fake_mbw() | 298 mbw = self.fake_mbw() |
301 mbw.Call = lambda cmd, env=None: (1, '', '') | 299 mbw.Call = lambda cmd, env=None: (1, '', '') |
302 self.check(['gen', '-c', 'gyp_rel_bot', '//out/Release'], mbw=mbw, ret=1) | 300 self.check(['gen', '-c', 'gyp_rel_bot', '//out/Release'], mbw=mbw, ret=1) |
303 | 301 |
304 def test_gyp_lookup_goma_dir_expansion(self): | 302 def test_gyp_lookup_goma_dir_expansion(self): |
305 self.check(['lookup', '-c', 'gyp_rel_bot', '-g', '/foo'], ret=0, | 303 self.check(['lookup', '-c', 'gyp_rel_bot', '-g', '/foo'], ret=0, |
306 out=("python build/gyp_chromium -G 'output_dir=<path>' " | 304 out=("python build/gyp_chromium -G 'output_dir=<path>' " |
307 "-G config=Release -D goma=1 -D gomadir=/foo\n")) | 305 "-D goma=1 -D gomadir=/foo\n")) |
308 | 306 |
309 def test_help(self): | 307 def test_help(self): |
310 orig_stdout = sys.stdout | 308 orig_stdout = sys.stdout |
311 try: | 309 try: |
312 sys.stdout = StringIO.StringIO() | 310 sys.stdout = StringIO.StringIO() |
313 self.assertRaises(SystemExit, self.check, ['-h']) | 311 self.assertRaises(SystemExit, self.check, ['-h']) |
314 self.assertRaises(SystemExit, self.check, ['help']) | 312 self.assertRaises(SystemExit, self.check, ['help']) |
315 self.assertRaises(SystemExit, self.check, ['help', 'gen']) | 313 self.assertRaises(SystemExit, self.check, ['help', 'gen']) |
316 finally: | 314 finally: |
317 sys.stdout = orig_stdout | 315 sys.stdout = orig_stdout |
318 | 316 |
319 | 317 |
320 def test_validate(self): | 318 def test_validate(self): |
321 self.check(['validate'], ret=0) | 319 self.check(['validate'], ret=0) |
322 | 320 |
323 | 321 |
324 if __name__ == '__main__': | 322 if __name__ == '__main__': |
325 unittest.main() | 323 unittest.main() |
OLD | NEW |