Permalink
Browse files

misc: add a travis check for trailing whitepsace

  • Loading branch information...
austin987 committed May 13, 2018
1 parent 5881efd commit cfe308c810bbbc24a3da985ebf787d47057afe63
Showing with 42 additions and 1 deletion.
  1. +4 −1 .travis.yml
  2. +38 −0 tests/whitespace-check
View
@@ -71,7 +71,10 @@ before_install:
# shell-checks is quick and works, no display or compiles needed
script: time sh ./tests/shell-checks
script:
- time sh ./tests/shell-checks
# Also check for trailing whitespace. Not doing in shell-checks because it depends on a clean tree (uses git diff):
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then time sh ./tests/whitespace-check; fi
# OS X doesn't allow writing to /usr/bin, skip non-PREFIX make install test there
install:
View
@@ -0,0 +1,38 @@
#!/bin/sh
set -x
# Invoked by travis to check for trailing whitespace
# Only in travis since local tree may have other diffs applied:
make cleanup
# Git diff doesn't show the trailing whitespace as of 2018/05/13.
# Tried various color/diff settings with no luck.
# The workaround is cat, but commands aren't standard on Linux/OS X
git diff --exit-code > whitespace.diff
ret="$?"
if [ "$ret" = 0 ]; then
echo "No trailing whitespace found."
exit 0
else
echo "There is trailing whitespace that needs to be fixed:"
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
cat -A whitespace.diff
elif [ "$TRAVIS_OS_NAME" = "osx" ]; then
# Currently unimpemented on OSX.
# sed will need to be fixed as well:
# sed --in-place 's,[ \t]\+$,,' $(find Makefile src tests -type f)
# sed: illegal option -- -
# usage: sed script [-Ealn] [-i extension] [file ...]
# sed [-Ealn] [-i extension] [-e script] ... [-f script_file] ... [file ...]
# make: *** [cleanup] Error 1
# cat -etv whitespace.diff
echo "Not fully implemented on osx yet"
else
echo "Unknown OS!"
fi
exit 1
fi

0 comments on commit cfe308c

Please sign in to comment.