Commit 581fc7d0 authored by Brenden Blanco's avatar Brenden Blanco

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.
parent af8552be
#!/usr/bin/env python
#!/usr/bin/env python2
#
#===- git-clang-format - ClangFormat Git Integration ---------*- python -*--===#
#
......
#!/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
......@@ -4,6 +4,8 @@ configure_file(wrapper.sh.in "${CMAKE_CURRENT_BINARY_DIR}/wrapper.sh" @ONLY)
set(TEST_WRAPPER ${CMAKE_CURRENT_BINARY_DIR}/wrapper.sh)
add_test(NAME style-check COMMAND ${CMAKE_SOURCE_DIR}/scripts/style-check.sh)
add_subdirectory(cc)
add_subdirectory(python)
add_subdirectory(lua)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment