summaryrefslogtreecommitdiff
path: root/debian/tests/run-all
blob: db7f84a112430b42648febd3633315eb3bd484f5 (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
64
65
#!/bin/sh

exec 2>&1
set -e
#set -x

KNOW_FAILURES=$(dirname $(readlink -f $0))/known-failures.txt

tests="$@"

cleanup() {
  rm -rf "$ADTTMP"
}
if [ -z "$ADTTMP" ]; then
  ADTTMP=$(mktemp -d)
  trap cleanup INT TERM EXIT
fi

cp -r 'test/' $ADTTMP
cd $ADTTMP

if [ -z "$tests" ]; then
  # FIXME for now, we are excluding the tests for C extensions; couldn't figure
  # out how to properly build them without building everything else
  tests=$(find 'test/' -name 'test_*.rb' -and -not -path '*-ext-*' | sort)
fi

pass=0
fail=0
fail_expected=0
total=0

for t in $tests; do
  if ruby2.3 test/runner.rb $t >log 2>&1; then
    echo "PASS $t"
    pass=$(($pass + 1))
  else
    if grep "^$t$" $KNOW_FAILURES; then
      fail_expected=$(($fail_expected + 1))
      echo "FAIL (EXPECTED) $t"
      echo "FAIL (EXPECTED) $t" | sed -e 's/./-/g'
    else
      fail=$(($fail + 1))
      echo "FAIL $t"
      echo "FAIL $t" | sed -e 's/./-/g'
    fi
    echo
    cat log
  fi
  total=$(($total + 1))
done
rm -f log

echo
echo "Finished"
echo '--------'
echo "   Tests executed: $(($total))"
echo "             PASS: $pass"
echo "             FAIL: $fail"
echo "EXPECTED FAILURES: $fail_expected"
echo

if [ $fail -gt 0 ]; then
  exit 1
fi