Support running a specific clang-format version in CI

This commit is contained in:
Petri Lehtinen 2019-10-17 11:41:16 +03:00
parent 1a95a60f80
commit 7c0297abe8
2 changed files with 7 additions and 2 deletions

View File

@ -29,4 +29,4 @@ script:
- if [ "$JANSSON_BUILD_METHOD" = "cmake" ]; then mkdir build && cd build && cmake $JANSSON_CMAKE_OPTIONS .. && cmake --build . && ctest --output-on-failure; fi - if [ "$JANSSON_BUILD_METHOD" = "cmake" ]; then mkdir build && cd build && cmake $JANSSON_CMAKE_OPTIONS .. && cmake --build . && ctest --output-on-failure; fi
- if [ "$JANSSON_BUILD_METHOD" = "coverage" ]; then mkdir build && cd build && cmake $JANSSON_CMAKE_OPTIONS .. && cmake --build . && cmake --build . --target coveralls; fi - if [ "$JANSSON_BUILD_METHOD" = "coverage" ]; then mkdir build && cd build && cmake $JANSSON_CMAKE_OPTIONS .. && cmake --build . && cmake --build . --target coveralls; fi
- if [ "$JANSSON_BUILD_METHOD" = "fuzzer" ]; then ./test/ossfuzz/travisoss.sh; fi - if [ "$JANSSON_BUILD_METHOD" = "fuzzer" ]; then ./test/ossfuzz/travisoss.sh; fi
- if [ "$JANSSON_BUILD_METHOD" = "lint" ]; then ./scripts/clang-format-ci; fi - if [ "$JANSSON_BUILD_METHOD" = "lint" ]; then ./scripts/clang-format-ci 9; fi

View File

@ -1,10 +1,15 @@
#!/bin/bash #!/bin/bash
clangformat="clang-format"
if [ -n "$1" ]; then
clangformat="clang-format-$1"
fi
errors=0 errors=0
paths=$(find . -type f -a '(' -name '*.c' -o -name '*.h' ')') paths=$(find . -type f -a '(' -name '*.c' -o -name '*.h' ')')
for path in $paths; do for path in $paths; do
in=$(cat $path) in=$(cat $path)
out=$(clang-format $path) out=$($clangformat $path)
if [ "$in" != "$out" ]; then if [ "$in" != "$out" ]; then
diff -u -L $path -L "$path.formatted" $path - <<<$out diff -u -L $path -L "$path.formatted" $path - <<<$out