Remove reference to //base in mb_unittest.py
Also remove tests in //tools_webrtc/mb/mb_unittest.py that are testing exclusively code in //tools/mb/mb.py. Bug: webrtc:13662 Change-Id: Ifdfbe26c11f7c315e307856b1d3ab06483d57641 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/260041 Reviewed-by: Björn Terelius <terelius@webrtc.org> Commit-Queue: Jeremy Leconte <jleconte@google.com> Cr-Commit-Position: refs/heads/main@{#36651}
This commit is contained in:

committed by
WebRTC LUCI CQ

parent
cf01838790
commit
7c94291c58
@ -11,8 +11,6 @@
|
|||||||
"""Tests for mb.py."""
|
"""Tests for mb.py."""
|
||||||
|
|
||||||
import ast
|
import ast
|
||||||
import json
|
|
||||||
from io import StringIO # for Python3
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
@ -275,92 +273,17 @@ class UnitTest(unittest.TestCase):
|
|||||||
self.assertEqual(mbw.err, err)
|
self.assertEqual(mbw.err, err)
|
||||||
return mbw
|
return mbw
|
||||||
|
|
||||||
def test_analyze(self):
|
|
||||||
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"]
|
|
||||||
}'''
|
|
||||||
}
|
|
||||||
|
|
||||||
mbw = CreateFakeMBW(files)
|
|
||||||
mbw.Call = lambda cmd, env=None, buffer_output=True: (0, '', '')
|
|
||||||
|
|
||||||
self.check([
|
|
||||||
'analyze', '-c', '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'],
|
|
||||||
'test_targets': ['foo_unittests']
|
|
||||||
})
|
|
||||||
|
|
||||||
def test_gen(self):
|
|
||||||
mbw = CreateFakeMBW()
|
|
||||||
self.check(['gen', '-c', 'debug_goma', '//out/Default', '-g', '/goma'],
|
|
||||||
mbw=mbw,
|
|
||||||
ret=0)
|
|
||||||
self.assertMultiLineEqual(mbw.files['/fake_src/out/Default/args.gn'],
|
|
||||||
('goma_dir = "/goma"\n'
|
|
||||||
'is_debug = true\n'
|
|
||||||
'use_goma = true\n'))
|
|
||||||
|
|
||||||
# Make sure we log both what is written to args.gn and the command line.
|
|
||||||
self.assertIn('Writing """', mbw.out)
|
|
||||||
self.assertIn('/fake_src/buildtools/linux64/gn gen //out/Default --check',
|
|
||||||
mbw.out)
|
|
||||||
|
|
||||||
mbw = CreateFakeMBW(win32=True)
|
|
||||||
self.check(['gen', '-c', 'debug_goma', '-g', 'c:\\goma', '//out/Debug'],
|
|
||||||
mbw=mbw,
|
|
||||||
ret=0)
|
|
||||||
self.assertMultiLineEqual(mbw.files['c:\\fake_src\\out\\Debug\\args.gn'],
|
|
||||||
('goma_dir = "c:\\\\goma"\n'
|
|
||||||
'is_debug = true\n'
|
|
||||||
'use_goma = true\n'))
|
|
||||||
self.assertIn(
|
|
||||||
'c:\\fake_src\\buildtools\\win\\gn.exe gen //out/Debug '
|
|
||||||
'--check\n', mbw.out)
|
|
||||||
|
|
||||||
mbw = CreateFakeMBW()
|
|
||||||
self.check(
|
|
||||||
['gen', '-m', 'fake_group', '-b', 'fake_args_bot', '//out/Debug'],
|
|
||||||
mbw=mbw,
|
|
||||||
ret=0)
|
|
||||||
self.assertEqual(
|
|
||||||
mbw.files['/fake_src/out/Debug/args.gn'],
|
|
||||||
'import("//build/args/bots/fake_group/fake_args_bot.gn")\n\n')
|
|
||||||
|
|
||||||
def test_gen_fails(self):
|
|
||||||
mbw = CreateFakeMBW()
|
|
||||||
mbw.Call = lambda cmd, env=None, buffer_output=True: (1, '', '')
|
|
||||||
self.check(['gen', '-c', 'debug_goma', '//out/Default'], mbw=mbw, ret=1)
|
|
||||||
|
|
||||||
def test_gen_swarming(self):
|
def test_gen_swarming(self):
|
||||||
files = {
|
files = {
|
||||||
'/tmp/swarming_targets':
|
'/tmp/swarming_targets':
|
||||||
'base_unittests\n',
|
'foo_unittests\n',
|
||||||
'/fake_src/testing/buildbot/gn_isolate_map.pyl':
|
'/fake_src/testing/buildbot/gn_isolate_map.pyl':
|
||||||
("{'base_unittests': {"
|
("{'foo_unittests': {"
|
||||||
" 'label': '//base:base_unittests',"
|
" 'label': '//foo:foo_unittests',"
|
||||||
" 'type': 'raw',"
|
" 'type': 'raw',"
|
||||||
" 'args': [],"
|
" 'args': [],"
|
||||||
"}}\n"),
|
"}}\n"),
|
||||||
'/fake_src/out/Default/base_unittests.runtime_deps':
|
'/fake_src/out/Default/foo_unittests.runtime_deps': ("foo_unittests\n"),
|
||||||
("base_unittests\n"),
|
|
||||||
}
|
}
|
||||||
mbw = CreateFakeMBW(files)
|
mbw = CreateFakeMBW(files)
|
||||||
self.check([
|
self.check([
|
||||||
@ -369,21 +292,20 @@ class UnitTest(unittest.TestCase):
|
|||||||
],
|
],
|
||||||
mbw=mbw,
|
mbw=mbw,
|
||||||
ret=0)
|
ret=0)
|
||||||
self.assertIn('/fake_src/out/Default/base_unittests.isolate', mbw.files)
|
self.assertIn('/fake_src/out/Default/foo_unittests.isolate', mbw.files)
|
||||||
self.assertIn('/fake_src/out/Default/base_unittests.isolated.gen.json',
|
self.assertIn('/fake_src/out/Default/foo_unittests.isolated.gen.json',
|
||||||
mbw.files)
|
mbw.files)
|
||||||
|
|
||||||
def test_gen_swarming_android(self):
|
def test_gen_swarming_android(self):
|
||||||
test_files = {
|
test_files = {
|
||||||
'/tmp/swarming_targets':
|
'/tmp/swarming_targets':
|
||||||
'base_unittests\n',
|
'foo_unittests\n',
|
||||||
'/fake_src/testing/buildbot/gn_isolate_map.pyl':
|
'/fake_src/testing/buildbot/gn_isolate_map.pyl':
|
||||||
("{'base_unittests': {"
|
("{'foo_unittests': {"
|
||||||
" 'label': '//base:base_unittests',"
|
" 'label': '//foo:foo_unittests',"
|
||||||
" 'type': 'console_test_launcher',"
|
" 'type': 'console_test_launcher',"
|
||||||
"}}\n"),
|
"}}\n"),
|
||||||
'/fake_src/out/Default/base_unittests.runtime_deps':
|
'/fake_src/out/Default/foo_unittests.runtime_deps': ("foo_unittests\n"),
|
||||||
("base_unittests\n"),
|
|
||||||
}
|
}
|
||||||
mbw = self.check([
|
mbw = self.check([
|
||||||
'gen', '-c', 'android_bot', '//out/Default', '--swarming-targets-file',
|
'gen', '-c', 'android_bot', '//out/Default', '--swarming-targets-file',
|
||||||
@ -393,18 +315,19 @@ class UnitTest(unittest.TestCase):
|
|||||||
files=test_files,
|
files=test_files,
|
||||||
ret=0)
|
ret=0)
|
||||||
|
|
||||||
isolate_file = mbw.files['/fake_src/out/Default/base_unittests.isolate']
|
isolate_file = mbw.files['/fake_src/out/Default/foo_unittests.isolate']
|
||||||
isolate_file_contents = ast.literal_eval(isolate_file)
|
isolate_file_contents = ast.literal_eval(isolate_file)
|
||||||
files = isolate_file_contents['variables']['files']
|
files = isolate_file_contents['variables']['files']
|
||||||
command = isolate_file_contents['variables']['command']
|
command = isolate_file_contents['variables']['command']
|
||||||
|
|
||||||
self.assertEqual(files, ['../../.vpython3', '../../testing/test_env.py',
|
self.assertEqual(
|
||||||
'base_unittests'])
|
files,
|
||||||
|
['../../.vpython3', '../../testing/test_env.py', 'foo_unittests'])
|
||||||
self.assertEqual(command, [
|
self.assertEqual(command, [
|
||||||
'vpython3',
|
'vpython3',
|
||||||
'../../build/android/test_wrapper/logdog_wrapper.py',
|
'../../build/android/test_wrapper/logdog_wrapper.py',
|
||||||
'--target',
|
'--target',
|
||||||
'base_unittests',
|
'foo_unittests',
|
||||||
'--logdog-bin-cmd',
|
'--logdog-bin-cmd',
|
||||||
'../../bin/logdog_butler',
|
'../../bin/logdog_butler',
|
||||||
'--logcat-output-file',
|
'--logcat-output-file',
|
||||||
@ -415,14 +338,13 @@ class UnitTest(unittest.TestCase):
|
|||||||
def test_gen_swarming_android_junit_test(self):
|
def test_gen_swarming_android_junit_test(self):
|
||||||
test_files = {
|
test_files = {
|
||||||
'/tmp/swarming_targets':
|
'/tmp/swarming_targets':
|
||||||
'base_unittests\n',
|
'foo_unittests\n',
|
||||||
'/fake_src/testing/buildbot/gn_isolate_map.pyl':
|
'/fake_src/testing/buildbot/gn_isolate_map.pyl':
|
||||||
("{'base_unittests': {"
|
("{'foo_unittests': {"
|
||||||
" 'label': '//base:base_unittests',"
|
" 'label': '//foo:foo_unittests',"
|
||||||
" 'type': 'junit_test',"
|
" 'type': 'junit_test',"
|
||||||
"}}\n"),
|
"}}\n"),
|
||||||
'/fake_src/out/Default/base_unittests.runtime_deps':
|
'/fake_src/out/Default/foo_unittests.runtime_deps': ("foo_unittests\n"),
|
||||||
("base_unittests\n"),
|
|
||||||
}
|
}
|
||||||
mbw = self.check([
|
mbw = self.check([
|
||||||
'gen', '-c', 'android_bot', '//out/Default', '--swarming-targets-file',
|
'gen', '-c', 'android_bot', '//out/Default', '--swarming-targets-file',
|
||||||
@ -432,18 +354,19 @@ class UnitTest(unittest.TestCase):
|
|||||||
files=test_files,
|
files=test_files,
|
||||||
ret=0)
|
ret=0)
|
||||||
|
|
||||||
isolate_file = mbw.files['/fake_src/out/Default/base_unittests.isolate']
|
isolate_file = mbw.files['/fake_src/out/Default/foo_unittests.isolate']
|
||||||
isolate_file_contents = ast.literal_eval(isolate_file)
|
isolate_file_contents = ast.literal_eval(isolate_file)
|
||||||
files = isolate_file_contents['variables']['files']
|
files = isolate_file_contents['variables']['files']
|
||||||
command = isolate_file_contents['variables']['command']
|
command = isolate_file_contents['variables']['command']
|
||||||
|
|
||||||
self.assertEqual(files, ['../../.vpython3', '../../testing/test_env.py',
|
self.assertEqual(
|
||||||
'base_unittests'])
|
files,
|
||||||
|
['../../.vpython3', '../../testing/test_env.py', 'foo_unittests'])
|
||||||
self.assertEqual(command, [
|
self.assertEqual(command, [
|
||||||
'vpython3',
|
'vpython3',
|
||||||
'../../build/android/test_wrapper/logdog_wrapper.py',
|
'../../build/android/test_wrapper/logdog_wrapper.py',
|
||||||
'--target',
|
'--target',
|
||||||
'base_unittests',
|
'foo_unittests',
|
||||||
'--logdog-bin-cmd',
|
'--logdog-bin-cmd',
|
||||||
'../../bin/logdog_butler',
|
'../../bin/logdog_butler',
|
||||||
'--logcat-output-file',
|
'--logcat-output-file',
|
||||||
@ -454,15 +377,14 @@ class UnitTest(unittest.TestCase):
|
|||||||
def test_gen_timeout(self):
|
def test_gen_timeout(self):
|
||||||
test_files = {
|
test_files = {
|
||||||
'/tmp/swarming_targets':
|
'/tmp/swarming_targets':
|
||||||
'base_unittests\n',
|
'foo_unittests\n',
|
||||||
'/fake_src/testing/buildbot/gn_isolate_map.pyl':
|
'/fake_src/testing/buildbot/gn_isolate_map.pyl':
|
||||||
("{'base_unittests': {"
|
("{'foo_unittests': {"
|
||||||
" 'label': '//base:base_unittests',"
|
" 'label': '//foo:foo_unittests',"
|
||||||
" 'type': 'non_parallel_console_test_launcher',"
|
" 'type': 'non_parallel_console_test_launcher',"
|
||||||
" 'timeout': 500,"
|
" 'timeout': 500,"
|
||||||
"}}\n"),
|
"}}\n"),
|
||||||
'/fake_src/out/Default/base_unittests.runtime_deps':
|
'/fake_src/out/Default/foo_unittests.runtime_deps': ("foo_unittests\n"),
|
||||||
("base_unittests\n"),
|
|
||||||
}
|
}
|
||||||
mbw = self.check([
|
mbw = self.check([
|
||||||
'gen', '-c', 'debug_goma', '//out/Default', '--swarming-targets-file',
|
'gen', '-c', 'debug_goma', '//out/Default', '--swarming-targets-file',
|
||||||
@ -472,7 +394,7 @@ class UnitTest(unittest.TestCase):
|
|||||||
files=test_files,
|
files=test_files,
|
||||||
ret=0)
|
ret=0)
|
||||||
|
|
||||||
isolate_file = mbw.files['/fake_src/out/Default/base_unittests.isolate']
|
isolate_file = mbw.files['/fake_src/out/Default/foo_unittests.isolate']
|
||||||
isolate_file_contents = ast.literal_eval(isolate_file)
|
isolate_file_contents = ast.literal_eval(isolate_file)
|
||||||
files = isolate_file_contents['variables']['files']
|
files = isolate_file_contents['variables']['files']
|
||||||
command = isolate_file_contents['variables']['command']
|
command = isolate_file_contents['variables']['command']
|
||||||
@ -483,7 +405,7 @@ class UnitTest(unittest.TestCase):
|
|||||||
'../../third_party/gtest-parallel/gtest-parallel',
|
'../../third_party/gtest-parallel/gtest-parallel',
|
||||||
'../../third_party/gtest-parallel/gtest_parallel.py',
|
'../../third_party/gtest-parallel/gtest_parallel.py',
|
||||||
'../../tools_webrtc/gtest-parallel-wrapper.py',
|
'../../tools_webrtc/gtest-parallel-wrapper.py',
|
||||||
'base_unittests',
|
'foo_unittests',
|
||||||
])
|
])
|
||||||
self.assertEqual(command, [
|
self.assertEqual(command, [
|
||||||
'vpython3',
|
'vpython3',
|
||||||
@ -494,7 +416,7 @@ class UnitTest(unittest.TestCase):
|
|||||||
'--timeout=500',
|
'--timeout=500',
|
||||||
'--workers=1',
|
'--workers=1',
|
||||||
'--retry_failed=3',
|
'--retry_failed=3',
|
||||||
'./base_unittests',
|
'./foo_unittests',
|
||||||
'--asan=0',
|
'--asan=0',
|
||||||
'--lsan=0',
|
'--lsan=0',
|
||||||
'--msan=0',
|
'--msan=0',
|
||||||
@ -504,16 +426,16 @@ class UnitTest(unittest.TestCase):
|
|||||||
def test_gen_script(self):
|
def test_gen_script(self):
|
||||||
test_files = {
|
test_files = {
|
||||||
'/tmp/swarming_targets':
|
'/tmp/swarming_targets':
|
||||||
'base_unittests_script\n',
|
'foo_unittests_script\n',
|
||||||
'/fake_src/testing/buildbot/gn_isolate_map.pyl':
|
'/fake_src/testing/buildbot/gn_isolate_map.pyl':
|
||||||
("{'base_unittests_script': {"
|
("{'foo_unittests_script': {"
|
||||||
" 'label': '//base:base_unittests',"
|
" 'label': '//foo:foo_unittests',"
|
||||||
" 'type': 'script',"
|
" 'type': 'script',"
|
||||||
" 'script': '//base/base_unittests_script.py',"
|
" 'script': '//foo/foo_unittests_script.py',"
|
||||||
"}}\n"),
|
"}}\n"),
|
||||||
'/fake_src/out/Default/base_unittests_script.runtime_deps':
|
'/fake_src/out/Default/foo_unittests_script.runtime_deps':
|
||||||
("base_unittests\n"
|
("foo_unittests\n"
|
||||||
"base_unittests_script.py\n"),
|
"foo_unittests_script.py\n"),
|
||||||
}
|
}
|
||||||
mbw = self.check([
|
mbw = self.check([
|
||||||
'gen', '-c', 'debug_goma', '//out/Default', '--swarming-targets-file',
|
'gen', '-c', 'debug_goma', '//out/Default', '--swarming-targets-file',
|
||||||
@ -524,31 +446,32 @@ class UnitTest(unittest.TestCase):
|
|||||||
ret=0)
|
ret=0)
|
||||||
|
|
||||||
isolate_file = (
|
isolate_file = (
|
||||||
mbw.files['/fake_src/out/Default/base_unittests_script.isolate'])
|
mbw.files['/fake_src/out/Default/foo_unittests_script.isolate'])
|
||||||
isolate_file_contents = ast.literal_eval(isolate_file)
|
isolate_file_contents = ast.literal_eval(isolate_file)
|
||||||
files = isolate_file_contents['variables']['files']
|
files = isolate_file_contents['variables']['files']
|
||||||
command = isolate_file_contents['variables']['command']
|
command = isolate_file_contents['variables']['command']
|
||||||
|
|
||||||
self.assertEqual(files, [
|
self.assertEqual(files, [
|
||||||
'../../.vpython3', '../../testing/test_env.py',
|
'../../.vpython3',
|
||||||
'base_unittests', 'base_unittests_script.py',
|
'../../testing/test_env.py',
|
||||||
|
'foo_unittests',
|
||||||
|
'foo_unittests_script.py',
|
||||||
])
|
])
|
||||||
self.assertEqual(command, [
|
self.assertEqual(command, [
|
||||||
'vpython3',
|
'vpython3',
|
||||||
'../../base/base_unittests_script.py',
|
'../../foo/foo_unittests_script.py',
|
||||||
])
|
])
|
||||||
|
|
||||||
def test_gen_raw(self):
|
def test_gen_raw(self):
|
||||||
test_files = {
|
test_files = {
|
||||||
'/tmp/swarming_targets':
|
'/tmp/swarming_targets':
|
||||||
'base_unittests\n',
|
'foo_unittests\n',
|
||||||
'/fake_src/testing/buildbot/gn_isolate_map.pyl':
|
'/fake_src/testing/buildbot/gn_isolate_map.pyl':
|
||||||
("{'base_unittests': {"
|
("{'foo_unittests': {"
|
||||||
" 'label': '//base:base_unittests',"
|
" 'label': '//foo:foo_unittests',"
|
||||||
" 'type': 'raw',"
|
" 'type': 'raw',"
|
||||||
"}}\n"),
|
"}}\n"),
|
||||||
'/fake_src/out/Default/base_unittests.runtime_deps':
|
'/fake_src/out/Default/foo_unittests.runtime_deps': ("foo_unittests\n"),
|
||||||
("base_unittests\n"),
|
|
||||||
}
|
}
|
||||||
mbw = self.check([
|
mbw = self.check([
|
||||||
'gen', '-c', 'debug_goma', '//out/Default', '--swarming-targets-file',
|
'gen', '-c', 'debug_goma', '//out/Default', '--swarming-targets-file',
|
||||||
@ -558,7 +481,7 @@ class UnitTest(unittest.TestCase):
|
|||||||
files=test_files,
|
files=test_files,
|
||||||
ret=0)
|
ret=0)
|
||||||
|
|
||||||
isolate_file = mbw.files['/fake_src/out/Default/base_unittests.isolate']
|
isolate_file = mbw.files['/fake_src/out/Default/foo_unittests.isolate']
|
||||||
isolate_file_contents = ast.literal_eval(isolate_file)
|
isolate_file_contents = ast.literal_eval(isolate_file)
|
||||||
files = isolate_file_contents['variables']['files']
|
files = isolate_file_contents['variables']['files']
|
||||||
command = isolate_file_contents['variables']['command']
|
command = isolate_file_contents['variables']['command']
|
||||||
@ -567,25 +490,24 @@ class UnitTest(unittest.TestCase):
|
|||||||
'../../.vpython3',
|
'../../.vpython3',
|
||||||
'../../testing/test_env.py',
|
'../../testing/test_env.py',
|
||||||
'../../tools_webrtc/flags_compatibility.py',
|
'../../tools_webrtc/flags_compatibility.py',
|
||||||
'base_unittests',
|
'foo_unittests',
|
||||||
])
|
])
|
||||||
self.assertEqual(command, [
|
self.assertEqual(command, [
|
||||||
'vpython3',
|
'vpython3',
|
||||||
'../../tools_webrtc/flags_compatibility.py',
|
'../../tools_webrtc/flags_compatibility.py',
|
||||||
'./base_unittests',
|
'./foo_unittests',
|
||||||
])
|
])
|
||||||
|
|
||||||
def test_gen_non_parallel_console_test_launcher(self):
|
def test_gen_non_parallel_console_test_launcher(self):
|
||||||
test_files = {
|
test_files = {
|
||||||
'/tmp/swarming_targets':
|
'/tmp/swarming_targets':
|
||||||
'base_unittests\n',
|
'foo_unittests\n',
|
||||||
'/fake_src/testing/buildbot/gn_isolate_map.pyl':
|
'/fake_src/testing/buildbot/gn_isolate_map.pyl':
|
||||||
("{'base_unittests': {"
|
("{'foo_unittests': {"
|
||||||
" 'label': '//base:base_unittests',"
|
" 'label': '//foo:foo_unittests',"
|
||||||
" 'type': 'non_parallel_console_test_launcher',"
|
" 'type': 'non_parallel_console_test_launcher',"
|
||||||
"}}\n"),
|
"}}\n"),
|
||||||
'/fake_src/out/Default/base_unittests.runtime_deps':
|
'/fake_src/out/Default/foo_unittests.runtime_deps': ("foo_unittests\n"),
|
||||||
("base_unittests\n"),
|
|
||||||
}
|
}
|
||||||
mbw = self.check([
|
mbw = self.check([
|
||||||
'gen', '-c', 'debug_goma', '//out/Default', '--swarming-targets-file',
|
'gen', '-c', 'debug_goma', '//out/Default', '--swarming-targets-file',
|
||||||
@ -595,7 +517,7 @@ class UnitTest(unittest.TestCase):
|
|||||||
files=test_files,
|
files=test_files,
|
||||||
ret=0)
|
ret=0)
|
||||||
|
|
||||||
isolate_file = mbw.files['/fake_src/out/Default/base_unittests.isolate']
|
isolate_file = mbw.files['/fake_src/out/Default/foo_unittests.isolate']
|
||||||
isolate_file_contents = ast.literal_eval(isolate_file)
|
isolate_file_contents = ast.literal_eval(isolate_file)
|
||||||
files = isolate_file_contents['variables']['files']
|
files = isolate_file_contents['variables']['files']
|
||||||
command = isolate_file_contents['variables']['command']
|
command = isolate_file_contents['variables']['command']
|
||||||
@ -606,7 +528,7 @@ class UnitTest(unittest.TestCase):
|
|||||||
'../../third_party/gtest-parallel/gtest-parallel',
|
'../../third_party/gtest-parallel/gtest-parallel',
|
||||||
'../../third_party/gtest-parallel/gtest_parallel.py',
|
'../../third_party/gtest-parallel/gtest_parallel.py',
|
||||||
'../../tools_webrtc/gtest-parallel-wrapper.py',
|
'../../tools_webrtc/gtest-parallel-wrapper.py',
|
||||||
'base_unittests',
|
'foo_unittests',
|
||||||
])
|
])
|
||||||
self.assertEqual(command, [
|
self.assertEqual(command, [
|
||||||
'vpython3',
|
'vpython3',
|
||||||
@ -617,7 +539,7 @@ class UnitTest(unittest.TestCase):
|
|||||||
'--timeout=900',
|
'--timeout=900',
|
||||||
'--workers=1',
|
'--workers=1',
|
||||||
'--retry_failed=3',
|
'--retry_failed=3',
|
||||||
'./base_unittests',
|
'./foo_unittests',
|
||||||
'--asan=0',
|
'--asan=0',
|
||||||
'--lsan=0',
|
'--lsan=0',
|
||||||
'--msan=0',
|
'--msan=0',
|
||||||
@ -627,14 +549,14 @@ class UnitTest(unittest.TestCase):
|
|||||||
def test_isolate_windowed_test_launcher_linux(self):
|
def test_isolate_windowed_test_launcher_linux(self):
|
||||||
test_files = {
|
test_files = {
|
||||||
'/tmp/swarming_targets':
|
'/tmp/swarming_targets':
|
||||||
'base_unittests\n',
|
'foo_unittests\n',
|
||||||
'/fake_src/testing/buildbot/gn_isolate_map.pyl':
|
'/fake_src/testing/buildbot/gn_isolate_map.pyl':
|
||||||
("{'base_unittests': {"
|
("{'foo_unittests': {"
|
||||||
" 'label': '//base:base_unittests',"
|
" 'label': '//foo:foo_unittests',"
|
||||||
" 'type': 'windowed_test_launcher',"
|
" 'type': 'windowed_test_launcher',"
|
||||||
"}}\n"),
|
"}}\n"),
|
||||||
'/fake_src/out/Default/base_unittests.runtime_deps':
|
'/fake_src/out/Default/foo_unittests.runtime_deps':
|
||||||
("base_unittests\n"
|
("foo_unittests\n"
|
||||||
"some_resource_file\n"),
|
"some_resource_file\n"),
|
||||||
}
|
}
|
||||||
mbw = self.check([
|
mbw = self.check([
|
||||||
@ -645,7 +567,7 @@ class UnitTest(unittest.TestCase):
|
|||||||
files=test_files,
|
files=test_files,
|
||||||
ret=0)
|
ret=0)
|
||||||
|
|
||||||
isolate_file = mbw.files['/fake_src/out/Default/base_unittests.isolate']
|
isolate_file = mbw.files['/fake_src/out/Default/foo_unittests.isolate']
|
||||||
isolate_file_contents = ast.literal_eval(isolate_file)
|
isolate_file_contents = ast.literal_eval(isolate_file)
|
||||||
files = isolate_file_contents['variables']['files']
|
files = isolate_file_contents['variables']['files']
|
||||||
command = isolate_file_contents['variables']['command']
|
command = isolate_file_contents['variables']['command']
|
||||||
@ -657,7 +579,7 @@ class UnitTest(unittest.TestCase):
|
|||||||
'../../third_party/gtest-parallel/gtest-parallel',
|
'../../third_party/gtest-parallel/gtest-parallel',
|
||||||
'../../third_party/gtest-parallel/gtest_parallel.py',
|
'../../third_party/gtest-parallel/gtest_parallel.py',
|
||||||
'../../tools_webrtc/gtest-parallel-wrapper.py',
|
'../../tools_webrtc/gtest-parallel-wrapper.py',
|
||||||
'base_unittests',
|
'foo_unittests',
|
||||||
'some_resource_file',
|
'some_resource_file',
|
||||||
])
|
])
|
||||||
self.assertEqual(command, [
|
self.assertEqual(command, [
|
||||||
@ -668,7 +590,7 @@ class UnitTest(unittest.TestCase):
|
|||||||
'--gtest_color=no',
|
'--gtest_color=no',
|
||||||
'--timeout=900',
|
'--timeout=900',
|
||||||
'--retry_failed=3',
|
'--retry_failed=3',
|
||||||
'./base_unittests',
|
'./foo_unittests',
|
||||||
'--asan=0',
|
'--asan=0',
|
||||||
'--lsan=0',
|
'--lsan=0',
|
||||||
'--msan=0',
|
'--msan=0',
|
||||||
@ -730,14 +652,13 @@ class UnitTest(unittest.TestCase):
|
|||||||
def test_gen_console_test_launcher(self):
|
def test_gen_console_test_launcher(self):
|
||||||
test_files = {
|
test_files = {
|
||||||
'/tmp/swarming_targets':
|
'/tmp/swarming_targets':
|
||||||
'base_unittests\n',
|
'foo_unittests\n',
|
||||||
'/fake_src/testing/buildbot/gn_isolate_map.pyl':
|
'/fake_src/testing/buildbot/gn_isolate_map.pyl':
|
||||||
("{'base_unittests': {"
|
("{'foo_unittests': {"
|
||||||
" 'label': '//base:base_unittests',"
|
" 'label': '//foo:foo_unittests',"
|
||||||
" 'type': 'console_test_launcher',"
|
" 'type': 'console_test_launcher',"
|
||||||
"}}\n"),
|
"}}\n"),
|
||||||
'/fake_src/out/Default/base_unittests.runtime_deps':
|
'/fake_src/out/Default/foo_unittests.runtime_deps': ("foo_unittests\n"),
|
||||||
("base_unittests\n"),
|
|
||||||
}
|
}
|
||||||
mbw = self.check([
|
mbw = self.check([
|
||||||
'gen', '-c', 'debug_goma', '//out/Default', '--swarming-targets-file',
|
'gen', '-c', 'debug_goma', '//out/Default', '--swarming-targets-file',
|
||||||
@ -747,7 +668,7 @@ class UnitTest(unittest.TestCase):
|
|||||||
files=test_files,
|
files=test_files,
|
||||||
ret=0)
|
ret=0)
|
||||||
|
|
||||||
isolate_file = mbw.files['/fake_src/out/Default/base_unittests.isolate']
|
isolate_file = mbw.files['/fake_src/out/Default/foo_unittests.isolate']
|
||||||
isolate_file_contents = ast.literal_eval(isolate_file)
|
isolate_file_contents = ast.literal_eval(isolate_file)
|
||||||
files = isolate_file_contents['variables']['files']
|
files = isolate_file_contents['variables']['files']
|
||||||
command = isolate_file_contents['variables']['command']
|
command = isolate_file_contents['variables']['command']
|
||||||
@ -758,7 +679,7 @@ class UnitTest(unittest.TestCase):
|
|||||||
'../../third_party/gtest-parallel/gtest-parallel',
|
'../../third_party/gtest-parallel/gtest-parallel',
|
||||||
'../../third_party/gtest-parallel/gtest_parallel.py',
|
'../../third_party/gtest-parallel/gtest_parallel.py',
|
||||||
'../../tools_webrtc/gtest-parallel-wrapper.py',
|
'../../tools_webrtc/gtest-parallel-wrapper.py',
|
||||||
'base_unittests',
|
'foo_unittests',
|
||||||
])
|
])
|
||||||
self.assertEqual(command, [
|
self.assertEqual(command, [
|
||||||
'vpython3',
|
'vpython3',
|
||||||
@ -768,7 +689,7 @@ class UnitTest(unittest.TestCase):
|
|||||||
'--gtest_color=no',
|
'--gtest_color=no',
|
||||||
'--timeout=900',
|
'--timeout=900',
|
||||||
'--retry_failed=3',
|
'--retry_failed=3',
|
||||||
'./base_unittests',
|
'./foo_unittests',
|
||||||
'--asan=0',
|
'--asan=0',
|
||||||
'--lsan=0',
|
'--lsan=0',
|
||||||
'--msan=0',
|
'--msan=0',
|
||||||
@ -778,15 +699,15 @@ class UnitTest(unittest.TestCase):
|
|||||||
def test_isolate_test_launcher_with_webcam(self):
|
def test_isolate_test_launcher_with_webcam(self):
|
||||||
test_files = {
|
test_files = {
|
||||||
'/tmp/swarming_targets':
|
'/tmp/swarming_targets':
|
||||||
'base_unittests\n',
|
'foo_unittests\n',
|
||||||
'/fake_src/testing/buildbot/gn_isolate_map.pyl':
|
'/fake_src/testing/buildbot/gn_isolate_map.pyl':
|
||||||
("{'base_unittests': {"
|
("{'foo_unittests': {"
|
||||||
" 'label': '//base:base_unittests',"
|
" 'label': '//foo:foo_unittests',"
|
||||||
" 'type': 'console_test_launcher',"
|
" 'type': 'console_test_launcher',"
|
||||||
" 'use_webcam': True,"
|
" 'use_webcam': True,"
|
||||||
"}}\n"),
|
"}}\n"),
|
||||||
'/fake_src/out/Default/base_unittests.runtime_deps':
|
'/fake_src/out/Default/foo_unittests.runtime_deps':
|
||||||
("base_unittests\n"
|
("foo_unittests\n"
|
||||||
"some_resource_file\n"),
|
"some_resource_file\n"),
|
||||||
}
|
}
|
||||||
mbw = self.check([
|
mbw = self.check([
|
||||||
@ -797,7 +718,7 @@ class UnitTest(unittest.TestCase):
|
|||||||
files=test_files,
|
files=test_files,
|
||||||
ret=0)
|
ret=0)
|
||||||
|
|
||||||
isolate_file = mbw.files['/fake_src/out/Default/base_unittests.isolate']
|
isolate_file = mbw.files['/fake_src/out/Default/foo_unittests.isolate']
|
||||||
isolate_file_contents = ast.literal_eval(isolate_file)
|
isolate_file_contents = ast.literal_eval(isolate_file)
|
||||||
files = isolate_file_contents['variables']['files']
|
files = isolate_file_contents['variables']['files']
|
||||||
command = isolate_file_contents['variables']['command']
|
command = isolate_file_contents['variables']['command']
|
||||||
@ -809,7 +730,7 @@ class UnitTest(unittest.TestCase):
|
|||||||
'../../third_party/gtest-parallel/gtest_parallel.py',
|
'../../third_party/gtest-parallel/gtest_parallel.py',
|
||||||
'../../tools_webrtc/ensure_webcam_is_running.py',
|
'../../tools_webrtc/ensure_webcam_is_running.py',
|
||||||
'../../tools_webrtc/gtest-parallel-wrapper.py',
|
'../../tools_webrtc/gtest-parallel-wrapper.py',
|
||||||
'base_unittests',
|
'foo_unittests',
|
||||||
'some_resource_file',
|
'some_resource_file',
|
||||||
])
|
])
|
||||||
self.assertEqual(command, [
|
self.assertEqual(command, [
|
||||||
@ -822,7 +743,7 @@ class UnitTest(unittest.TestCase):
|
|||||||
'--gtest_color=no',
|
'--gtest_color=no',
|
||||||
'--timeout=900',
|
'--timeout=900',
|
||||||
'--retry_failed=3',
|
'--retry_failed=3',
|
||||||
'./base_unittests',
|
'./foo_unittests',
|
||||||
'--asan=0',
|
'--asan=0',
|
||||||
'--lsan=0',
|
'--lsan=0',
|
||||||
'--msan=0',
|
'--msan=0',
|
||||||
@ -834,160 +755,26 @@ class UnitTest(unittest.TestCase):
|
|||||||
'/fake_src/out/Default/toolchain.ninja':
|
'/fake_src/out/Default/toolchain.ninja':
|
||||||
"",
|
"",
|
||||||
'/fake_src/testing/buildbot/gn_isolate_map.pyl':
|
'/fake_src/testing/buildbot/gn_isolate_map.pyl':
|
||||||
("{'base_unittests': {"
|
("{'foo_unittests': {"
|
||||||
" 'label': '//base:base_unittests',"
|
" 'label': '//foo:foo_unittests',"
|
||||||
" 'type': 'non_parallel_console_test_launcher',"
|
" 'type': 'non_parallel_console_test_launcher',"
|
||||||
"}}\n"),
|
"}}\n"),
|
||||||
'/fake_src/out/Default/base_unittests.runtime_deps':
|
'/fake_src/out/Default/foo_unittests.runtime_deps': ("foo_unittests\n"),
|
||||||
("base_unittests\n"),
|
|
||||||
}
|
}
|
||||||
self.check(
|
self.check(
|
||||||
['isolate', '-c', 'debug_goma', '//out/Default', 'base_unittests'],
|
['isolate', '-c', 'debug_goma', '//out/Default', 'foo_unittests'],
|
||||||
files=files,
|
files=files,
|
||||||
ret=0)
|
ret=0)
|
||||||
|
|
||||||
# test running isolate on an existing build_dir
|
# test running isolate on an existing build_dir
|
||||||
files['/fake_src/out/Default/args.gn'] = 'is_debug = true\n'
|
files['/fake_src/out/Default/args.gn'] = 'is_debug = true\n'
|
||||||
self.check(['isolate', '//out/Default', 'base_unittests'],
|
self.check(['isolate', '//out/Default', 'foo_unittests'],
|
||||||
files=files,
|
files=files,
|
||||||
ret=0)
|
ret=0)
|
||||||
files['/fake_src/out/Default/mb_type'] = 'gn\n'
|
files['/fake_src/out/Default/mb_type'] = 'gn\n'
|
||||||
self.check(['isolate', '//out/Default', 'base_unittests'],
|
self.check(['isolate', '//out/Default', 'foo_unittests'],
|
||||||
files=files,
|
files=files,
|
||||||
ret=0)
|
ret=0)
|
||||||
|
|
||||||
def test_run(self):
|
|
||||||
files = {
|
|
||||||
'/fake_src/testing/buildbot/gn_isolate_map.pyl':
|
|
||||||
("{'base_unittests': {"
|
|
||||||
" 'label': '//base:base_unittests',"
|
|
||||||
" 'type': 'windowed_test_launcher',"
|
|
||||||
"}}\n"),
|
|
||||||
'/fake_src/out/Default/base_unittests.runtime_deps':
|
|
||||||
("base_unittests\n"),
|
|
||||||
}
|
|
||||||
self.check(['run', '-c', 'debug_goma', '//out/Default', 'base_unittests'],
|
|
||||||
files=files,
|
|
||||||
ret=0)
|
|
||||||
|
|
||||||
def test_run_swarmed(self):
|
|
||||||
# pylint: disable=attribute-defined-outside-init
|
|
||||||
files = {
|
|
||||||
'/fake_src/testing/buildbot/gn_isolate_map.pyl':
|
|
||||||
("{'base_unittests': {"
|
|
||||||
" 'label': '//base:base_unittests',"
|
|
||||||
" 'type': 'console_test_launcher',"
|
|
||||||
"}}\n"),
|
|
||||||
'/fake_src/out/Default/base_unittests.runtime_deps':
|
|
||||||
("base_unittests\n"),
|
|
||||||
'/fake_src/out/Default/base_unittests.archive.json':
|
|
||||||
("{\"base_unittests\":\"fake_hash\"}"),
|
|
||||||
'/fake_src/third_party/depot_tools/cipd_manifest.txt':
|
|
||||||
("# vpython3\n"
|
|
||||||
"/some/vpython3/pkg git_revision:deadbeef\n"),
|
|
||||||
}
|
|
||||||
task_json = json.dumps({'tasks': [{'task_id': '00000'}]})
|
|
||||||
collect_json = json.dumps({'00000': {'results': {}}})
|
|
||||||
|
|
||||||
mbw = CreateFakeMBW(files=files)
|
|
||||||
mbw.files[mbw.PathJoin(mbw.TempDir(), 'task.json')] = task_json
|
|
||||||
mbw.files[mbw.PathJoin(mbw.TempDir(), 'collect_output.json')] = collect_json
|
|
||||||
original_impl = mbw.ToSrcRelPath
|
|
||||||
|
|
||||||
def to_src_rel_path_stub(path):
|
|
||||||
if path.endswith('base_unittests.archive.json'):
|
|
||||||
return 'base_unittests.archive.json'
|
|
||||||
return original_impl(path)
|
|
||||||
|
|
||||||
mbw.ToSrcRelPath = to_src_rel_path_stub
|
|
||||||
|
|
||||||
self.check(
|
|
||||||
['run', '-s', '-c', 'debug_goma', '//out/Default', 'base_unittests'],
|
|
||||||
mbw=mbw,
|
|
||||||
ret=0)
|
|
||||||
mbw = CreateFakeMBW(files=files)
|
|
||||||
mbw.files[mbw.PathJoin(mbw.TempDir(), 'task.json')] = task_json
|
|
||||||
mbw.files[mbw.PathJoin(mbw.TempDir(), 'collect_output.json')] = collect_json
|
|
||||||
mbw.ToSrcRelPath = to_src_rel_path_stub
|
|
||||||
self.check([
|
|
||||||
'run', '-s', '-c', 'debug_goma', '-d', 'os', 'Win7', '//out/Default',
|
|
||||||
'base_unittests'
|
|
||||||
],
|
|
||||||
mbw=mbw,
|
|
||||||
ret=0)
|
|
||||||
|
|
||||||
def test_lookup(self):
|
|
||||||
self.check(['lookup', '-c', 'debug_goma'], ret=0)
|
|
||||||
|
|
||||||
def test_quiet_lookup(self):
|
|
||||||
self.check(['lookup', '-c', 'debug_goma', '--quiet'],
|
|
||||||
ret=0,
|
|
||||||
out=('is_debug = true\n'
|
|
||||||
'use_goma = true\n'))
|
|
||||||
|
|
||||||
def test_lookup_goma_dir_expansion(self):
|
|
||||||
self.check(['lookup', '-c', 'rel_bot', '-g', '/foo'],
|
|
||||||
ret=0,
|
|
||||||
out=('\n'
|
|
||||||
'Writing """\\\n'
|
|
||||||
'dcheck_always_on = false\n'
|
|
||||||
'enable_doom_melon = true\n'
|
|
||||||
'goma_dir = "/foo"\n'
|
|
||||||
'is_debug = false\n'
|
|
||||||
'use_goma = true\n'
|
|
||||||
'""" to _path_/args.gn.\n\n'
|
|
||||||
'/fake_src/buildtools/linux64/gn gen _path_\n'))
|
|
||||||
|
|
||||||
def test_help(self):
|
|
||||||
orig_stdout = sys.stdout
|
|
||||||
try:
|
|
||||||
sys.stdout = StringIO()
|
|
||||||
self.assertRaises(SystemExit, self.check, ['-h'])
|
|
||||||
self.assertRaises(SystemExit, self.check, ['help'])
|
|
||||||
self.assertRaises(SystemExit, self.check, ['help', 'gen'])
|
|
||||||
finally:
|
|
||||||
sys.stdout = orig_stdout
|
|
||||||
|
|
||||||
def test_multiple_phases(self):
|
|
||||||
# Check that not passing a --phase to a multi-phase builder fails.
|
|
||||||
mbw = self.check(['lookup', '-m', 'fake_group', '-b', 'fake_multi_phase'],
|
|
||||||
ret=1)
|
|
||||||
self.assertIn('Must specify a build --phase', mbw.out)
|
|
||||||
|
|
||||||
# Check that passing a --phase to a single-phase builder fails.
|
|
||||||
mbw = self.check([
|
|
||||||
'lookup', '-m', 'fake_group', '-b', 'fake_builder', '--phase', 'phase_1'
|
|
||||||
],
|
|
||||||
ret=1)
|
|
||||||
self.assertIn('Must not specify a build --phase', mbw.out)
|
|
||||||
|
|
||||||
# Check that passing a wrong phase key to a multi-phase builder fails.
|
|
||||||
mbw = self.check([
|
|
||||||
'lookup', '-m', 'fake_group', '-b', 'fake_multi_phase', '--phase',
|
|
||||||
'wrong_phase'
|
|
||||||
],
|
|
||||||
ret=1)
|
|
||||||
self.assertIn('Phase wrong_phase doesn\'t exist', mbw.out)
|
|
||||||
|
|
||||||
# Check that passing a correct phase key to a multi-phase builder passes.
|
|
||||||
mbw = self.check([
|
|
||||||
'lookup', '-m', 'fake_group', '-b', 'fake_multi_phase', '--phase',
|
|
||||||
'phase_1'
|
|
||||||
],
|
|
||||||
ret=0)
|
|
||||||
self.assertIn('phase = 1', mbw.out)
|
|
||||||
|
|
||||||
mbw = self.check([
|
|
||||||
'lookup', '-m', 'fake_group', '-b', 'fake_multi_phase', '--phase',
|
|
||||||
'phase_2'
|
|
||||||
],
|
|
||||||
ret=0)
|
|
||||||
self.assertIn('phase = 2', mbw.out)
|
|
||||||
|
|
||||||
def test_validate(self):
|
|
||||||
mbw = CreateFakeMBW()
|
|
||||||
self.check(['validate'], mbw=mbw, ret=0)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
Reference in New Issue
Block a user