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

Unified Diff: tools/mb/mb_unittest.py

Issue 2341403004: Revert of Update MB to use `gn analyze`. (Closed)
Patch Set: Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/mb/mb.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/mb/mb_unittest.py
diff --git a/tools/mb/mb_unittest.py b/tools/mb/mb_unittest.py
index 6870b24f862b5f9ad47d60b76a40486252f38da8..98a1b05919b1c1400c4956011402f8efb636f6b1 100755
--- a/tools/mb/mb_unittest.py
+++ b/tools/mb/mb_unittest.py
@@ -216,15 +216,6 @@
mbw = FakeMBW(win32=win32)
mbw.files.setdefault(mbw.default_config, TEST_CONFIG)
mbw.files.setdefault(
- mbw.ToAbsPath('//testing/buildbot/gn_isolate_map.pyl'),
- '''{
- "foo_unittests": {
- "label": "//foo:foo_unittests",
- "type": "console_test_launcher",
- "args": [],
- },
- }''')
- mbw.files.setdefault(
mbw.ToAbsPath('//build/args/bots/fake_master/fake_gn_args_bot.gn'),
'is_debug = false\n')
if files:
@@ -277,27 +268,76 @@
self.assertEqual(mbw.files['/fake_src/out/Debug/mb_type'], 'gyp')
def test_gn_analyze(self):
- files = {'/tmp/in.json': '''{\
+ files = {'/tmp/in.json': """{\
"files": ["foo/foo_unittest.cc"],
- "test_targets": ["foo_unittests"],
- "additional_compile_targets": ["all"]
- }''',
- '/tmp/out.json.gn': '''{\
- "status": "Found dependency",
- "compile_targets": ["//foo:foo_unittests"],
- "test_targets": ["//foo:foo_unittests"]
- }'''}
+ "test_targets": ["foo_unittests", "bar_unittests"],
+ "additional_compile_targets": []
+ }"""}
mbw = self.fake_mbw(files)
- mbw.Call = lambda cmd, env=None, buffer_output=True: (0, '', '')
+ mbw.Call = lambda cmd, env=None, buffer_output=True: (
+ 0, 'out/Default/foo_unittests\n', '')
self.check(['analyze', '-c', 'gn_debug_goma', '//out/Default',
'/tmp/in.json', '/tmp/out.json'], mbw=mbw, ret=0)
out = json.loads(mbw.files['/tmp/out.json'])
self.assertEqual(out, {
'status': 'Found dependency',
- 'compile_targets': ['foo:foo_unittests'],
+ 'compile_targets': ['foo_unittests'],
'test_targets': ['foo_unittests']
+ })
+
+ def test_gn_analyze_fails(self):
+ files = {'/tmp/in.json': """{\
+ "files": ["foo/foo_unittest.cc"],
+ "test_targets": ["foo_unittests", "bar_unittests"],
+ "additional_compile_targets": []
+ }"""}
+
+ mbw = self.fake_mbw(files)
+ mbw.Call = lambda cmd, env=None, buffer_output=True: (1, '', '')
+
+ self.check(['analyze', '-c', 'gn_debug_goma', '//out/Default',
+ '/tmp/in.json', '/tmp/out.json'], mbw=mbw, ret=1)
+
+ def test_gn_analyze_all(self):
+ files = {'/tmp/in.json': """{\
+ "files": ["foo/foo_unittest.cc"],
+ "test_targets": ["bar_unittests"],
+ "additional_compile_targets": ["all"]
+ }"""}
+ mbw = self.fake_mbw(files)
+ mbw.Call = lambda cmd, env=None, buffer_output=True: (
+ 0, 'out/Default/foo_unittests\n', '')
+ self.check(['analyze', '-c', 'gn_debug_goma', '//out/Default',
+ '/tmp/in.json', '/tmp/out.json'], mbw=mbw, ret=0)
+ out = json.loads(mbw.files['/tmp/out.json'])
+ self.assertEqual(out, {
+ 'status': 'Found dependency (all)',
+ 'compile_targets': ['all', 'bar_unittests'],
+ 'test_targets': ['bar_unittests'],
+ })
+
+ def test_gn_analyze_missing_file(self):
+ files = {'/tmp/in.json': """{\
+ "files": ["foo/foo_unittest.cc"],
+ "test_targets": ["bar_unittests"],
+ "additional_compile_targets": []
+ }"""}
+ mbw = self.fake_mbw(files)
+ mbw.cmds = [
+ (0, '', ''),
+ (1, 'The input matches no targets, configs, or files\n', ''),
+ (1, 'The input matches no targets, configs, or files\n', ''),
+ ]
+
+ self.check(['analyze', '-c', 'gn_debug_goma', '//out/Default',
+ '/tmp/in.json', '/tmp/out.json'], mbw=mbw, ret=0)
+ out = json.loads(mbw.files['/tmp/out.json'])
+ self.assertEqual(out, {
+ 'status': 'No dependency',
+ 'compile_targets': [],
+ 'test_targets': [],
})
def test_gn_gen(self):
« 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