diff options
-rwxr-xr-x | llvm_tools/update_chromeos_llvm_hash.py | 6 | ||||
-rwxr-xr-x | llvm_tools/update_chromeos_llvm_hash_unittest.py | 16 |
2 files changed, 13 insertions, 9 deletions
diff --git a/llvm_tools/update_chromeos_llvm_hash.py b/llvm_tools/update_chromeos_llvm_hash.py index afc63f3c..ab83321a 100755 --- a/llvm_tools/update_chromeos_llvm_hash.py +++ b/llvm_tools/update_chromeos_llvm_hash.py @@ -300,13 +300,12 @@ def UprevEbuildToVersion(symlink, svn_version, git_hash): raise ValueError('Invalid symlink provided: %s' % symlink) ebuild = os.path.realpath(symlink) + llvm_major_version = get_llvm_hash.GetLLVMMajorVersion(git_hash) # llvm package = os.path.basename(os.path.dirname(symlink)) if not package: raise ValueError('Tried to uprev an unknown package') - # llvm if package == 'llvm': - llvm_major_version = get_llvm_hash.GetLLVMMajorVersion(git_hash) new_ebuild, is_changed = re.subn( r'(\d+)\.(\d+)_pre([0-9]+)_p([0-9]+)', '%s.\\2_pre%s_p%s' % (llvm_major_version, svn_version, @@ -316,7 +315,8 @@ def UprevEbuildToVersion(symlink, svn_version, git_hash): # any other package else: new_ebuild, is_changed = re.subn( - r'pre([0-9]+)', 'pre%s' % svn_version, ebuild, count=1) + r'(\d+)\.(\d+)_pre([0-9]+)', + '%s.\\2_pre%s' % (llvm_major_version, svn_version), ebuild, count=1) if not is_changed: # failed to increment the revision number raise ValueError('Failed to uprev the ebuild.') diff --git a/llvm_tools/update_chromeos_llvm_hash_unittest.py b/llvm_tools/update_chromeos_llvm_hash_unittest.py index 01306ad6..adb20598 100755 --- a/llvm_tools/update_chromeos_llvm_hash_unittest.py +++ b/llvm_tools/update_chromeos_llvm_hash_unittest.py @@ -311,16 +311,19 @@ class UpdateLLVMHashTest(unittest.TestCase): self.assertEqual(mock_command_output.call_args_list[3], mock.call(expected_cmd)) + @mock.patch.object(get_llvm_hash, 'GetLLVMMajorVersion') @mock.patch.object(os.path, 'islink', return_value=True) @mock.patch.object(os.path, 'realpath') @mock.patch.object(subprocess, 'check_output', return_value=None) def testSuccessfullyUprevEbuildToVersionNonLLVM(self, mock_command_output, - mock_realpath, mock_islink): - symlink = '/path/to/compiler-rt/compiler-rt_pre3_p2-r10.ebuild' - ebuild = '/abs/path/to/compiler-rt/compiler-rt_pre3_p2.ebuild' + mock_realpath, mock_islink, + mock_llvm_version): + symlink = '/abs/path/to/compiler-rt/compiler-rt-12.0_pre314159265-r4.ebuild' + ebuild = '/abs/path/to/compiler-rt/compiler-rt-12.0_pre314159265.ebuild' mock_realpath.return_value = ebuild + mock_llvm_version.return_value = '1234' svn_version = 1000 - git_hash = '1234' + git_hash = '5678' update_chromeos_llvm_hash.UprevEbuildToVersion(symlink, svn_version, git_hash) @@ -329,12 +332,13 @@ class UpdateLLVMHashTest(unittest.TestCase): mock_realpath.assert_called_once_with(symlink) + mock_llvm_version.assert_called_once_with(git_hash) + mock_command_output.assert_called() # Verify commands symlink_dir = os.path.dirname(symlink) - new_ebuild, _ = re.subn( - r'pre([0-9]+)', 'pre%s' % svn_version, ebuild, count=1) + new_ebuild = '/abs/path/to/compiler-rt/compiler-rt-1234.0_pre1000.ebuild' new_symlink = new_ebuild[:-len('.ebuild')] + '-r1.ebuild' expected_cmd = ['git', '-C', symlink_dir, 'mv', ebuild, new_ebuild] |