summaryrefslogtreecommitdiff
path: root/packages/taler-integrationtests/testrunner
blob: c03f6ed9707717b7f064f297dde0a7728cdfe73d (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
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env bash

# Simple test runner for the wallet integration tests.
#
# Usage: $0 TESTGLOB
#
# The TESTGLOB can be used to select which test cases to execute

set -eu

exit_int() {
  echo "Interrupted..."
  exit 2
}

trap "exit_int" INT

if [ "$#" -ne 1 ]; then
    echo "Usage: $0 TESTGLOB"
    exit 1
fi

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

cd $DIR

./node_modules/.bin/tsc -b

export ESM_OPTIONS='{"sourceMap": true}'

shopt -s extglob

num_exec=0
num_fail=0
num_succ=0

files_failed=''

# Glob tests
for file in lib/$1?(.js); do
  case "$file" in
    */test-*.js)
      echo "executing test $file"
      ret=0
      node -r source-map-support/register -r esm $file || ret=$?
      num_exec=$((num_exec+1))
      case $ret in
        0)
          num_succ=$((num_succ+1))
          ;;
        *)
          num_fail=$((num_fail+1))
          files_failed=$files_failed:$file
          ;;
      esac
      ;;
    *)
      continue
    ;;
  esac
done

echo "-----------------------------------"
echo "Tests finished"
echo "$num_succ/$num_exec tests succeeded"
if [[ $num_fail != 0 ]]; then
  echo "These tests failed:"
  echo $files_failed | tr : \\n | sed '/^$/d'
fi
echo "-----------------------------------"

if [[ $num_fail = 0 ]]; then
  exit 0
else
  exit 1
fi