diff_coverage_test.sh 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/bin/bash
  2. readarray -t IGNORED_FILES < $( dirname "$0" )/covignore.cfg
  3. REUSE_COVERAGE_REPORT=${REUSE_COVERAGE_REPORT:-0}
  4. REPO=${1:-"origin"}
  5. BRANCH=${2:-"refactor_dev"}
  6. git fetch $REPO $BRANCH
  7. PY_FILES=""
  8. for FILE_NAME in $(git diff --name-only ${REPO}/${BRANCH}); do
  9. # Only test python files in mmdet/ existing in current branch, and not ignored in covignore.cfg
  10. if [ ${FILE_NAME: -3} == ".py" ] && [ ${FILE_NAME:0:6} == "mmdet/" ] && [ -f "$FILE_NAME" ]; then
  11. IGNORED=false
  12. for IGNORED_FILE_NAME in "${IGNORED_FILES[@]}"; do
  13. # Skip blank lines
  14. if [ -z "$IGNORED_FILE_NAME" ]; then
  15. continue
  16. fi
  17. if [ "${IGNORED_FILE_NAME::1}" != "#" ] && [[ "$FILE_NAME" =~ $IGNORED_FILE_NAME ]]; then
  18. echo "Ignoring $FILE_NAME"
  19. IGNORED=true
  20. break
  21. fi
  22. done
  23. if [ "$IGNORED" = false ]; then
  24. PY_FILES="$PY_FILES $FILE_NAME"
  25. fi
  26. fi
  27. done
  28. # Only test the coverage when PY_FILES are not empty, otherwise they will test the entire project
  29. if [ ! -z "${PY_FILES}" ]
  30. then
  31. if [ "$REUSE_COVERAGE_REPORT" == "0" ]; then
  32. coverage run --branch --source mmdet -m pytest tests/
  33. fi
  34. coverage report --fail-under 80 -m $PY_FILES
  35. interrogate -v --ignore-init-method --ignore-module --ignore-nested-functions --ignore-magic --ignore-regex "__repr__" --fail-under 95 $PY_FILES
  36. fi