source: libcaca/trunk/test/check-source @ 4352

Last change on this file since 4352 was 4352, checked in by Sam Hocevar, 10 years ago

Make the check-source test more generic.

  • Property svn:executable set to *
File size: 856 bytes
Line 
1#!/bin/sh
2
3#
4# Check that we have no tabs or trailing spaces in the source code
5#
6nfails=0
7nfiles=0
8nlines=0
9for dir in $(make -s echo-dirs -C ..); do
10  if [ ! -d "../$dir" ]; then continue; fi
11  for x in $(make -s echo-sources -C ../$dir); do
12    case "$x" in
13      *.c|*.cpp|*.h|*.m|*.php|*.cs|*.java|.py|.pl)
14        nfiles=$(($nfiles + 1));
15        nlines=$(($nlines + `grep -c . "../$dir/$x"`)) ;;
16      *)
17        continue ;;
18    esac
19    if grep '[[:space:]]$' "../$dir/$x" >/dev/null 2>&1; then
20      echo "error: $dir/$x contains trailing spaces"
21      nfails=$(($nfails + 1))
22    fi
23    if grep '   ' "../$dir/$x" >/dev/null 2>&1; then
24      echo "error: $dir/$x contains tabs"
25      nfails=$(($nfails + 1))
26    fi
27  done
28done
29
30echo "$nfiles files, $nlines lines, $nfails errors in source code"
31
32if test "$nfails" != "0"; then
33  exit 1
34fi
35
36exit 0
37
Note: See TracBrowser for help on using the repository browser.