diff --git a/.travis.yml b/.travis.yml index 948de48863ec36389337beb273d9599888f7c05a..0734177bc23476f24736bc4e27bb7e4cbd04fd5d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,6 +17,8 @@ install: # Build gflags # TODO(noetzli): Remove when gflags available through Travis - pushd /tmp/ && curl -L https://github.com/gflags/gflags/archive/v2.1.2.tar.gz -o gflags.tar.gz && tar xfz gflags.tar.gz && cd gflags-2.1.2 && cmake . && make && popd + # Download clang-format-diff.py to check source code formatting + - pushd /tmp/ && curl -L http://llvm.org/svn/llvm-project/cfe/trunk/tools/clang-format/clang-format-diff.py -o clang-format-diff.py && chmod +x clang-format-diff.py && popd before_script: # Add gflags to include/library paths @@ -30,7 +32,7 @@ before_script: # Lousy hack to disable use and testing of fallocate, which doesn't behave quite # as EnvPosixTest::AllocateTest expects within the Travis OpenVZ environment. -script: OPT=-DTRAVIS V=1 make -j4 check && OPT=-DTRAVIS V=1 make clean jclean rocksdbjava jtest +script: OPT=-DTRAVIS CLANG_FORMAT_DIFF=/tmp/clang-format-diff.py make format && OPT=-DTRAVIS V=1 make -j4 check && OPT=-DTRAVIS V=1 make clean jclean rocksdbjava jtest notifications: email: diff --git a/build_tools/format-diff.sh b/build_tools/format-diff.sh index 2d60620091f98cac658b52714897b859f915de4e..5b2efdd1a9e7b09947a15862394d0968ebf04d7c 100755 --- a/build_tools/format-diff.sh +++ b/build_tools/format-diff.sh @@ -79,6 +79,12 @@ echo -e "Detect lines that doesn't follow the format rules:\r" echo "$diffs" | sed -e "s/\(^-.*$\)/`echo -e \"$COLOR_RED\1$COLOR_END\"`/" | sed -e "s/\(^+.*$\)/`echo -e \"$COLOR_GREEN\1$COLOR_END\"`/" + +if [[ "$OPT" == *"-DTRAVIS"* ]] +then + exit 1 +fi + echo -e "Would you like to fix the format automatically (y/n): \c" # Make sure under any mode, we can read user input.