Skip to content

Commit b6c92ec

Browse files
authored
gh-132038: Make perf version check in test_perf_profiler more robust (#132039)
Should work also if the version string includes a commit hash, like `perf version 6.12.9.g242e6068fd5c`
1 parent 5518c2a commit b6c92ec

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Lib/test/test_perf_profiler.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -493,15 +493,16 @@ def compile_trampolines_for_all_functions():
493493

494494
def _is_perf_version_at_least(major, minor):
495495
# The output of perf --version looks like "perf version 6.7-3" but
496-
# it can also be perf version "perf version 5.15.143"
496+
# it can also be perf version "perf version 5.15.143", or even include
497+
# a commit hash in the version string, like "6.12.9.g242e6068fd5c"
497498
try:
498499
output = subprocess.check_output(["perf", "--version"], text=True)
499500
except (subprocess.CalledProcessError, FileNotFoundError):
500501
return False
501502
version = output.split()[2]
502503
version = version.split("-")[0]
503504
version = version.split(".")
504-
version = tuple(map(int, version))
505+
version = tuple(map(int, version[:2]))
505506
return version >= (major, minor)
506507

507508

0 commit comments

Comments
 (0)