Follow upstream changes -- rest
[git-darcs-import.git] / tests / haskell_policy.sh
bloba8219ff684a1b94132556b6d170cae56ffd72387
1 #!/usr/bin/env bash
3 RESULT=tmpfile
4 ROOT=..
5 ERRORSTATUS=0
7 # lookfor ( $1=what, $2=reason, $3=source module exception )
8 lookfor () {
9 rm -f "$RESULT"
10 darcs query manifest --repodir="$ROOT" | grep '\.l\?hs$' | while read f; do
11 grep -FHnwe "$1" "$ROOT/$f" | grep -v "$3\.$1" | \
12 grep -v ":[0-9]\+:import " | grep -Fv "ratify $1: " >> "$RESULT"
13 done
14 if [ -s "$RESULT" ]; then
15 echo "Found the following unratified uses of $1:"
16 # ugly sed expresion to fix relative paths; think pretty cat
17 sed -e 's/[^:]*\/\.\///' "$RESULT"
18 echo "$2"
19 echo "Comment 'ratify $1: <why>' on the same line to allow it"
20 echo
21 ERRORSTATUS=1
23 rm -f "$RESULT"
27 lookfor readFile \
28 "readFile doesn't ensure the file is closed before it is deleted!" \
29 B # importing readFile from Data.ByteString as B, is allowed
31 lookfor hGetContents \
32 "hGetContents doesn't ensure the file is closed before it is deleted!"
34 # look for tabs in haskell source
35 rm -f "$RESULT"
36 darcs query manifest --repodir="$ROOT" | grep '\.l\?hs$' | while read f; do
37 grep -FHnwe " " "$ROOT/$f" >> "$RESULT"
38 done
39 if [ -s "$RESULT" ]; then
40 echo "Found the following lines with unwanted tabs:"
41 # ugly sed expresion to fix relative paths; think pretty cat
42 sed -e 's/[^:]*\/\.\///' "$RESULT"
43 echo
44 ERRORSTATUS=1
46 rm -f "$RESULT"
48 exit "$ERRORSTATUS"