summaryrefslogtreecommitdiffstats
path: root/share/extensions/test/run-all-extension-tests
blob: 1776e25b04db4cf7bf1dc5ccc4da216c06f8c610 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash

echo -e "\n##### Extension Tests #####"

cd "$(dirname "$0")"

has_py_coverage=false
py_cover_files=$( mktemp )
failed_tests=$( mktemp )

if coverage.py -e >/dev/null 2>/dev/null; then
  has_py_coverage=true
  cover_py_cmd=coverage.py
else
  if coverage -e >/dev/null 2>/dev/null; then
    has_py_coverage=true
    cover_py_cmd=coverage
  fi
fi

#if $has_py_coverage; then
#  $cover_py_cmd -e
#fi

function run_py_test() {
  echo -e "\n>> Testing $1"
  if $has_py_coverage; then
    if ! $cover_py_cmd -x "$1.test.py"; then
      echo "$1" >> $failed_tests
    fi
    echo "../$1.py" >> $py_cover_files
  else
    if ! python "$1.test.py"; then
      echo "$1" >> $failed_tests
    fi
  fi
  return 0
}

tot_FAILED=0

for testFile in *.test.py; do
  if ! run_py_test $( echo $testFile | sed -r 's/^([^.]+)..*$/\1/' ); then
    let tot_FAILED++
  fi
done

if $has_py_coverage; then
  echo -e "\n>> Coverage Report:"
  cat $py_cover_files | xargs $cover_py_cmd -r
fi

fail=false
if ! test -z "$( cat $failed_tests )"; then
  echo -e "\nFailed $( cat $failed_tests | wc -l ) of $( ls -1 *.test.py | wc -l ) extension tests:"
  cat $failed_tests | sed 's/^/  - /'
  fail=true
fi
echo ""

rm $py_cover_files $failed_tests

$fail && exit 1