home *** CD-ROM | disk | FTP | other *** search
/ Chip 2011 November / CHIP_2011_11.iso / Programy / Narzedzia / Inkscape / Inkscape-0.48.2-1-win32.exe / share / extensions / test / run-all-extension-tests < prev    next >
Text File  |  2011-07-08  |  1KB  |  63 lines

  1. #!/bin/bash
  2.  
  3. echo -e "\n##### Extension Tests #####"
  4.  
  5. cd "$(dirname "$0")"
  6.  
  7. has_py_coverage=false
  8. py_cover_files=$( mktemp )
  9. failed_tests=$( mktemp )
  10.  
  11. if coverage.py -e >/dev/null 2>/dev/null; then
  12.   has_py_coverage=true
  13.   cover_py_cmd=coverage.py
  14. else
  15.   if coverage -e >/dev/null 2>/dev/null; then
  16.     has_py_coverage=true
  17.     cover_py_cmd=coverage
  18.   fi
  19. fi
  20.  
  21. #if $has_py_coverage; then
  22. #  $cover_py_cmd -e
  23. #fi
  24.  
  25. function run_py_test() {
  26.   echo -e "\n>> Testing $1"
  27.   if $has_py_coverage; then
  28.     if ! $cover_py_cmd -x "$1.test.py"; then
  29.       echo "$1" >> $failed_tests
  30.     fi
  31.     echo "../$1.py" >> $py_cover_files
  32.   else
  33.     if ! python "$1.test.py"; then
  34.       echo "$1" >> $failed_tests
  35.     fi
  36.   fi
  37.   return 0
  38. }
  39.  
  40. tot_FAILED=0
  41.  
  42. for testFile in *.test.py; do
  43.   if ! run_py_test $( echo $testFile | sed -r 's/^([^.]+)..*$/\1/' ); then
  44.     let tot_FAILED++
  45.   fi
  46. done
  47.  
  48. if $has_py_coverage; then
  49.   echo -e "\n>> Coverage Report:"
  50.   cat $py_cover_files | xargs $cover_py_cmd -r
  51. fi
  52.  
  53. fail=false
  54. if ! test -z "$( cat $failed_tests )"; then
  55.   echo -e "\nFailed $( cat $failed_tests | wc -l ) of $( ls -1 *.test.py | wc -l ) extension tests:"
  56.   cat $failed_tests | sed 's/^/  - /'
  57.   fail=true
  58. fi
  59. echo ""
  60.  
  61. rm $py_cover_files $failed_tests
  62.  
  63. $fail && exit 1