unittest.sh 638 字节
Newer Older
Y
yangyaming 已提交
1 2 3 4 5 6 7 8 9 10
#!/bin/bash

abort(){
    echo "Run unittest failed" 1>&2
    echo "Please check your code" 1>&2
    exit 1
}

unittest(){
    cd $1 > /dev/null
Y
yangyaming 已提交
11 12
    if [ -f "setup.sh" ]; then
        sh setup.sh
L
Luo Tao 已提交
13
        export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
Y
yangyaming 已提交
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
    fi
    if [ $? != 0 ]; then
        exit 1
    fi
    find . -name 'tests' -type d -print0 | \
        xargs -0 -I{} -n1 bash -c \
        'python -m unittest discover -v -s {}'
    cd - > /dev/null
}

trap 'abort' 0
set -e

for proj in */ ; do
    if [ -d $proj ]; then
        unittest $proj
        if [ $? != 0 ]; then
            exit 1
        fi
    fi
done

trap : 0