Commit 422d691c authored by Yuke Liao's avatar Yuke Liao Committed by Commit Bot

[code coverage] Fix the update_clang_coverage_tools script

The format of the clang build stamp file was changed in:
https://chromium-review.googlesource.com/c/chromium/src/+/1615030/27/tools/clang/scripts/update.py

The update_clang_coverage_tools.py script is broken because the
expected format doesn't match anymore, and this CL fixes the issue.

Change-Id: Ic72e9dc3d45bbb4ebbdb914c6dacee8d7259edb6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1625549Reviewed-by: default avatarMax Moroz <mmoroz@chromium.org>
Commit-Queue: Yuke Liao <liaoyuke@chromium.org>
Cr-Commit-Position: refs/heads/master@{#662236}
parent 3f5b1169
......@@ -28,16 +28,16 @@ def DownloadCoverageToolsIfNeeded():
"""Temporary solution to download llvm-profdata and llvm-cov tools."""
def _GetRevisionFromStampFile(stamp_file_path):
"""Returns a pair of revision number by reading the build stamp file.
"""Returns revision by reading the build stamp file.
Args:
stamp_file_path: A path the build stamp file created by
tools/clang/scripts/update.py.
Returns:
A pair of integers represeting the main and sub revision respectively.
A string represeting the revision of the tool, such as 361212-67510fac-2.
"""
if not os.path.exists(stamp_file_path):
return 0, 0
return ''
with open(stamp_file_path) as stamp_file:
stamp_file_line = stamp_file.readline()
......@@ -46,30 +46,25 @@ def DownloadCoverageToolsIfNeeded():
else:
package_version = stamp_file_line.rstrip()
clang_revision_str, clang_sub_revision_str = package_version.split('-')
return int(clang_revision_str), int(clang_sub_revision_str)
return package_version
cov_path = os.path.join(clang_update.LLVM_BUILD_DIR, 'llvm-cov')
profdata_path = os.path.join(clang_update.LLVM_BUILD_DIR, 'llvm-profdata')
host_platform = coverage_utils.GetHostPlatform()
clang_revision, clang_sub_revision = _GetRevisionFromStampFile(
clang_update.STAMP_FILE)
clang_revision = _GetRevisionFromStampFile(clang_update.STAMP_FILE)
coverage_revision_stamp_file = os.path.join(
os.path.dirname(clang_update.STAMP_FILE), 'cr_coverage_revision')
coverage_revision, coverage_sub_revision = _GetRevisionFromStampFile(
coverage_revision_stamp_file)
coverage_revision = _GetRevisionFromStampFile(coverage_revision_stamp_file)
has_coverage_tools = (
os.path.exists(cov_path) and os.path.exists(profdata_path))
if (has_coverage_tools and coverage_revision == clang_revision and
coverage_sub_revision == clang_sub_revision):
if (has_coverage_tools and clang_revision == coverage_revision):
# LLVM coverage tools are up to date, bail out.
return
package_version = '%d-%d' % (clang_revision, clang_sub_revision)
package_version = clang_revision
coverage_tools_file = 'llvm-code-coverage-%s.tgz' % package_version
# The code below follows the code from tools/clang/scripts/update.py.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment