run-all-extension-tests revision 83aaf46c9feab529aeb9add871c05c3d1177afcc
4e10d188042815c5285edf00ea96896b862e0863aurium#!/bin/bash
4e10d188042815c5285edf00ea96896b862e0863aurium
2ebfcf72203f94f579931a9cfe6658a65ca5027dauriumecho -e "\n##### Extension Tests #####"
4e10d188042815c5285edf00ea96896b862e0863aurium
4e10d188042815c5285edf00ea96896b862e0863auriumcd "$(dirname "$0")"
4e10d188042815c5285edf00ea96896b862e0863aurium
4e10d188042815c5285edf00ea96896b862e0863auriumhas_py_coverage=false
4e10d188042815c5285edf00ea96896b862e0863auriumpy_cover_files=$( mktemp )
83aaf46c9feab529aeb9add871c05c3d1177afccauriumfailed_tests=$( mktemp )
4e10d188042815c5285edf00ea96896b862e0863aurium
4e10d188042815c5285edf00ea96896b862e0863auriumif coverage.py -e >/dev/null 2>/dev/null; then
4e10d188042815c5285edf00ea96896b862e0863aurium has_py_coverage=true
4e10d188042815c5285edf00ea96896b862e0863aurium cover_py_cmd=coverage.py
4e10d188042815c5285edf00ea96896b862e0863auriumelse
4e10d188042815c5285edf00ea96896b862e0863aurium if coverage -e >/dev/null 2>/dev/null; then
4e10d188042815c5285edf00ea96896b862e0863aurium has_py_coverage=true
4e10d188042815c5285edf00ea96896b862e0863aurium cover_py_cmd=coverage
4e10d188042815c5285edf00ea96896b862e0863aurium fi
4e10d188042815c5285edf00ea96896b862e0863auriumfi
4e10d188042815c5285edf00ea96896b862e0863aurium
4e10d188042815c5285edf00ea96896b862e0863aurium#if $has_py_coverage; then
4e10d188042815c5285edf00ea96896b862e0863aurium# $cover_py_cmd -e
4e10d188042815c5285edf00ea96896b862e0863aurium#fi
4e10d188042815c5285edf00ea96896b862e0863aurium
4e10d188042815c5285edf00ea96896b862e0863auriumfunction run_py_test() {
4e10d188042815c5285edf00ea96896b862e0863aurium echo -e "\n>> Testing $1"
4e10d188042815c5285edf00ea96896b862e0863aurium if $has_py_coverage; then
83aaf46c9feab529aeb9add871c05c3d1177afccaurium if ! $cover_py_cmd -x "$1.test.py"; then
83aaf46c9feab529aeb9add871c05c3d1177afccaurium echo "$1" >> $failed_tests
83aaf46c9feab529aeb9add871c05c3d1177afccaurium fi
4e10d188042815c5285edf00ea96896b862e0863aurium echo "../$1.py" >> $py_cover_files
4e10d188042815c5285edf00ea96896b862e0863aurium else
83aaf46c9feab529aeb9add871c05c3d1177afccaurium if ! python "$1.test.py"; then
83aaf46c9feab529aeb9add871c05c3d1177afccaurium echo "$1" >> $failed_tests
83aaf46c9feab529aeb9add871c05c3d1177afccaurium fi
4e10d188042815c5285edf00ea96896b862e0863aurium fi
83aaf46c9feab529aeb9add871c05c3d1177afccaurium return 0
4e10d188042815c5285edf00ea96896b862e0863aurium}
4e10d188042815c5285edf00ea96896b862e0863aurium
83aaf46c9feab529aeb9add871c05c3d1177afccauriumtot_FAILED=0
83aaf46c9feab529aeb9add871c05c3d1177afccaurium
83aaf46c9feab529aeb9add871c05c3d1177afccauriumfor testFile in *.test.py; do
83aaf46c9feab529aeb9add871c05c3d1177afccaurium if ! run_py_test $( echo $testFile | sed -r 's/^([^.]+)..*$/\1/' ); then
83aaf46c9feab529aeb9add871c05c3d1177afccaurium let tot_FAILED++
83aaf46c9feab529aeb9add871c05c3d1177afccaurium fi
905e42f96548e175ead68243a632f06b19285e1fauriumdone
4e10d188042815c5285edf00ea96896b862e0863aurium
4e10d188042815c5285edf00ea96896b862e0863auriumif $has_py_coverage; then
83aaf46c9feab529aeb9add871c05c3d1177afccaurium echo -e "\n>> Coverage Report:"
4e10d188042815c5285edf00ea96896b862e0863aurium cat $py_cover_files | xargs $cover_py_cmd -r
4e10d188042815c5285edf00ea96896b862e0863auriumfi
4e10d188042815c5285edf00ea96896b862e0863aurium
83aaf46c9feab529aeb9add871c05c3d1177afccauriumfail=false
83aaf46c9feab529aeb9add871c05c3d1177afccauriumif ! test -z "$( cat $failed_tests )"; then
83aaf46c9feab529aeb9add871c05c3d1177afccaurium echo -e "\nFailed extension tests:"
83aaf46c9feab529aeb9add871c05c3d1177afccaurium cat $failed_tests | sed 's/^/ - /'
83aaf46c9feab529aeb9add871c05c3d1177afccaurium fail=true
83aaf46c9feab529aeb9add871c05c3d1177afccauriumfi
83aaf46c9feab529aeb9add871c05c3d1177afccauriumecho ""
83aaf46c9feab529aeb9add871c05c3d1177afccaurium
83aaf46c9feab529aeb9add871c05c3d1177afccauriumrm $py_cover_files $failed_tests
83aaf46c9feab529aeb9add871c05c3d1177afccaurium
83aaf46c9feab529aeb9add871c05c3d1177afccaurium$fail && exit 1