-
Notifications
You must be signed in to change notification settings - Fork 675
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
Refactored clang version check into a python script. #1471
Changes from 2 commits
37de157
0cb52f8
c0b4713
c6efe07
aabbbba
4349193
de4d3d8
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import subprocess | ||
|
||
EXPECTED_CLANG_VERSION = "18.1.6" | ||
|
||
|
||
def main(): | ||
result = subprocess.run("clang-format --version", capture_output=True) | ||
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.
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. Fixed c6efe07 |
||
result.check_returncode() | ||
|
||
version_str = result.stdout.decode("utf-8").split(" ")[2].strip() | ||
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. nit: the default split character is space, so you can just do: 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. Thanks. Updated in de4d3d8 |
||
if version_str != EXPECTED_CLANG_VERSION: | ||
print( | ||
f"Error: Found clang-format version {version_str}, but {EXPECTED_CLANG_VERSION} is required." | ||
) | ||
exit(1) | ||
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. In python the convention is to throw an exception. It's exit value is raise ValueError(f"Error: Found clang-format version {version_str}, but {EXPECTED_CLANG_VERSION} is required.") 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. Fixed c0b4713 |
||
|
||
print("Clang format version satisfied.") | ||
exit(0) | ||
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. This line is not needed. The default exit value is 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. Fixed c0b4713 |
||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
explicitly use Python3?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure.
subprocess.run
is not supported pre python 3.5 anyway.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed aabbbba