diff --git a/.travis.yml b/.travis.yml index f069c12016c0bc0cac26bf028e4f8fd025b2842a..a5559a796351bb10eacd4739f719b054e085160c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,9 +21,8 @@ before_install: - docker pull paddlepaddle/paddle:latest script: - .travis/precommit.sh - - docker run -i --rm -v "$PWD:/py_unittest" paddlepaddle/paddle:latest /bin/bash -c - "cd /py_unittest && find . -name 'tests' -type d -print0 | xargs -0 -I{} -n1 bash -c 'cd {}; - python -m unittest discover -v'" + - docker run -i --rm -v "$PWD:/py_unittest" paddlepaddle/paddle:latest /bin/bash -c + 'cd /py_unittest; sh .travis/unittest.sh' notifications: email: diff --git a/.travis/unittest.sh b/.travis/unittest.sh new file mode 100755 index 0000000000000000000000000000000000000000..23f15094c8e51132cff350e786654e3bab29cee1 --- /dev/null +++ b/.travis/unittest.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +abort(){ + echo "Run unittest failed" 1>&2 + echo "Please check your code" 1>&2 + exit 1 +} + +unittest(){ + cd $1 > /dev/null + if [ -f "requirements.txt" ]; then + pip install -r requirements.txt + 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