3
0

unittest.sh 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/bin/bash
  2. abort(){
  3. echo "Run unittest failed" 1>&2
  4. echo "Please check your code" 1>&2
  5. echo " 1. you can run unit tests by 'bash .travis/unittest.sh' locally" 1>&2
  6. echo " 2. you can add python requirements in .travis/requirements.txt if you use new requirements in unit tests" 1>&2
  7. exit 1
  8. }
  9. unittest(){
  10. if [ $? != 0 ]; then
  11. exit 1
  12. fi
  13. find "./ppdet" -name 'tests' -type d -print0 | \
  14. xargs -0 -I{} -n1 bash -c \
  15. 'python -m unittest discover -v -s {}'
  16. }
  17. trap 'abort' 0
  18. set -e
  19. # install travis python dependencies exclude pycocotools
  20. if [ -f ".travis/requirements.txt" ]; then
  21. pip install -r .travis/requirements.txt
  22. fi
  23. # install pycocotools
  24. if [ `pip list | grep pycocotools | wc -l` -eq 0 ]; then
  25. # install git if needed
  26. if [ -n `which git` ]; then
  27. apt-get update
  28. apt-get install -y git
  29. fi;
  30. git clone https://github.com/cocodataset/cocoapi.git
  31. cd cocoapi/PythonAPI
  32. make install
  33. python setup.py install --user
  34. cd ../..
  35. rm -rf cocoapi
  36. fi
  37. export PYTHONPATH=`pwd`:$PYTHONPATH
  38. unittest .
  39. trap : 0