]> git.sur5r.net Git - i3/i3/blobdiff - .travis.yml
travis: install clang-format-3.5 from llvm repository
[i3/i3] / .travis.yml
index 1c801609947d9a1d6690e526c0ee998c4cf8117b..dd1fb156142fb237313a7fa9a09f4c2e87c91e34 100644 (file)
@@ -2,6 +2,15 @@ language: c
 compiler:
   - gcc
   - clang
+addons:
+  apt:
+    sources:
+    - llvm-toolchain-precise-3.5
+    # ubuntu-toolchain-r-test contains libstdc++6 >= 4.8 which libllvm3.5 needs.
+    - ubuntu-toolchain-r-test
+    packages:
+    - clang-format-3.5
+    - libllvm3.5
 before_install:
   # The travis VMs run on Ubuntu 12.04 which is very old and a huge pain to get
   # into a state where we can build a recent version of i3 :(.
@@ -31,11 +40,33 @@ before_install:
   - sudo cp /tmp/pin /etc/apt/preferences.d/trustypin
   - sudo apt-get update
   - sudo apt-get install -t trusty libc6 libc6-dev
-  - sudo apt-get install --no-install-recommends devscripts equivs
+  - sudo apt-get install --no-install-recommends devscripts equivs xdotool
 install:
   - sudo mk-build-deps --install --remove --tool 'apt-get --no-install-recommends' debian/control
   # Install as many dependencies as possible via apt because cpanm is not very reliable/easy to debug.
-  - sudo apt-get install --no-install-recommends libanyevent-perl libanyevent-i3-perl libextutils-pkgconfig-perl xcb-proto cpanminus xvfb xserver-xephyr xauth libinline-perl libxml-simple-perl libmouse-perl libmousex-nativetraits-perl libextutils-depends-perl perl-modules libtest-deep-perl libtest-exception-perl libxml-parser-perl libtest-simple-perl libtest-fatal-perl libdata-dump-perl libtest-differences-perl libxml-tokeparser-perl libtest-use-ok-perl
+  - sudo apt-get install --no-install-recommends libanyevent-perl libanyevent-i3-perl libextutils-pkgconfig-perl xcb-proto cpanminus xvfb xserver-xephyr xauth libinline-perl libxml-simple-perl libmouse-perl libmousex-nativetraits-perl libextutils-depends-perl perl-modules libtest-deep-perl libtest-exception-perl libxml-parser-perl libtest-simple-perl libtest-fatal-perl libdata-dump-perl libtest-differences-perl libxml-tokeparser-perl libtest-use-ok-perl libipc-run-perl
   - sudo /bin/sh -c 'cpanm -n -v X11::XCB || true'
-script: make -j && (cd testcases && xvfb-run ./complete-run.pl)
-after_failure: cat /home/travis/.cpanm/build.log
+  - sudo /bin/sh -c 'cpanm -n -v AnyEvent::I3 || true'
+script:
+  - CFLAGS="-Wformat -Wformat-security -Wextra -Wno-unused-parameter -Werror" make -j
+  - (cd testcases && xvfb-run ./complete-run.pl --parallel=1 || (cat latest/complete-run.log; false))
+  - clang-format-3.5 -i $(find . -name "*.[ch]" | tr '\n' ' ') && git diff --exit-code || (echo 'Code was not formatted using clang-format!'; false)
+  - |
+    funcs='malloc|calloc|realloc|strdup|strndup|asprintf|write'
+    cstring='"([^"\\]|\\.)*"'
+    cchar="'[^\\\\]'|'\\\\.[^']*'"
+    regex="^([^'\"]|${cstring}|${cchar})*\<(${funcs})\>"
+    detected=0
+    while IFS= read -r file; do
+        if { cpp -w -fpreprocessed "$file" || exit "$?"; } | grep -E -- "$regex"; then
+            echo "^ $file calls a function that has a safe counterpart."
+            detected=1
+        fi
+    done << EOF
+    $(find -name '*.c' -not -name safewrappers.c -not -name strndup.c)
+    EOF
+    if [ "$detected" -ne 0 ]; then
+        echo
+        echo "Calls of functions that have safe counterparts were detected."
+        exit 1
+    fi