mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
[3.13] gh-132038: Make perf version check in test_perf_profiler more robust (GH-132039) (#132058)
gh-132038: Make perf version check in test_perf_profiler more robust (GH-132039)
Should work also if the version string includes a commit hash, like `perf version 6.12.9.g242e6068fd5c`
(cherry picked from commit b6c92ec419
)
Co-authored-by: Itamar Oren <itamarost@gmail.com>
This commit is contained in:
parent
832a6918b1
commit
f7ab4ebb2c
1 changed files with 3 additions and 2 deletions
|
@ -482,7 +482,8 @@ class TestPerfProfiler(unittest.TestCase, TestPerfProfilerMixin):
|
|||
|
||||
def _is_perf_vesion_at_least(major, minor):
|
||||
# The output of perf --version looks like "perf version 6.7-3" but
|
||||
# it can also be perf version "perf version 5.15.143"
|
||||
# it can also be perf version "perf version 5.15.143", or even include
|
||||
# a commit hash in the version string, like "6.12.9.g242e6068fd5c"
|
||||
try:
|
||||
output = subprocess.check_output(["perf", "--version"], text=True)
|
||||
except (subprocess.CalledProcessError, FileNotFoundError):
|
||||
|
@ -490,7 +491,7 @@ def _is_perf_vesion_at_least(major, minor):
|
|||
version = output.split()[2]
|
||||
version = version.split("-")[0]
|
||||
version = version.split(".")
|
||||
version = tuple(map(int, version))
|
||||
version = tuple(map(int, version[:2]))
|
||||
return version >= (major, minor)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue