diff options
author | Gennadiy Civil <misterg@google.com> | 2018-09-25 06:42:15 (GMT) |
---|---|---|
committer | Gennadiy Civil <misterg@google.com> | 2018-09-25 06:42:15 (GMT) |
commit | 2d3466be4785560cfc93680e28f9afb92e656665 (patch) | |
tree | 581f05fab5ea940469b29169d96becfb7eaf9071 /ci | |
parent | ed6e84ccef7f3c0f31caca60a47077a46d72a806 (diff) | |
download | googletest-2d3466be4785560cfc93680e28f9afb92e656665.zip googletest-2d3466be4785560cfc93680e28f9afb92e656665.tar.gz googletest-2d3466be4785560cfc93680e28f9afb92e656665.tar.bz2 |
Add clang format check to one of the builds to provide indication that formatting is incorrect
Diffstat (limited to 'ci')
-rwxr-xr-x | ci/test-format.sh | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/ci/test-format.sh b/ci/test-format.sh new file mode 100755 index 0000000..502c84c --- /dev/null +++ b/ci/test-format.sh @@ -0,0 +1,33 @@ +#!/bin/bash +echo "clang-format - checking Code Formatting..." + +if [[ "${TRAVIS_OS_NAME}" == "linux" ]] && \ + [[ "${TEST_CLANG_FORMAT}" == "yes" ]]; then + + RETURN=0 + CLANG_FORMAT="clang-format-3.9" + + which clang-format-3.9 + + if [ ! -f ".clang-format" ]; then + echo ".clang-format file not found!" + exit 1 + fi + + FILES=`git diff master --name-only | grep -E "\.(cc|cpp|h)$"` + + for FILE in $FILES; do + + $CLANG_FORMAT $FILE | cmp $FILE >/dev/null + + if [ $? -ne 0 ]; then + echo "[!] Clang-Format Found INCORRECT FORMATTING. Please re-format and re-submit. The following file failed: $FILE" >&2 + RETURN=1 + fi + + done + + exit $RETURN +fi + +exit 0 |