diff options
author | George Burgess IV <gbiv@google.com> | 2019-09-09 16:34:32 -0700 |
---|---|---|
committer | George Burgess <gbiv@chromium.org> | 2019-09-10 01:58:59 +0000 |
commit | 0f8dae198451cfc73eb6c509cbddbe9c159ea45f (patch) | |
tree | b0cde29571d47f49118c5e461d487a839b660ef3 /llvm_tools | |
parent | df367da3e784c3e2f69d2f2f8aaa5457426e0414 (diff) | |
download | toolchain-utils-0f8dae198451cfc73eb6c509cbddbe9c159ea45f.tar.gz |
llvm_tools: appease pylint
Pylint apparently dislikes a lot about these files. Make it happy.
BUG=None
TEST=`cros lint`
Change-Id: I2752ca5872eb0c9b2daa2c0409ddc6347171418f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/1793908
Reviewed-by: Manoj Gupta <manojgupta@chromium.org>
Tested-by: George Burgess <gbiv@chromium.org>
Diffstat (limited to 'llvm_tools')
-rwxr-xr-x | llvm_tools/get_llvm_hash_unittest.py | 2 | ||||
-rwxr-xr-x | llvm_tools/update_chromeos_llvm_next_hash.py | 15 | ||||
-rwxr-xr-x | llvm_tools/update_chromeos_llvm_next_hash_unittest.py | 32 |
3 files changed, 30 insertions, 19 deletions
diff --git a/llvm_tools/get_llvm_hash_unittest.py b/llvm_tools/get_llvm_hash_unittest.py index 77957aa0..895ee2b6 100755 --- a/llvm_tools/get_llvm_hash_unittest.py +++ b/llvm_tools/get_llvm_hash_unittest.py @@ -12,9 +12,9 @@ import subprocess import unittest import get_llvm_hash +from get_llvm_hash import LLVMHash import mock import test_helpers -from get_llvm_hash import LLVMHash # We grab protected stuff from get_llvm_hash. That's OK. # pylint: disable=protected-access diff --git a/llvm_tools/update_chromeos_llvm_next_hash.py b/llvm_tools/update_chromeos_llvm_next_hash.py index 470098d8..30660de3 100755 --- a/llvm_tools/update_chromeos_llvm_next_hash.py +++ b/llvm_tools/update_chromeos_llvm_next_hash.py @@ -18,11 +18,11 @@ import re import subprocess from collections import namedtuple -import get_llvm_hash -import llvm_patch_management from assert_not_in_chroot import VerifyOutsideChroot from failure_modes import FailureModes from get_llvm_hash import GetLLVMHashAndVersionFromSVNOption, is_svn_option +import get_llvm_hash +import llvm_patch_management from subprocess_helpers import ChrootRunCommand, ExecCommandAndCaptureOutput # If set to `True`, then the contents of `stdout` after executing a command will @@ -48,7 +48,7 @@ def GetCommandLineArgs(): # Create parser and add optional command-line arguments. parser = argparse.ArgumentParser( - description='Updates the build\'s hash for llvm-next.') + description="Updates the build's hash for llvm-next.") # Add argument for a specific chroot path. parser.add_argument( @@ -100,6 +100,9 @@ def GetCommandLineArgs(): # Parse the command line. args_output = parser.parse_args() + # FIXME: We shouldn't be using globals here, but until we fix it, make pylint + # stop complaining about it. + # pylint: disable=global-statement global verbose verbose = args_output.verbose @@ -410,7 +413,7 @@ def GetGerritRepoUploadContents(repo_upload_contents): found_url = re.search( r'https://chromium-review.googlesource.com/c/' - 'chromiumos/overlays/chromiumos-overlay/\+/([0-9]+)', + r'chromiumos/overlays/chromiumos-overlay/\+/([0-9]+)', repo_upload_contents) if not found_url: @@ -454,6 +457,10 @@ def UploadChanges(path_to_repo_dir, llvm_hash, commit_messages): upload_change_cmd = ( 'yes | repo upload --br=llvm-next-update-%s --no-verify' % llvm_hash) + # Pylint currently doesn't lint things in py3 mode, and py2 didn't allow + # users to specify `encoding`s for Popen. Hence, pylint is "wrong" here. + # pylint: disable=unexpected-keyword-arg + # NOTE: Need `shell=True` in order to pipe `yes` into `repo upload ...`. # # The CL URL is sent to 'stderr', so need to redirect 'stderr' to 'stdout'. diff --git a/llvm_tools/update_chromeos_llvm_next_hash_unittest.py b/llvm_tools/update_chromeos_llvm_next_hash_unittest.py index 379185a4..62615def 100755 --- a/llvm_tools/update_chromeos_llvm_next_hash_unittest.py +++ b/llvm_tools/update_chromeos_llvm_next_hash_unittest.py @@ -11,7 +11,6 @@ from __future__ import print_function from collections import namedtuple from pipes import quote from tempfile import mkstemp -import mock import os import unittest @@ -19,8 +18,12 @@ from cros_utils import command_executer from failure_modes import FailureModes from test_helpers import CallCountsToMockFunctions import llvm_patch_management +import mock import update_chromeos_llvm_next_hash +# These are unittests; protected access is OK to a point. +# pylint: disable=protected-access + class UpdateLLVMNextHashTest(unittest.TestCase): """Test class for updating 'LLVM_NEXT_HASH' of packages.""" @@ -356,7 +359,7 @@ class UpdateLLVMNextHashTest(unittest.TestCase): @mock.patch.object(command_executer.CommandExecuter, 'RunCommandWOutput') def testSuccessfullyCreatedRepo(self, mock_command_output, mock_isdir): # Test function to simulate 'RunCommandWOutput' when 'repo start' succeeds. - def GoodRepoStart(create_repo_cmd, print_to_console): + def GoodRepoStart(create_repo_cmd, _print_to_console): self.assertEqual(create_repo_cmd.split()[-1], 'llvm-next-update-a123testhash1') @@ -415,7 +418,7 @@ class UpdateLLVMNextHashTest(unittest.TestCase): def testSuccessfullyDeletedRepo(self, mock_command_output, mock_isdir): # Test function to simulate 'RunCommandWOutput' when successfully deleted a # repo. - def GoodRepoDelete(create_repo_cmd, print_to_console): + def GoodRepoDelete(create_repo_cmd, _print_to_console): self.assertEqual(create_repo_cmd.split()[-1], 'llvm-next-update-a123testhash2') @@ -506,7 +509,7 @@ class UpdateLLVMNextHashTest(unittest.TestCase): # Test function to simulate 'RunCommandWOutput' when attempting to create # a commit and upload the changes for review. @CallCountsToMockFunctions - def MultipleCallsToUploadACommit(call_count, cmd, print_to_console): + def MultipleCallsToUploadACommit(call_count, cmd, _print_to_console): # Creating a commit for the changes. if call_count == 0: # first call to 'RunCommandWOutput' self.assertEqual( @@ -551,7 +554,7 @@ class UpdateLLVMNextHashTest(unittest.TestCase): # Test function to simulate 'RunCommandWOutput' when creating a commit for # the changes and uploading the changes for review. @CallCountsToMockFunctions - def MultipleCallsToUploadACommit(call_count, cmd, print_to_console): + def MultipleCallsToUploadACommit(call_count, cmd, _print_to_console): # Creating a commit in the repo path. if call_count == 0: # first call to 'RunCommandWOutput' self.assertEqual( @@ -599,7 +602,7 @@ class UpdateLLVMNextHashTest(unittest.TestCase): # Test function to simulate '_ConvertChrootPathsToSymLinkPaths' when a # symlink does not start with the prefix '/mnt/host/source'. - def BadPrefixChrootPath(chroot_path, chroot_file_paths): + def BadPrefixChrootPath(_chroot_path, _chroot_file_paths): raise ValueError('Invalid prefix for the chroot path: ' '/some/chroot/path/to/package-r1.ebuild') @@ -769,7 +772,7 @@ class UpdateLLVMNextHashTest(unittest.TestCase): @mock.patch.object(os.path, 'isfile', return_value=True) @mock.patch.object(command_executer.CommandExecuter, 'RunCommandWOutput') def testFailedToStagePatchMetadataFileForCommit(self, mock_run_cmd, - mock_isfile): + _mock_isfile): # Simulate the behavior of 'RunCommandWOutput()' when failed to stage the # patch metadata file for commit. @@ -797,7 +800,7 @@ class UpdateLLVMNextHashTest(unittest.TestCase): @mock.patch.object(os.path, 'isfile', return_value=True) @mock.patch.object(command_executer.CommandExecuter, 'RunCommandWOutput') def testSuccessfullyStagedPatchMetadataFileForCommit(self, mock_run_cmd, - mock_isfile): + _mock_isfile): # Simulate the behavior of 'RunCommandWOutput()' when successfully staged # the patch metadata file for commit. @@ -909,7 +912,7 @@ class UpdateLLVMNextHashTest(unittest.TestCase): # Test function to simulate '_CreateRepo' when successfully created the # repo on a valid repo path. - def SuccessfullyCreateRepoForChanges(repo_path, llvm_hash): + def SuccessfullyCreateRepoForChanges(_repo_path, llvm_hash): self.assertEqual(llvm_hash, 'a123testhash4') return @@ -924,18 +927,19 @@ class UpdateLLVMNextHashTest(unittest.TestCase): # Test function to simulate 'UprevEbuild' when the symlink to the ebuild # does not have a revision number. - def FailedToUprevEbuild(symlink_path): + def FailedToUprevEbuild(_symlink_path): # Raises a 'ValueError' exception because the symlink did not have have a # revision number. raise ValueError('Failed to uprev the ebuild.') # Test function to fail on 'UploadChanges' if the function gets called # when an exception is raised. - def ShouldNotExecuteUploadChanges(repo_path, llvm_hash, commit_messages): + def ShouldNotExecuteUploadChanges(_repo_path, _llvm_hash, + _commit_messages): # Test function should not be called (i.e. execution should resume in the # 'finally' block) because 'UprevEbuild()' raised an # exception. - assert False, 'Failed to go to \'finally\' block ' \ + assert False, "Failed to go to 'finally' block " \ 'after the exception was raised.' test_package_path_dict = { @@ -999,7 +1003,7 @@ class UpdateLLVMNextHashTest(unittest.TestCase): # Test function to simulate '_CreateRepo' when successfully created the repo # for the changes to be made to the ebuild files. - def SuccessfullyCreateRepoForChanges(repo_path, llvm_hash): + def SuccessfullyCreateRepoForChanges(_repo_path, llvm_hash): self.assertEqual(llvm_hash, 'a123testhash5') return @@ -1054,7 +1058,7 @@ class UpdateLLVMNextHashTest(unittest.TestCase): # Test function to simulate 'UploadChanges()' when successfully created a # commit for the changes made to the packages and their patches and # retrieved the change list of the commit. - def SuccessfullyUploadedChanges(repo_path, llvm_hash, commit_messages): + def SuccessfullyUploadedChanges(_repo_path, _llvm_hash, _commit_messages): commit_url = 'https://some_name/path/to/commit/+/12345' return update_chromeos_llvm_next_hash.CommitContents( |