mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-13 05:40:42 +01:00

Reason for revert: Fixing errors for reland. I have tested that this does not make Chromium video quality tests fail. Original issue's description: > Revert of PyLint fixes for tools-webrtc and webrtc/tools (patchset #3 id:40001 of https://codereview.webrtc.org/2736233003/ ) > > Reason for revert: > Fails video quality tests in Chrome: http://build.chromium.org/p/chromium.webrtc.fyi/builders/Win10%20Tester/builds/6568 > I should have looked more closer at those :( > > Original issue's description: > > PyLint fixes for tools-webrtc and webrtc/tools > > > > Fix a lot of errors before bringing in the new config in > > https://codereview.webrtc.org/2737963003/ > > > > BUG=webrtc:7303 > > NOTRY=True > > > > Review-Url: https://codereview.webrtc.org/2736233003 > > Cr-Commit-Position: refs/heads/master@{#17137} > > Committed:f5318e1f39
> > TBR=oprypin@webrtc.org > # Skipping CQ checks because original CL landed less than 1 days ago. > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > BUG=webrtc:7303 > > Review-Url: https://codereview.webrtc.org/2737233003 > Cr-Commit-Position: refs/heads/master@{#17142} > Committed:94f4d9effc
NOTRY=true BUG=webrtc:7312 Review-Url: https://codereview.webrtc.org/2741733003 Cr-Commit-Position: refs/heads/master@{#17541}
68 lines
2.2 KiB
Python
Executable file
68 lines
2.2 KiB
Python
Executable file
#!/usr/bin/env python
|
|
|
|
# Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
|
|
#
|
|
# Use of this source code is governed by a BSD-style license
|
|
# that can be found in the LICENSE file in the root of the source
|
|
# tree. An additional intellectual property rights grant can be found
|
|
# in the file PATENTS. All contributing project authors may
|
|
# be found in the AUTHORS file in the root of the source tree.
|
|
|
|
import ast
|
|
import os
|
|
import unittest
|
|
|
|
from check_package_boundaries import CheckPackageBoundaries
|
|
|
|
|
|
MSG_FORMAT = 'ERROR:check_package_boundaries.py: Unexpected %s.'
|
|
TESTDATA_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)),
|
|
'testdata')
|
|
|
|
|
|
def ReadPylFile(file_path):
|
|
with open(file_path) as f:
|
|
return ast.literal_eval(f.read())
|
|
|
|
|
|
class Logger(object):
|
|
def __init__(self, test_dir):
|
|
self.messages = []
|
|
self.test_dir = test_dir
|
|
|
|
def Log(self, build_file_path, line_number, target_name, source_file,
|
|
subpackage):
|
|
build_file_path = os.path.relpath(build_file_path, self.test_dir)
|
|
build_file_path = build_file_path.replace(os.path.sep, '/')
|
|
self.messages.append([build_file_path, line_number, target_name,
|
|
source_file, subpackage])
|
|
|
|
|
|
class UnitTest(unittest.TestCase):
|
|
def RunTest(self, test_dir, check_all_build_files=False):
|
|
logger = Logger(test_dir)
|
|
build_files = [os.path.join(test_dir, 'BUILD.gn')]
|
|
if check_all_build_files:
|
|
build_files = None
|
|
CheckPackageBoundaries(test_dir, logger, build_files)
|
|
expected_messages = ReadPylFile(os.path.join(test_dir, 'expected.pyl'))
|
|
self.assertListEqual(sorted(expected_messages), sorted(logger.messages))
|
|
|
|
def testNoErrors(self):
|
|
self.RunTest(os.path.join(TESTDATA_DIR, 'no_errors'))
|
|
|
|
def testMultipleErrorsSingleTarget(self):
|
|
self.RunTest(os.path.join(TESTDATA_DIR, 'multiple_errors_single_target'))
|
|
|
|
def testMultipleErrorsMultipleTargets(self):
|
|
self.RunTest(os.path.join(TESTDATA_DIR, 'multiple_errors_multiple_targets'))
|
|
|
|
def testCommonPrefix(self):
|
|
self.RunTest(os.path.join(TESTDATA_DIR, 'common_prefix'))
|
|
|
|
def testAllBuildFiles(self):
|
|
self.RunTest(os.path.join(TESTDATA_DIR, 'all_build_files'), True)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|