-
Notifications
You must be signed in to change notification settings - Fork 15.5k
[lldb][windows] refactor the version check in @skipIfWindows #172838
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ | |
| import subprocess | ||
| import sys | ||
| import os | ||
| from typing import Optional | ||
| from packaging import version | ||
| from urllib.parse import urlparse | ||
|
|
||
|
|
@@ -300,6 +301,25 @@ def getCompilerVersion(): | |
| return "unknown" | ||
|
|
||
|
|
||
| def getWindowsVersion(): | ||
| """Returns a string that represents the Windows version. | ||
|
|
||
| The string is a concatenation of the following, separated by a dot: | ||
| - The major version number. | ||
| - The build number. | ||
|
|
||
| Example: | ||
| - Windows 11 version 24H2 -> "10.0.26100" | ||
| - Windows 10 version 1809 -> "10.0.17763" | ||
| """ | ||
| import sys | ||
|
|
||
| if sys.platform != "win32": | ||
| return "unknown" | ||
| windows_version = sys.getwindowsversion() | ||
DavidSpickett marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return f"{windows_version.major}.{windows_version.minor}.{windows_version.build}" | ||
|
|
||
|
|
||
| def getDwarfVersion(): | ||
| """Returns the dwarf version generated by clang or '0'.""" | ||
| if configuration.dwarf_version: | ||
|
|
@@ -322,8 +342,34 @@ def getDwarfVersion(): | |
| return "0" | ||
|
|
||
|
|
||
| def isExpectedVersion( | ||
| actual_version: str, required_version: str, operator: str | ||
| ) -> bool: | ||
| """Returns True iff actual_version matches the required_version given the operator. | ||
| Any operator other than the following defaults to an equality test: | ||
DavidSpickett marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| '>', '>=', "=>", '<', '<=', '=<', '!=', "!" or 'not' | ||
|
|
||
| Example: | ||
| - actual_version='1.2.0', required_version='1.0.0', operator='>=' returns True | ||
| """ | ||
| actual_version_ = version.parse(actual_version) | ||
| required_version_ = version.parse(required_version) | ||
|
|
||
| if operator == ">": | ||
| return actual_version_ > required_version_ | ||
| if operator == ">=" or operator == "=>": | ||
| return actual_version_ >= required_version_ | ||
| if operator == "<": | ||
| return actual_version_ < required_version_ | ||
| if operator == "<=" or operator == "=<": | ||
| return actual_version_ <= required_version_ | ||
| if operator == "!=" or operator == "!" or operator == "not": | ||
| return actual_version not in required_version | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could use the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this would lead to unexpected test failures due to #172838 (comment). |
||
| return actual_version in required_version | ||
|
|
||
|
|
||
| def expectedCompilerVersion(compiler_version): | ||
| """Returns True iff compiler_version[1] matches the current compiler version. | ||
| """Returns True if compiler_version[1] matches the current compiler version. | ||
DavidSpickett marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Use compiler_version[0] to specify the operator used to determine if a match has occurred. | ||
| Any operator other than the following defaults to an equality test: | ||
| '>', '>=', "=>", '<', '<=', '=<', '!=', "!" or 'not' | ||
|
|
@@ -342,23 +388,14 @@ def expectedCompilerVersion(compiler_version): | |
|
|
||
| test_compiler_version_str = getCompilerVersion() | ||
| if test_compiler_version_str == "unknown": | ||
| # Assume the compiler version is at or near the top of trunk. | ||
| # Assume the version is at or near the top of trunk. | ||
| return operator in [">", ">=", "!", "!=", "not"] | ||
|
|
||
| actual_version = version.parse(version_str) | ||
| test_compiler_version = version.parse(test_compiler_version_str) | ||
|
|
||
| if operator == ">": | ||
| return test_compiler_version > actual_version | ||
| if operator == ">=" or operator == "=>": | ||
| return test_compiler_version >= actual_version | ||
| if operator == "<": | ||
| return test_compiler_version < actual_version | ||
| if operator == "<=" or operator == "=<": | ||
| return test_compiler_version <= actual_version | ||
| if operator == "!=" or operator == "!" or operator == "not": | ||
| return version_str not in test_compiler_version_str | ||
| return version_str in test_compiler_version_str | ||
| return isExpectedVersion( | ||
| actual_version=test_compiler_version_str, | ||
| required_version=version_str, | ||
| operator=operator, | ||
| ) | ||
|
|
||
|
|
||
| def expectedCompiler(compilers): | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.