forked from iovisor/bcc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ctest for style, using clang-format
When user touches a file, that file will be fed to `git clang-format`, and if the tool reports a new diff it will consider the test failed. The files to check will be anything in the current workspace compared to origin/master.
- Loading branch information
Brenden Blanco
committed
Apr 19, 2016
1 parent
af8552b
commit 581fc7d
Showing
3 changed files
with
28 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/bash | ||
|
||
# Runs clang-format on the files changed between HEAD and $1, which defaults to | ||
# origin/master. | ||
|
||
# to pick up git-clang-format from scripts/ | ||
export PATH=$(dirname $0):$PATH | ||
|
||
CLANG_FORMAT=${CLANG_FORMAT:-clang-format} | ||
GITREF=${1:-origin/master} | ||
|
||
if ! hash $CLANG_FORMAT 2> /dev/null; then | ||
echo "Could not find clang-format tool" 1>&2 | ||
exit 1 | ||
fi | ||
|
||
n=$(git clang-format $GITREF --binary $CLANG_FORMAT --style llvm --diff --quiet | wc -l) | ||
if [ $n -gt 0 ]; then | ||
echo "git clang-format $GITREF --binary $CLANG_FORMAT --style llvm --diff" | ||
echo | ||
git clang-format $GITREF --binary $CLANG_FORMAT --style llvm --diff | ||
echo | ||
echo "clang-format returned non-empty diff, please fixup the style" 1>&2 | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters