mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-19 06:09:01 +00:00
Add clang-format config and check-format.sh script (#724)
* Add clang-format config and check-format.sh script Travis CI is now configured to run check-format.sh and the job will fail if any format violations are detected. This will only check the format of new/modified code; existing code that violates the format will not cause a CI failure. * Make format checking the first Travis CI job * Tweak format based on Jeremy's preferences * Tweak format based on Kevin's preferences
This commit is contained in:
13
check-format.sh
Executable file
13
check-format.sh
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Run git-clang-format to check for violations
|
||||
CLANG_FORMAT_OUTPUT=$(git-clang-format --diff origin/master --extensions c,cpp,h,hpp)
|
||||
|
||||
# Check for no-ops
|
||||
grep '^no modified files to format$' <<<"$CLANG_FORMAT_OUTPUT" && exit 0
|
||||
grep '^clang-format did not modify any files$' <<<"$CLANG_FORMAT_OUTPUT" && exit 0
|
||||
|
||||
# Dump formatting diff and signal failure
|
||||
echo -e "\n==== FORMATTING VIOLATIONS DETECTED ====\n"
|
||||
echo "$CLANG_FORMAT_OUTPUT"
|
||||
exit 1
|
||||
Reference in New Issue
Block a user