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

Unified Diff: tools/mb/mb_unittest.py

Issue 1440173002: Update MB for the new way to run 'analyze'. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: original patch for review Created 5 years, 1 month 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
« tools/mb/docs/design_spec.md ('K') | « 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 23b3ee08efa933bd071c6b8c04fd2fe17784d445..1a0f901f901a72c396a1a849d434eca6e92eb50b 100755
--- a/tools/mb/mb_unittest.py
+++ b/tools/mb/mb_unittest.py
@@ -220,6 +220,26 @@ class UnitTest(unittest.TestCase):
'build_targets': ['foo_unittests']
})
+ def test_gn_analyze_new_logic(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: (
+ 0, 'out/Default/foo_unittests\n', '')
+
+ self.check(['analyze', '-c', 'gn_debug', '//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_unittests'],
+ 'test_targets': ['foo_unittests']
+ })
+
def test_gn_analyze_all(self):
files = {'/tmp/in.json': """{\
"files": ["foo/foo_unittest.cc"],
@@ -235,6 +255,24 @@ class UnitTest(unittest.TestCase):
'status': 'Found dependency (all)',
})
+ def test_gn_analyze_all_new_logic(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', '//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"],
@@ -256,6 +294,28 @@ class UnitTest(unittest.TestCase):
'status': 'No dependency',
})
+ def test_gn_analyze_missing_file_new_logic(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', '//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):
self.check(['gen', '-c', 'gn_debug', '//out/Default', '-g', '/goma'],
ret=0,
« tools/mb/docs/design_spec.md ('K') | « tools/mb/mb.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698