diff options
author | Jordan R Abrahams-Whitehead <ajordanr@google.com> | 2022-07-14 22:33:03 +0000 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-07-15 17:32:52 +0000 |
commit | c37602934cbc1280c50e7cdc54ac15ab72e5d1ed (patch) | |
tree | e3a4d7ace95a2391f512a1d20f83c0127d62ab1f /llvm_tools | |
parent | ad8fdba512d0e5547e112742c1f1b86d4f463a78 (diff) | |
download | toolchain-utils-c37602934cbc1280c50e7cdc54ac15ab72e5d1ed.tar.gz |
llvm_tools: Remove unused llvm_patch_management.py
This code is not used by anything on the ChromeOS side,
and is just a wrapper around patch_manager.py itself.
The README implies that it auto-fills the command line
arguments, but this is somewhat unneccesary, and if we
want to add support for this workflow, it should likely
be in patch_manager.py itself as a subcommand.
This commit removes llvm_patch_management.py and
llvm_patch_management_unittest.py, and also
removes it from the README.md.
Also removes other incorrect flags from the README.md.
BUG=b:188465085
TEST=./run_tests_for.py llvm_tools/*
Change-Id: Ibf5f77977f70a8b7334e111a92a8fec5be462201
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/3765939
Reviewed-by: Manoj Gupta <manojgupta@chromium.org>
Tested-by: Jordan Abrahams-Whitehead <ajordanr@google.com>
Commit-Queue: Jordan Abrahams-Whitehead <ajordanr@google.com>
Reviewed-by: George Burgess <gbiv@chromium.org>
Diffstat (limited to 'llvm_tools')
-rw-r--r-- | llvm_tools/README.md | 34 | ||||
-rwxr-xr-x | llvm_tools/llvm_patch_management.py | 281 | ||||
-rwxr-xr-x | llvm_tools/llvm_patch_management_unittest.py | 311 |
3 files changed, 0 insertions, 626 deletions
diff --git a/llvm_tools/README.md b/llvm_tools/README.md index 74fad6c9..86a4b778 100644 --- a/llvm_tools/README.md +++ b/llvm_tools/README.md @@ -124,35 +124,6 @@ $ ./update_chromeos_llvm_hash.py \ --failure_mode disable_patches ``` -## `llvm_patch_management.py` - -### Usage - -This script is used to test whether a newly added patch in a package's patch -metadata file would apply successfully. The script is also used to make sure -the patches of a package applied successfully, failed, etc., depending on the -failure mode specified. - -An example of using this script is when multiple packages would like to be -tested when a new patch was added to their patch metadata file. - -For example: - -``` -$ ./llvm_patch_management.py \ - --packages sys-devel/llvm sys-libs/compiler-rt \ - --failure_mode continue -``` - -The above example tests sys-devel/llvm and sys-libs/compiler-rt patch metadata -file with the failure mode `continue`. - -For help with the command line arguments of the script, run: - -``` -$ ./llvm_patch_management.py --help -``` - ## `patch_manager.py` ### Usage @@ -172,7 +143,6 @@ For example, to see all the failed (if any) patches: $ ./patch_manager.py \ --svn_version 367622 \ --patch_metadata_file /abs/path/to/patch/file \ - --filesdir_path /abs/path/to/$FILESDIR \ --src_path /abs/path/to/src/tree \ --failure_mode continue ``` @@ -183,7 +153,6 @@ For example, to disable all patches that failed to apply: $ ./patch_manager.py \ --svn_version 367622 \ --patch_metadata_file /abs/path/to/patch/file \ - --filesdir_path /abs/path/to/$FILESDIR \ --src_path /abs/path/to/src/tree \ --failure_mode disable_patches ``` @@ -194,7 +163,6 @@ For example, to remove all patches that no longer apply: $ ./patch_manager.py \ --svn_version 367622 \ --patch_metadata_file /abs/path/to/patch/file \ - --filesdir_path /abs/path/to/$FILESDIR \ --src_path /abs/path/to/src/tree \ --failure_mode remove_patches ``` @@ -205,7 +173,6 @@ For example, to bisect a failing patch and stop at the first bisected patch: $ ./patch_manager.py \ --svn_version 367622 \ --patch_metadata_file /abs/path/to/patch/file \ - --filesdir_path /abs/path/to/$FILESDIR \ --src_path /abs/path/to/src/tree \ --failure_mode bisect_patches \ --good_svn_version 365631 @@ -218,7 +185,6 @@ the failed patches: $ ./patch_manager.py \ --svn_version 367622 \ --patch_metadata_file /abs/path/to/patch/file \ - --filesdir_path /abs/path/to/$FILESDIR \ --src_path /abs/path/to/src/tree \ --failure_mode bisect_patches \ --good_svn_version 365631 \ diff --git a/llvm_tools/llvm_patch_management.py b/llvm_tools/llvm_patch_management.py deleted file mode 100755 index 46ddb867..00000000 --- a/llvm_tools/llvm_patch_management.py +++ /dev/null @@ -1,281 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- -# Copyright 2019 The ChromiumOS Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. -# -# pylint: disable=global-statement - -"""Creates the arguments for the patch manager for LLVM.""" - -from __future__ import print_function - -import argparse -import os - -import chroot -from failure_modes import FailureModes -import get_llvm_hash -import patch_manager -import patch_utils -import subprocess_helpers - - -# If set to `True`, then the contents of `stdout` after executing a command will -# be displayed to the terminal. -verbose = False - - -def GetCommandLineArgs(): - """Parses the commandline for the optional commandline arguments. - - Returns: - An argument parser object that contains all the commandline arguments. - """ - - # Default path to the chroot if a path is not specified. - cros_root = os.path.expanduser('~') - cros_root = os.path.join(cros_root, 'chromiumos') - - # Create parser and add optional command-line arguments. - parser = argparse.ArgumentParser( - description='Patch management for packages.') - - # Add argument for a specific chroot path. - parser.add_argument( - '--chroot_path', - type=patch_manager.is_directory, - default=cros_root, - help='the absolute path to the chroot (default: %(default)s)') - - # Add argument for which packages to manage their patches. - parser.add_argument( - '--packages', - required=False, - nargs='+', - default=['sys-devel/llvm'], - help='the packages to manage their patches (default: %(default)s)') - - # Add argument for whether to display command contents to `stdout`. - parser.add_argument('--verbose', - action='store_true', - help='display contents of a command to the terminal ' - '(default: %(default)s)') - - # Add argument for the LLVM version to use for patch management. - parser.add_argument( - '--llvm_version', - type=int, - help='the LLVM version to use for patch management. Alternatively, you ' - 'can pass "google3" or "google3-unstable". (Default: "google3")') - - # Add argument for the mode of the patch management when handling patches. - parser.add_argument( - '--failure_mode', - default=FailureModes.FAIL.value, - choices=[FailureModes.FAIL.value, FailureModes.CONTINUE.value, - FailureModes.DISABLE_PATCHES.value, - FailureModes.REMOVE_PATCHES.value], - help='the mode of the patch manager when handling failed patches ' \ - '(default: %(default)s)') - - # Add argument for the patch metadata file in $FILESDIR of LLVM. - parser.add_argument( - '--patch_metadata_file', - default='PATCHES.json', - help='the .json file in $FILESDIR that has all the patches and their ' - 'metadata if applicable (default: %(default)s)') - - # Parse the command line. - args_output = parser.parse_args() - - global verbose - - verbose = args_output.verbose - - unique_packages = list(set(args_output.packages)) - - # Duplicate packages were passed into the command line - if len(unique_packages) != len(args_output.packages): - raise ValueError('Duplicate packages were passed in: %s' % - ' '.join(args_output.packages)) - - args_output.packages = unique_packages - - return args_output - - -def GetPathToFilesDirectory(chroot_path, package): - """Gets the absolute path to $FILESDIR of the package. - - Args: - chroot_path: The absolute path to the chroot. - package: The package to find its absolute path to $FILESDIR. - - Returns: - The absolute path to $FILESDIR. - - Raises: - ValueError: An invalid chroot path has been provided. - """ - - if not os.path.isdir(chroot_path): - raise ValueError('Invalid chroot provided: %s' % chroot_path) - - # Get the absolute chroot path to the ebuild. - chroot_ebuild_path = subprocess_helpers.ChrootRunCommand( - chroot_path, ['equery', 'w', package], verbose=verbose) - - # Get the absolute chroot path to $FILESDIR's parent directory. - filesdir_parent_path = os.path.dirname(chroot_ebuild_path.strip()) - - # Get the relative path to $FILESDIR's parent directory. - rel_path = _GetRelativePathOfChrootPath(filesdir_parent_path) - - # Construct the absolute path to the package's 'files' directory. - return os.path.join(chroot_path, rel_path, 'files/') - - -def _GetRelativePathOfChrootPath(chroot_path): - """Gets the relative path of the chroot path passed in. - - Args: - chroot_path: The chroot path to get its relative path. - - Returns: - The relative path after '/mnt/host/source/'. - - Raises: - ValueError: The prefix of 'chroot_path' did not match '/mnt/host/source/'. - """ - - chroot_prefix = '/mnt/host/source/' - - if not chroot_path.startswith(chroot_prefix): - raise ValueError('Invalid prefix for the chroot path: %s' % chroot_path) - - return chroot_path[len(chroot_prefix):] - - -def _CheckPatchMetadataPath(patch_metadata_path): - """Checks that the patch metadata path is valid. - - Args: - patch_metadata_path: The absolute path to the .json file that has the - patches and their metadata. - - Raises: - ValueError: The file does not exist or the file does not end in '.json'. - """ - - if not os.path.isfile(patch_metadata_path): - raise ValueError('Invalid file provided: %s' % patch_metadata_path) - - if not patch_metadata_path.endswith('.json'): - raise ValueError('File does not end in ".json": %s' % patch_metadata_path) - - -def _MoveSrcTreeHEADToGitHash(src_path, git_hash): - """Moves HEAD to 'git_hash'.""" - - move_head_cmd = ['git', '-C', src_path, 'checkout', git_hash] - - subprocess_helpers.ExecCommandAndCaptureOutput(move_head_cmd, - verbose=verbose) - - -def UpdatePackagesPatchMetadataFile(chroot_path, svn_version, - patch_metadata_file, packages, mode): - """Updates the packages metadata file. - - Args: - chroot_path: The absolute path to the chroot. - svn_version: The version to use for patch management. - patch_metadata_file: The patch metadta file where all the patches and - their metadata are. - packages: All the packages to update their patch metadata file. - mode: The mode for the patch manager to use when an applicable patch - fails to apply. - Ex: 'FailureModes.FAIL' - - Returns: - A dictionary where the key is the package name and the value is a dictionary - that has information on the patches. - """ - - # A dictionary where the key is the package name and the value is a dictionary - # that has information on the patches. - package_info = {} - - llvm_hash = get_llvm_hash.LLVMHash() - - with llvm_hash.CreateTempDirectory() as temp_dir: - with get_llvm_hash.CreateTempLLVMRepo(temp_dir) as src_path: - # Ensure that 'svn_version' exists in the chromiumum mirror of LLVM by - # finding its corresponding git hash. - git_hash = get_llvm_hash.GetGitHashFrom(src_path, svn_version) - - # Git hash of 'svn_version' exists, so move the source tree's HEAD to - # 'git_hash' via `git checkout`. - _MoveSrcTreeHEADToGitHash(src_path, git_hash) - - for cur_package in packages: - # Get the absolute path to $FILESDIR of the package. - filesdir_path = GetPathToFilesDirectory(chroot_path, cur_package) - - # Construct the absolute path to the patch metadata file where all the - # patches and their metadata are. - patch_metadata_path = os.path.join(filesdir_path, patch_metadata_file) - - # Make sure the patch metadata path is valid. - _CheckPatchMetadataPath(patch_metadata_path) - - patch_utils.clean_src_tree(src_path) - - # Get the patch results for the current package. - patches_info = patch_manager.HandlePatches(svn_version, - patch_metadata_path, - filesdir_path, src_path, - mode) - - package_info[cur_package] = patches_info._asdict() - - return package_info - - -def main(): - """Updates the patch metadata file of each package if possible. - - Raises: - AssertionError: The script was run inside the chroot. - """ - - chroot.VerifyOutsideChroot() - - args_output = GetCommandLineArgs() - - # Get the google3 LLVM version if a LLVM version was not provided. - llvm_version = args_output.llvm_version - if llvm_version in ('', 'google3', 'google3-unstable'): - llvm_version = get_llvm_hash.GetGoogle3LLVMVersion( - stable=llvm_version != 'google3-unstable') - - UpdatePackagesPatchMetadataFile(args_output.chroot_path, llvm_version, - args_output.patch_metadata_file, - args_output.packages, - FailureModes(args_output.failure_mode)) - - # Only 'disable_patches' and 'remove_patches' can potentially modify the patch - # metadata file. - if (args_output.failure_mode == FailureModes.DISABLE_PATCHES.value - or args_output.failure_mode == FailureModes.REMOVE_PATCHES.value): - print('The patch file %s has been modified for the packages:' % - args_output.patch_metadata_file) - print('\n'.join(args_output.packages)) - else: - print('Applicable patches in %s applied successfully.' % - args_output.patch_metadata_file) - - -if __name__ == '__main__': - main() diff --git a/llvm_tools/llvm_patch_management_unittest.py b/llvm_tools/llvm_patch_management_unittest.py deleted file mode 100755 index 52117c93..00000000 --- a/llvm_tools/llvm_patch_management_unittest.py +++ /dev/null @@ -1,311 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- -# Copyright 2019 The ChromiumOS Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# pylint: disable=protected-access - -"""Unit tests when creating the arguments for the patch manager.""" - -from __future__ import print_function - -from collections import namedtuple -import os -import unittest -import unittest.mock as mock - -from failure_modes import FailureModes -import get_llvm_hash -import llvm_patch_management -import patch_manager -import patch_utils -import subprocess_helpers - - -class LlvmPatchManagementTest(unittest.TestCase): - """Test class when constructing the arguments for the patch manager.""" - - # Simulate the behavior of `os.path.isdir()` when the chroot path does not - # exist or is not a directory. - @mock.patch.object(os.path, 'isdir', return_value=False) - def testInvalidChrootPathWhenGetPathToFilesDir(self, mock_isdir): - chroot_path = '/some/path/to/chroot' - package = 'sys-devel/llvm' - - # Verify the exception is raised when an invalid absolute path to the chroot - # is passed in. - with self.assertRaises(ValueError) as err: - llvm_patch_management.GetPathToFilesDirectory(chroot_path, package) - - self.assertEqual(str(err.exception), - 'Invalid chroot provided: %s' % chroot_path) - - mock_isdir.assert_called_once() - - # Simulate the behavior of 'os.path.isdir()' when a valid chroot path is - # passed in. - @mock.patch.object(os.path, 'isdir', return_value=True) - @mock.patch.object(subprocess_helpers, 'ChrootRunCommand') - @mock.patch.object(llvm_patch_management, '_GetRelativePathOfChrootPath') - def testSuccessfullyGetPathToFilesDir(self, - mock_get_relative_path_of_chroot_path, - mock_chroot_cmd, mock_isdir): - - package_chroot_path = '/mnt/host/source/path/to/llvm/llvm.ebuild' - - # Simulate behavior of 'ChrootRunCommand()' when successfully - # retrieved the absolute chroot path to the package's ebuild. - mock_chroot_cmd.return_value = package_chroot_path - - # Simulate behavior of '_GetRelativePathOfChrootPath()' when successfully - # removed '/mnt/host/source' of the absolute chroot path to the package's - # ebuild. - # - # Returns relative path after '/mnt/host/source/'. - mock_get_relative_path_of_chroot_path.return_value = 'path/to/llvm' - - chroot_path = '/some/path/to/chroot' - - package = 'sys-devel/llvm' - - self.assertEqual( - llvm_patch_management.GetPathToFilesDirectory(chroot_path, package), - '/some/path/to/chroot/path/to/llvm/files/') - - mock_isdir.assert_called_once() - - mock_chroot_cmd.assert_called_once() - - mock_get_relative_path_of_chroot_path.assert_called_once_with( - '/mnt/host/source/path/to/llvm') - - def testInvalidPrefixForChrootPath(self): - package_chroot_path = '/path/to/llvm' - - # Verify the exception is raised when the chroot path does not start with - # '/mnt/host/source/'. - with self.assertRaises(ValueError) as err: - llvm_patch_management._GetRelativePathOfChrootPath(package_chroot_path) - - self.assertEqual( - str(err.exception), - 'Invalid prefix for the chroot path: %s' % package_chroot_path) - - def testValidPrefixForChrootPath(self): - package_chroot_path = '/mnt/host/source/path/to/llvm' - - package_rel_path = 'path/to/llvm' - - self.assertEqual( - llvm_patch_management._GetRelativePathOfChrootPath( - package_chroot_path), package_rel_path) - - # Simulate behavior of 'os.path.isfile()' when the patch metadata file does - # not exist. - @mock.patch.object(os.path, 'isfile', return_value=False) - def testInvalidFileForPatchMetadataPath(self, mock_isfile): - abs_path_to_patch_file = '/abs/path/to/files/test.json' - - # Verify the exception is raised when the absolute path to the patch - # metadata file does not exist. - with self.assertRaises(ValueError) as err: - llvm_patch_management._CheckPatchMetadataPath(abs_path_to_patch_file) - - self.assertEqual(str(err.exception), - 'Invalid file provided: %s' % abs_path_to_patch_file) - - mock_isfile.assert_called_once() - - # Simulate behavior of 'os.path.isfile()' when the absolute path to the - # patch metadata file exists. - @mock.patch.object(os.path, 'isfile', return_value=True) - def testPatchMetadataFileDoesNotEndInJson(self, mock_isfile): - abs_path_to_patch_file = '/abs/path/to/files/PATCHES' - - # Verify the exception is raised when the patch metadata file does not end - # in '.json'. - with self.assertRaises(ValueError) as err: - llvm_patch_management._CheckPatchMetadataPath(abs_path_to_patch_file) - - self.assertEqual( - str(err.exception), - 'File does not end in ".json": %s' % abs_path_to_patch_file) - - mock_isfile.assert_called_once() - - @mock.patch.object(os.path, 'isfile') - def testValidPatchMetadataFile(self, mock_isfile): - abs_path_to_patch_file = '/abs/path/to/files/PATCHES.json' - - # Simulate behavior of 'os.path.isfile()' when the absolute path to the - # patch metadata file exists. - mock_isfile.return_value = True - - llvm_patch_management._CheckPatchMetadataPath(abs_path_to_patch_file) - - mock_isfile.assert_called_once() - - # Simulate `GetGitHashFrom()` when successfully retrieved the git hash - # of the version passed in. - @mock.patch.object(get_llvm_hash, - 'GetGitHashFrom', - return_value='a123testhash1') - # Simulate `CreateTempLLVMRepo()` when successfully created a work tree from - # the LLVM repo copy in `llvm_tools` directory. - @mock.patch.object(get_llvm_hash, 'CreateTempLLVMRepo') - # Simulate behavior of `_MoveSrcTreeHEADToGitHash()` when successfully moved - # the head pointer to the git hash of the revision. - @mock.patch.object(llvm_patch_management, '_MoveSrcTreeHEADToGitHash') - @mock.patch.object(llvm_patch_management, 'GetPathToFilesDirectory') - @mock.patch.object(llvm_patch_management, '_CheckPatchMetadataPath') - def testExceptionIsRaisedWhenUpdatingAPackagesMetadataFile( - self, mock_check_patch_metadata_path, mock_get_filesdir_path, - mock_move_head_pointer, mock_create_temp_llvm_repo, mock_get_git_hash): - - abs_path_to_patch_file = ( - '/some/path/to/chroot/some/path/to/filesdir/PATCHES') - - # Simulate the behavior of '_CheckPatchMetadataPath()' when the patch - # metadata file in $FILESDIR does not exist or does not end in '.json'. - def InvalidPatchMetadataFile(patch_metadata_path): - self.assertEqual(patch_metadata_path, abs_path_to_patch_file) - - raise ValueError('File does not end in ".json": %s' % - abs_path_to_patch_file) - - # Use the test function to simulate behavior of '_CheckPatchMetadataPath()'. - mock_check_patch_metadata_path.side_effect = InvalidPatchMetadataFile - - abs_path_to_filesdir = '/some/path/to/chroot/some/path/to/filesdir' - - # Simulate the behavior of 'GetPathToFilesDirectory()' when successfully - # constructed the absolute path to $FILESDIR of a package. - mock_get_filesdir_path.return_value = abs_path_to_filesdir - - temp_work_tree = '/abs/path/to/tmpWorkTree' - - # Simulate the behavior of returning the absolute path to a worktree via - # `git worktree add`. - mock_create_temp_llvm_repo.return_value.__enter__.return_value.name = ( - temp_work_tree) - - chroot_path = '/some/path/to/chroot' - revision = 1000 - patch_file_name = 'PATCHES' - package_name = 'test-package/package1' - - # Verify the exception is raised when a package is constructing the - # arguments for the patch manager to update its patch metadata file and an - # exception is raised in the process. - with self.assertRaises(ValueError) as err: - llvm_patch_management.UpdatePackagesPatchMetadataFile( - chroot_path, revision, patch_file_name, [package_name], - FailureModes.FAIL) - - self.assertEqual( - str(err.exception), - 'File does not end in ".json": %s' % abs_path_to_patch_file) - - mock_get_filesdir_path.assert_called_once_with(chroot_path, package_name) - - mock_get_git_hash.assert_called_once() - - mock_check_patch_metadata_path.assert_called_once() - - mock_move_head_pointer.assert_called_once() - - mock_create_temp_llvm_repo.assert_called_once() - - # Simulate `CleanSrcTree()` when successfully removed changes from the - # worktree. - @mock.patch.object(patch_utils, 'clean_src_tree') - # Simulate `GetGitHashFrom()` when successfully retrieved the git hash - # of the version passed in. - @mock.patch.object(get_llvm_hash, - 'GetGitHashFrom', - return_value='a123testhash1') - # Simulate `CreateTempLLVMRepo()` when successfully created a work tree from - # the LLVM repo copy in `llvm_tools` directory. - @mock.patch.object(get_llvm_hash, 'CreateTempLLVMRepo') - # Simulate behavior of `_MoveSrcTreeHEADToGitHash()` when successfully moved - # the head pointer to the git hash of the revision. - @mock.patch.object(llvm_patch_management, '_MoveSrcTreeHEADToGitHash') - @mock.patch.object(llvm_patch_management, 'GetPathToFilesDirectory') - @mock.patch.object(llvm_patch_management, '_CheckPatchMetadataPath') - @mock.patch.object(patch_manager, 'HandlePatches') - def testSuccessfullyRetrievedPatchResults( - self, mock_handle_patches, mock_check_patch_metadata_path, - mock_get_filesdir_path, mock_move_head_pointer, - mock_create_temp_llvm_repo, mock_get_git_hash, mock_clean_src_tree): - - abs_path_to_filesdir = '/some/path/to/chroot/some/path/to/filesdir' - - abs_path_to_patch_file = ( - '/some/path/to/chroot/some/path/to/filesdir/PATCHES.json') - - # Simulate the behavior of 'GetPathToFilesDirectory()' when successfully - # constructed the absolute path to $FILESDIR of a package. - mock_get_filesdir_path.return_value = abs_path_to_filesdir - - PatchInfo = namedtuple('PatchInfo', [ - 'applied_patches', 'failed_patches', 'non_applicable_patches', - 'disabled_patches', 'removed_patches', 'modified_metadata' - ]) - - # Simulate the behavior of 'HandlePatches()' when successfully iterated - # through every patch in the patch metadata file and a dictionary is - # returned that contains information about the patches' status. - mock_handle_patches.return_value = PatchInfo( - applied_patches=['fixes_something.patch'], - failed_patches=['disables_output.patch'], - non_applicable_patches=[], - disabled_patches=[], - removed_patches=[], - modified_metadata=None) - - temp_work_tree = '/abs/path/to/tmpWorkTree' - - # Simulate the behavior of returning the absolute path to a worktree via - # `git worktree add`. - mock_create_temp_llvm_repo.return_value.__enter__.return_value.name = ( - temp_work_tree) - - expected_patch_results = { - 'applied_patches': ['fixes_something.patch'], - 'failed_patches': ['disables_output.patch'], - 'non_applicable_patches': [], - 'disabled_patches': [], - 'removed_patches': [], - 'modified_metadata': None - } - - chroot_path = '/some/path/to/chroot' - revision = 1000 - patch_file_name = 'PATCHES.json' - package_name = 'test-package/package2' - - patch_info = llvm_patch_management.UpdatePackagesPatchMetadataFile( - chroot_path, revision, patch_file_name, [package_name], - FailureModes.CONTINUE) - - self.assertDictEqual(patch_info, {package_name: expected_patch_results}) - - mock_get_filesdir_path.assert_called_once_with(chroot_path, package_name) - - mock_check_patch_metadata_path.assert_called_once_with( - abs_path_to_patch_file) - - mock_handle_patches.assert_called_once() - - mock_create_temp_llvm_repo.assert_called_once() - - mock_get_git_hash.assert_called_once() - - mock_move_head_pointer.assert_called_once() - - mock_clean_src_tree.assert_called_once() - - -if __name__ == '__main__': - unittest.main() |