Add mb.py to pylint check of the root PRESUBMIT.py.
This now possible because of https://webrtc-review.googlesource.com/c/src/+/256972 Bug: webrtc:13605 Change-Id: Ie5c058c5ff459dde05c90f757a1df8bd53f35ccc Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/257281 Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Christoffer Jansson <jansson@google.com> Commit-Queue: Jeremy Leconte <jleconte@google.com> Cr-Commit-Position: refs/heads/main@{#36390}
This commit is contained in:

committed by
WebRTC LUCI CQ

parent
7b26037693
commit
ac5cf78801
@ -937,8 +937,6 @@ def CommonChecks(input_api, output_api):
|
|||||||
r'^testing[\\\/].*\.py$',
|
r'^testing[\\\/].*\.py$',
|
||||||
r'^third_party[\\\/].*\.py$',
|
r'^third_party[\\\/].*\.py$',
|
||||||
r'^tools[\\\/].*\.py$',
|
r'^tools[\\\/].*\.py$',
|
||||||
# TODO(bugs.webrtc.org/13605): should arguably be checked.
|
|
||||||
r'^tools_webrtc[\\\/]mb[\\\/].*\.py$',
|
|
||||||
r'^xcodebuild.*[\\\/].*\.py$',
|
r'^xcodebuild.*[\\\/].*\.py$',
|
||||||
),
|
),
|
||||||
pylintrc='pylintrc',
|
pylintrc='pylintrc',
|
||||||
|
@ -16,22 +16,6 @@ USE_PYTHON3 = True
|
|||||||
def _CommonChecks(input_api, output_api):
|
def _CommonChecks(input_api, output_api):
|
||||||
results = []
|
results = []
|
||||||
|
|
||||||
# Run Pylint over the files in the directory.
|
|
||||||
pylint_checks = input_api.canned_checks.GetPylint(
|
|
||||||
input_api,
|
|
||||||
output_api,
|
|
||||||
version='2.7',
|
|
||||||
# Disabling certain python3-specific warnings until the conversion
|
|
||||||
# is complete.
|
|
||||||
disabled_warnings=[
|
|
||||||
'super-with-arguments',
|
|
||||||
'raise-missing-from',
|
|
||||||
'useless-object-inheritance',
|
|
||||||
'arguments-differ',
|
|
||||||
],
|
|
||||||
)
|
|
||||||
results.extend(input_api.RunTests(pylint_checks))
|
|
||||||
|
|
||||||
# Run the MB unittests.
|
# Run the MB unittests.
|
||||||
results.extend(
|
results.extend(
|
||||||
input_api.canned_checks.RunUnitTestsInDirectory(input_api,
|
input_api.canned_checks.RunUnitTestsInDirectory(input_api,
|
||||||
|
@ -24,7 +24,7 @@ sys.path.insert(0, _SRC_DIR)
|
|||||||
from tools.mb import mb
|
from tools.mb import mb
|
||||||
|
|
||||||
|
|
||||||
def _get_executable(target, platform):
|
def _GetExecutable(target, platform):
|
||||||
executable_prefix = '.\\' if platform == 'win32' else './'
|
executable_prefix = '.\\' if platform == 'win32' else './'
|
||||||
executable_suffix = '.exe' if platform == 'win32' else ''
|
executable_suffix = '.exe' if platform == 'win32' else ''
|
||||||
return executable_prefix + target + executable_suffix
|
return executable_prefix + target + executable_suffix
|
||||||
@ -37,7 +37,7 @@ def main(args):
|
|||||||
|
|
||||||
class WebRTCMetaBuildWrapper(mb.MetaBuildWrapper):
|
class WebRTCMetaBuildWrapper(mb.MetaBuildWrapper):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(WebRTCMetaBuildWrapper, self).__init__()
|
super().__init__()
|
||||||
# Make sure default_config and default_isolate_map are attributes of the
|
# Make sure default_config and default_isolate_map are attributes of the
|
||||||
# parent class before changing their values.
|
# parent class before changing their values.
|
||||||
# pylint: disable=access-member-before-definition
|
# pylint: disable=access-member-before-definition
|
||||||
@ -93,7 +93,7 @@ class WebRTCMetaBuildWrapper(mb.MetaBuildWrapper):
|
|||||||
elif test_type == 'raw':
|
elif test_type == 'raw':
|
||||||
cmdline += [vpython_exe, '../../tools_webrtc/flags_compatibility.py']
|
cmdline += [vpython_exe, '../../tools_webrtc/flags_compatibility.py']
|
||||||
extra_files.append('../../tools_webrtc/flags_compatibility.py')
|
extra_files.append('../../tools_webrtc/flags_compatibility.py')
|
||||||
cmdline.append(_get_executable(target, self.platform))
|
cmdline.append(_GetExecutable(target, self.platform))
|
||||||
else:
|
else:
|
||||||
if isolate_map[target].get('use_webcam', False):
|
if isolate_map[target].get('use_webcam', False):
|
||||||
cmdline += [
|
cmdline += [
|
||||||
@ -144,7 +144,7 @@ class WebRTCMetaBuildWrapper(mb.MetaBuildWrapper):
|
|||||||
# Retry would hide most sanitizers detections.
|
# Retry would hide most sanitizers detections.
|
||||||
cmdline.append('--retry_failed=3')
|
cmdline.append('--retry_failed=3')
|
||||||
|
|
||||||
cmdline.append(_get_executable(target, self.platform))
|
cmdline.append(_GetExecutable(target, self.platform))
|
||||||
|
|
||||||
cmdline.extend([
|
cmdline.extend([
|
||||||
'--asan=%d' % asan,
|
'--asan=%d' % asan,
|
||||||
|
@ -28,7 +28,7 @@ from tools_webrtc.mb import mb
|
|||||||
|
|
||||||
class FakeMBW(mb.WebRTCMetaBuildWrapper):
|
class FakeMBW(mb.WebRTCMetaBuildWrapper):
|
||||||
def __init__(self, win32=False):
|
def __init__(self, win32=False):
|
||||||
super(FakeMBW, self).__init__()
|
super().__init__()
|
||||||
|
|
||||||
# Override vars for test portability.
|
# Override vars for test portability.
|
||||||
if win32:
|
if win32:
|
||||||
@ -63,7 +63,7 @@ class FakeMBW(mb.WebRTCMetaBuildWrapper):
|
|||||||
|
|
||||||
def Exists(self, path):
|
def Exists(self, path):
|
||||||
abs_path = self._AbsPath(path)
|
abs_path = self._AbsPath(path)
|
||||||
return (self.files.get(abs_path) is not None or abs_path in self.dirs)
|
return self.files.get(abs_path) is not None or abs_path in self.dirs
|
||||||
|
|
||||||
def ListDir(self, path):
|
def ListDir(self, path):
|
||||||
dir_contents = []
|
dir_contents = []
|
||||||
@ -83,8 +83,8 @@ class FakeMBW(mb.WebRTCMetaBuildWrapper):
|
|||||||
def ReadFile(self, path):
|
def ReadFile(self, path):
|
||||||
try:
|
try:
|
||||||
return self.files[self._AbsPath(path)]
|
return self.files[self._AbsPath(path)]
|
||||||
except KeyError:
|
except KeyError as e:
|
||||||
raise IOError('%s not found' % path)
|
raise IOError('%s not found' % path) from e
|
||||||
|
|
||||||
def WriteFile(self, path, contents, force_verbose=False):
|
def WriteFile(self, path, contents, force_verbose=False):
|
||||||
if self.args.dryrun or self.args.verbose or force_verbose:
|
if self.args.dryrun or self.args.verbose or force_verbose:
|
||||||
@ -141,7 +141,8 @@ class FakeMBW(mb.WebRTCMetaBuildWrapper):
|
|||||||
return re.sub('/+', '/', path)
|
return re.sub('/+', '/', path)
|
||||||
|
|
||||||
|
|
||||||
class FakeFile(object):
|
class FakeFile:
|
||||||
|
# pylint: disable=invalid-name
|
||||||
def __init__(self, files):
|
def __init__(self, files):
|
||||||
self.name = '/tmp/file'
|
self.name = '/tmp/file'
|
||||||
self.buf = ''
|
self.buf = ''
|
||||||
@ -211,8 +212,7 @@ TEST_CONFIG = """\
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
class UnitTest(unittest.TestCase):
|
def CreateFakeMBW(files=None, win32=False):
|
||||||
def fake_mbw(self, files=None, win32=False):
|
|
||||||
mbw = FakeMBW(win32=win32)
|
mbw = FakeMBW(win32=win32)
|
||||||
mbw.files.setdefault(mbw.default_config, TEST_CONFIG)
|
mbw.files.setdefault(mbw.default_config, TEST_CONFIG)
|
||||||
mbw.files.setdefault(
|
mbw.files.setdefault(
|
||||||
@ -226,14 +226,14 @@ class UnitTest(unittest.TestCase):
|
|||||||
mbw.files.setdefault(
|
mbw.files.setdefault(
|
||||||
mbw.ToAbsPath('//build/args/bots/fake_group/fake_args_bot.gn'),
|
mbw.ToAbsPath('//build/args/bots/fake_group/fake_args_bot.gn'),
|
||||||
'is_debug = false\ndcheck_always_on=false\n')
|
'is_debug = false\ndcheck_always_on=false\n')
|
||||||
mbw.files.setdefault(mbw.ToAbsPath('//tools/mb/rts_banned_suites.json'),
|
mbw.files.setdefault(mbw.ToAbsPath('//tools/mb/rts_banned_suites.json'), '{}')
|
||||||
'{}')
|
|
||||||
if files:
|
if files:
|
||||||
for path, contents in list(files.items()):
|
for path, contents in list(files.items()):
|
||||||
mbw.files[path] = contents
|
mbw.files[path] = contents
|
||||||
if path.endswith('.runtime_deps'):
|
if path.endswith('.runtime_deps'):
|
||||||
|
|
||||||
def fake_call(cmd, env=None, buffer_output=True, stdin=None):
|
def FakeCall(cmd, env=None, buffer_output=True, stdin=None):
|
||||||
|
# pylint: disable=cell-var-from-loop
|
||||||
del cmd
|
del cmd
|
||||||
del env
|
del env
|
||||||
del buffer_output
|
del buffer_output
|
||||||
@ -241,9 +241,13 @@ class UnitTest(unittest.TestCase):
|
|||||||
mbw.files[path] = contents
|
mbw.files[path] = contents
|
||||||
return 0, '', ''
|
return 0, '', ''
|
||||||
|
|
||||||
mbw.Call = fake_call
|
# pylint: disable=invalid-name
|
||||||
|
mbw.Call = FakeCall
|
||||||
return mbw
|
return mbw
|
||||||
|
|
||||||
|
|
||||||
|
class UnitTest(unittest.TestCase):
|
||||||
|
# pylint: disable=invalid-name
|
||||||
def check(self,
|
def check(self,
|
||||||
args,
|
args,
|
||||||
mbw=None,
|
mbw=None,
|
||||||
@ -253,7 +257,7 @@ class UnitTest(unittest.TestCase):
|
|||||||
ret=None,
|
ret=None,
|
||||||
env=None):
|
env=None):
|
||||||
if not mbw:
|
if not mbw:
|
||||||
mbw = self.fake_mbw(files)
|
mbw = CreateFakeMBW(files)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
prev_env = os.environ.copy()
|
prev_env = os.environ.copy()
|
||||||
@ -286,7 +290,7 @@ class UnitTest(unittest.TestCase):
|
|||||||
}'''
|
}'''
|
||||||
}
|
}
|
||||||
|
|
||||||
mbw = self.fake_mbw(files)
|
mbw = CreateFakeMBW(files)
|
||||||
mbw.Call = lambda cmd, env=None, buffer_output=True: (0, '', '')
|
mbw.Call = lambda cmd, env=None, buffer_output=True: (0, '', '')
|
||||||
|
|
||||||
self.check([
|
self.check([
|
||||||
@ -304,7 +308,7 @@ class UnitTest(unittest.TestCase):
|
|||||||
})
|
})
|
||||||
|
|
||||||
def test_gen(self):
|
def test_gen(self):
|
||||||
mbw = self.fake_mbw()
|
mbw = CreateFakeMBW()
|
||||||
self.check(['gen', '-c', 'debug_goma', '//out/Default', '-g', '/goma'],
|
self.check(['gen', '-c', 'debug_goma', '//out/Default', '-g', '/goma'],
|
||||||
mbw=mbw,
|
mbw=mbw,
|
||||||
ret=0)
|
ret=0)
|
||||||
@ -318,7 +322,7 @@ class UnitTest(unittest.TestCase):
|
|||||||
self.assertIn('/fake_src/buildtools/linux64/gn gen //out/Default --check',
|
self.assertIn('/fake_src/buildtools/linux64/gn gen //out/Default --check',
|
||||||
mbw.out)
|
mbw.out)
|
||||||
|
|
||||||
mbw = self.fake_mbw(win32=True)
|
mbw = CreateFakeMBW(win32=True)
|
||||||
self.check(['gen', '-c', 'debug_goma', '-g', 'c:\\goma', '//out/Debug'],
|
self.check(['gen', '-c', 'debug_goma', '-g', 'c:\\goma', '//out/Debug'],
|
||||||
mbw=mbw,
|
mbw=mbw,
|
||||||
ret=0)
|
ret=0)
|
||||||
@ -330,7 +334,7 @@ class UnitTest(unittest.TestCase):
|
|||||||
'c:\\fake_src\\buildtools\\win\\gn.exe gen //out/Debug '
|
'c:\\fake_src\\buildtools\\win\\gn.exe gen //out/Debug '
|
||||||
'--check\n', mbw.out)
|
'--check\n', mbw.out)
|
||||||
|
|
||||||
mbw = self.fake_mbw()
|
mbw = CreateFakeMBW()
|
||||||
self.check(
|
self.check(
|
||||||
['gen', '-m', 'fake_group', '-b', 'fake_args_bot', '//out/Debug'],
|
['gen', '-m', 'fake_group', '-b', 'fake_args_bot', '//out/Debug'],
|
||||||
mbw=mbw,
|
mbw=mbw,
|
||||||
@ -340,7 +344,7 @@ class UnitTest(unittest.TestCase):
|
|||||||
'import("//build/args/bots/fake_group/fake_args_bot.gn")\n\n')
|
'import("//build/args/bots/fake_group/fake_args_bot.gn")\n\n')
|
||||||
|
|
||||||
def test_gen_fails(self):
|
def test_gen_fails(self):
|
||||||
mbw = self.fake_mbw()
|
mbw = CreateFakeMBW()
|
||||||
mbw.Call = lambda cmd, env=None, buffer_output=True: (1, '', '')
|
mbw.Call = lambda cmd, env=None, buffer_output=True: (1, '', '')
|
||||||
self.check(['gen', '-c', 'debug_goma', '//out/Default'], mbw=mbw, ret=1)
|
self.check(['gen', '-c', 'debug_goma', '//out/Default'], mbw=mbw, ret=1)
|
||||||
|
|
||||||
@ -357,7 +361,7 @@ class UnitTest(unittest.TestCase):
|
|||||||
'/fake_src/out/Default/base_unittests.runtime_deps':
|
'/fake_src/out/Default/base_unittests.runtime_deps':
|
||||||
("base_unittests\n"),
|
("base_unittests\n"),
|
||||||
}
|
}
|
||||||
mbw = self.fake_mbw(files)
|
mbw = CreateFakeMBW(files)
|
||||||
self.check([
|
self.check([
|
||||||
'gen', '-c', 'debug_goma', '--swarming-targets-file',
|
'gen', '-c', 'debug_goma', '--swarming-targets-file',
|
||||||
'/tmp/swarming_targets', '//out/Default'
|
'/tmp/swarming_targets', '//out/Default'
|
||||||
@ -683,7 +687,7 @@ class UnitTest(unittest.TestCase):
|
|||||||
("unittests.exe\n"
|
("unittests.exe\n"
|
||||||
"some_dependency\n"),
|
"some_dependency\n"),
|
||||||
}
|
}
|
||||||
mbw = self.fake_mbw(files=files, win32=True)
|
mbw = CreateFakeMBW(files=files, win32=True)
|
||||||
self.check([
|
self.check([
|
||||||
'gen', '-c', 'debug_goma', '--swarming-targets-file',
|
'gen', '-c', 'debug_goma', '--swarming-targets-file',
|
||||||
'c:\\fake_src\\out\\Default\\tmp\\swarming_targets',
|
'c:\\fake_src\\out\\Default\\tmp\\swarming_targets',
|
||||||
@ -884,7 +888,7 @@ class UnitTest(unittest.TestCase):
|
|||||||
task_json = json.dumps({'tasks': [{'task_id': '00000'}]})
|
task_json = json.dumps({'tasks': [{'task_id': '00000'}]})
|
||||||
collect_json = json.dumps({'00000': {'results': {}}})
|
collect_json = json.dumps({'00000': {'results': {}}})
|
||||||
|
|
||||||
mbw = self.fake_mbw(files=files)
|
mbw = CreateFakeMBW(files=files)
|
||||||
mbw.files[mbw.PathJoin(mbw.TempDir(), 'task.json')] = task_json
|
mbw.files[mbw.PathJoin(mbw.TempDir(), 'task.json')] = task_json
|
||||||
mbw.files[mbw.PathJoin(mbw.TempDir(), 'collect_output.json')] = collect_json
|
mbw.files[mbw.PathJoin(mbw.TempDir(), 'collect_output.json')] = collect_json
|
||||||
original_impl = mbw.ToSrcRelPath
|
original_impl = mbw.ToSrcRelPath
|
||||||
@ -900,7 +904,7 @@ class UnitTest(unittest.TestCase):
|
|||||||
['run', '-s', '-c', 'debug_goma', '//out/Default', 'base_unittests'],
|
['run', '-s', '-c', 'debug_goma', '//out/Default', 'base_unittests'],
|
||||||
mbw=mbw,
|
mbw=mbw,
|
||||||
ret=0)
|
ret=0)
|
||||||
mbw = self.fake_mbw(files=files)
|
mbw = CreateFakeMBW(files=files)
|
||||||
mbw.files[mbw.PathJoin(mbw.TempDir(), 'task.json')] = task_json
|
mbw.files[mbw.PathJoin(mbw.TempDir(), 'task.json')] = task_json
|
||||||
mbw.files[mbw.PathJoin(mbw.TempDir(), 'collect_output.json')] = collect_json
|
mbw.files[mbw.PathJoin(mbw.TempDir(), 'collect_output.json')] = collect_json
|
||||||
mbw.ToSrcRelPath = to_src_rel_path_stub
|
mbw.ToSrcRelPath = to_src_rel_path_stub
|
||||||
@ -980,7 +984,7 @@ class UnitTest(unittest.TestCase):
|
|||||||
self.assertIn('phase = 2', mbw.out)
|
self.assertIn('phase = 2', mbw.out)
|
||||||
|
|
||||||
def test_validate(self):
|
def test_validate(self):
|
||||||
mbw = self.fake_mbw()
|
mbw = CreateFakeMBW()
|
||||||
self.check(['validate'], mbw=mbw, ret=0)
|
self.check(['validate'], mbw=mbw, ret=0)
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user