6e4f27b13965d8a89bfe81bbd5040e48dd1ced8f
[sawsim.git] / misc / hooks / pre-commit-pysawsim-check
1 #!/bin/sh
2
3 HAS_MPD=$(which mpdallexit 2>/dev/null)
4
5 if [ -n "$HAS_MPD" ]; then
6
7     LOCAL_MPD=''
8
9     mpdtrace >/dev/null 2>&1
10     if [ "$?" -ne 0 ]; then
11         LOCAL_MPD='1'
12         mpd &    # start an mpd instance
13         sleep 1  # give mpd some time to start up
14     fi           # otherwise there is an mpd instance already running
15
16     mpiexec -n 1 nosetests --with-doctest --doctest-tests pysawsim
17     RESULT="$?"
18
19     if [ -n "$LOCAL_MPD" ]; then
20         mpdallexit
21     fi
22
23     if [ "$RESULT" -ne 0 ]; then
24         exit 1;
25     fi
26
27 else  # no MPD
28
29     nosetests --with-doctest --doctest-tests pysawsim || exit 1
30
31 fi