Commit d653bdc6 authored by Julien Lopez's avatar Julien Lopez

Add script to install git hooks. Add hook to check cduce before

committing. To install the hooks locally: tools/install_hooks.sh
parent 0a52c207
......@@ -5,6 +5,7 @@
ROOT=`dirname $0`
EXTENDED="false"
RET=0
SCHEMADIR=$ROOT/schema
SCHEMATESTS="$SCHEMADIR/library1.xsd $SCHEMADIR/library2.xsd\
......@@ -24,7 +25,8 @@ OCAMLDIR=$ROOT/ocaml
# Parse options
while test $# -ne 0; do
if test $1 = "-e"; then EXTENDED="true"; fi; shift;
if test $1 = "-e" || test $1 = "--extended"; then EXTENDED="true"; fi;
shift;
done
# Test schema
......@@ -35,12 +37,14 @@ if test $EXTENDED = "false"; then
else
$SCHEMASCRIPT $SCHEMACDFILE $SCHEMALOGFILE $SCHEMADIR/*.xsd
fi
test $? -ne 0 && RET=1
echo " passed."
# Test regtest
echo -n "Tests on regtest: "
$REGSCRIPT $REGCDFILE $REGLOGFILE $REGDIR/*.xsd
test $? -ne 0 && RET=1
echo " passed."
# Test xsltmark
......@@ -72,6 +76,7 @@ for i in $GOODTESTS; do
done
echo "$SUCCESS / $TOTAL passed."
test $SUCCESS -ne $TOTAL && RET=1
# Test misc
......@@ -111,6 +116,7 @@ for i in $BADTESTS; do
done
echo "$SUCCESS / $TOTAL passed."
test $SUCCESS -ne $TOTAL && RET=1
# Test ocamlinterface
......@@ -123,18 +129,21 @@ $ROOT/../cduce -I $OCAMLDIR/misc --mlstub $OCAMLDIR/misc/consts.cdo > $OCAMLDIR/
$ROOT/../cduce -I $OCAMLDIR/misc --mlstub $OCAMLDIR/misc/misc.cdo > $OCAMLDIR/misc/misc.ml
ocamlfind ocamlc -I $OCAMLDIR/misc -g -package cduce,oUnit -linkpkg -o $OCAMLDIR/misc/misc $OCAMLDIR/misc/consts.ml $OCAMLDIR/misc/misc.ml $OCAMLDIR/misc/misctest.ml
$OCAMLDIR/misc/misc 2> /dev/null
test $? -ne 0 && RET=1
ocamlc -I $OCAMLDIR/eval -c $OCAMLDIR/eval/eval.mli
$ROOT/../cduce -I $OCAMLDIR/eval --compile $OCAMLDIR/eval/eval.cd -I $OCAML_TOPLEVEL_PATH/../cduce
$ROOT/../cduce -I $OCAMLDIR/eval --mlstub $OCAMLDIR/eval/eval.cdo > $OCAMLDIR/eval/eval.ml
ocamlfind ocamlc -I $OCAMLDIR/eval -package cduce,oUnit -linkpkg -o $OCAMLDIR/eval/eval $OCAMLDIR/eval/eval.ml $OCAMLDIR/eval/evaltest.ml
$OCAMLDIR/eval/eval
test $? -ne 0 && RET=1
ocamlc -I $OCAMLDIR/cdnum -c $OCAMLDIR/cdnum/cdnum.mli
$ROOT/../cduce -I $OCAMLDIR/cdnum --compile $OCAMLDIR/cdnum/cdnum.cd -I `ocamlfind query num`
$ROOT/../cduce -I $OCAMLDIR/cdnum --mlstub $OCAMLDIR/cdnum/cdnum.cdo > $OCAMLDIR/cdnum/cdnum.ml
ocamlfind ocamlc -I $OCAMLDIR/cdnum -package cduce,num,oUnit -linkpkg -o $OCAMLDIR/cdnum/cdnum $OCAMLDIR/cdnum/cdnum.ml $OCAMLDIR/cdnum/cdnumtest.ml
$OCAMLDIR/cdnum/cdnum
test $? -ne 0 && RET=1
if test $EXTENDED = "true"; then
ocamlc -I $OCAMLDIR/cdsdl -c -I `ocamlfind query sdl` $OCAMLDIR/cdsdl/cdsdl.mli
......@@ -142,10 +151,14 @@ if test $EXTENDED = "true"; then
$ROOT/../cduce -I $OCAMLDIR/cdsdl --mlstub -I `ocamlfind query sdl` $OCAMLDIR/cdsdl/cdsdl.cdo > $OCAMLDIR/cdsdl/cdsdl.ml
ocamlfind ocamlc -I $OCAMLDIR/cdsdl -package cduce,sdl,oUnit -linkpkg -o $OCAMLDIR/cdsdl/cdsdl $OCAMLDIR/cdsdl/cdsdl.ml $OCAMLDIR/cdsdl/cdsdltest.ml
$OCAMLDIR/cdsdl/cdsdl
test $? -ne 0 && RET=1
ocamlc -I $OCAMLDIR/latypes -c $OCAMLDIR/latypes/latypes.mli
$ROOT/../cduce -I $OCAMLDIR/latypes --compile $OCAMLDIR/latypes/latypes.cd
$ROOT/../cduce -I $OCAMLDIR/latypes --mlstub $OCAMLDIR/latypes/latypes.cdo > $OCAMLDIR/latypes/latypes2.ml
ocamlfind ocamlc -I $OCAMLDIR/latypes -package cduce,num,oUnit -linkpkg -o $OCAMLDIR/latypes/latypes $OCAMLDIR/latypes/latypes.ml $OCAMLDIR/latypes/latypes2.ml $OCAMLDIR/latypes/latypestest.ml
$OCAMLDIR/latypes/latypes
test $? -ne 0 && RET=1
fi
exit $RET
ROOTDIR="$(git rev-parse --git-dir)"
cd $ROOTDIR/..
echo "Testing the program before commit..."
echo -n "Building cduce..."
make > /dev/null 2> /dev/null
echo "done."
if test $? -ne 0; then
echo "Building cduce failed. Aborting commit."
exit 2
fi
echo "Testing..."
tests/test.sh
if test $? -ne 0; then
echo "Tests failed. Aborting commit."
exit 2
fi
echo "Success!"
exit 0
#!/bin/sh
HOOKSDIR=$(git rev-parse --show-toplevel)/tools/git_hooks
HOOKS=pre-commit
GITHOOKSDIR=$(git rev-parse --show-toplevel)/.git/hooks
echo "Installing git hooks to local repository..."
for i in $HOOKS; do
echo -n "Installing $HOOKSDIR/$i..."
if test -e $GITHOOKSDIR/$i && test ! -h $GITHOOKSDIR/$i; then
echo -n "\nWarning: $GITHOOKSDIR/$i already exists and is not a symbolic"
echo " link. $HOOKSDIR/$i not installed."
else
ln -sf $HOOKSDIR/$i $GITHOOKSDIR/$i
echo "done."
fi
done
echo "Finished."
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment