source: neercs/trunk/test/check-copyright @ 4367

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

Add unit test for copyright information.

  • Property svn:executable set to *
File size: 1014 bytes
Line 
1#!/bin/sh
2
3#
4# Check that the copyright information is valid
5#
6nfails=0
7nfiles=0
8for dir in $(make -s echo-dirs -C ..); do
9  if [ ! -d "../$dir" ]; then continue; fi
10  for x in $(make -s echo-sources -C ../$dir); do
11    case "$x" in
12      *.c|*.cpp|*.h|*.m|*.php|*.cs|*.java|.py|.pl)
13        nfiles=$(($nfiles + 1)) ;;
14      *)
15        continue ;;
16    esac
17    if ! grep 'Copyright *([cC])' "../$dir/$x" >/dev/null 2>&1; then
18      echo "error: $dir/$x lacks proper copyright information"
19      nfails=$(($nfails + 1))
20    fi
21    if [ -d ../.git ]; then
22      Y="$(git log "../$dir/$x" | head -n 3 | sed -ne 's/^Date.* \([0-9][0-9][0-9][0-9]\) .*/\1/p')"
23      if [ "$Y" != "" ]; then
24        if ! grep "$Y.*@" "../$dir/$x" >/dev/null 2>&1; then
25          echo "error: $dir/$x last modified in $Y, which is not in copyright"
26          nfails=$(($nfails + 1))
27        fi
28      fi
29    fi
30  done
31done
32
33echo "$nfiles files, $nfails errors in copyright information"
34
35if test "$nfails" != "0"; then
36  exit 1
37fi
38
39exit 0
40
Note: See TracBrowser for help on using the repository browser.