From f912430cda4a9c3379d5781057297ff2ed453ba0 Mon Sep 17 00:00:00 2001 From: Petri Lehtinen Date: Sat, 19 Oct 2019 20:46:34 +0300 Subject: [PATCH] Run clang-format with make check --- .gitignore | 2 ++ .travis.yml | 2 +- Makefile.am | 2 ++ scripts/{clang-format-ci => clang-format-check} | 6 ++++++ test/.gitignore | 4 ---- 5 files changed, 11 insertions(+), 5 deletions(-) rename scripts/{clang-format-ci => clang-format-check} (77%) diff --git a/.gitignore b/.gitignore index 4d62549..0a985b4 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,5 @@ stamp-h1 *.exe .idea cmake-build-debug/ +*.log +*.trs \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index df74eb2..a1f736b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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" = "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" = "lint" ]; then ./scripts/clang-format-ci 9; fi + - if [ "$JANSSON_BUILD_METHOD" = "lint" ]; then ./scripts/clang-format-check 9; fi diff --git a/Makefile.am b/Makefile.am index 0de2ac1..285d2f0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -8,3 +8,5 @@ dvi: pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = jansson.pc + +TESTS = scripts/clang-format-check diff --git a/scripts/clang-format-ci b/scripts/clang-format-check similarity index 77% rename from scripts/clang-format-ci rename to scripts/clang-format-check index 6854fc2..f3f0f6d 100755 --- a/scripts/clang-format-ci +++ b/scripts/clang-format-check @@ -5,6 +5,12 @@ if [ -n "$1" ]; then clangformat="clang-format-$1" fi +if ! type $clangformat >/dev/null; then + # clang-format not found. If running tests, mark this test as + # skipped. + exit 77 +fi + errors=0 paths=$(find . -type f -a '(' -name '*.c' -o -name '*.h' ')') for path in $paths; do diff --git a/test/.gitignore b/test/.gitignore index d643dc8..6a33dea 100644 --- a/test/.gitignore +++ b/test/.gitignore @@ -18,7 +18,3 @@ suites/api/test_simple suites/api/test_sprintf suites/api/test_unpack suites/api/test_version -run-suites.log -run-suites.trs -test-suite.log -