summaryrefslogtreecommitdiff
path: root/tests/twisted/run-test.sh.in
blob: ac553e3c3a273fe5e4b957fb49849e6b1bb6dcfa (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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#!/bin/sh

# This script assumes that it is run in a temporary directory where it can
# create and delete subdirectories for files, logs, etc., but other users
# cannot write (for instance, /tmp is unsuitable, but
# the directory created by `mktemp -d /tmp/test.XXXXXXXXXX` is fine).
#
# During "make check" or "make installcheck" it runs in
# ${top_builddir}/tests/twisted.
#
# During installed testing, the test environment must run it in a
# suitable location.

set -e

MC_TEST_CURDIR="`pwd`"
export MC_TEST_CURDIR

if test "x$MC_TEST_UNINSTALLED" = x; then
  script_fullname=`readlink -e "@mctestsdir@/twisted/run-test.sh"`
  if [ `readlink -e "$0"` != "$script_fullname" ] ; then
    echo "This script is meant to be installed at $script_fullname" >&2
    exit 1
  fi

  test_src="@mctestsdir@"
  test_build="@mctestsdir@"
  config_file="@mctestsdir@/twisted/tools/servicedir-installed/tmp-session-bus.conf"
  plugins="@mctestsdir@/twisted/plugins"

  PYTHONPATH="@mctestsdir@/twisted"
  export PYTHONPATH

  MC_TWISTED_PATH="@mctestsdir@/twisted"
  export MC_TWISTED_PATH
else
  if test -z "$MC_ABS_TOP_SRCDIR"; then
    echo "MC_ABS_TOP_SRCDIR must be set" >&2
    exit 1
  fi
  if test -z "$MC_ABS_TOP_BUILDDIR"; then
    echo "MC_ABS_TOP_BUILDDIR must be set" >&2
    exit 1
  fi

  test_src="${MC_ABS_TOP_SRCDIR}/tests"
  test_build="${MC_ABS_TOP_BUILDDIR}/tests"
  config_file="${test_build}/twisted/tools/servicedir-uninstalled/tmp-session-bus.conf"
  plugins="${test_build}/twisted/.libs"

  PYTHONPATH="${test_src}/twisted:${test_build}/twisted"
  export PYTHONPATH

  MC_TWISTED_PATH="${test_src}/twisted"
  export MC_TWISTED_PATH
fi

MC_DEBUG=all
export MC_DEBUG
G_DEBUG=fatal-criticals
export G_DEBUG
# for ENABLE_LIBACCOUNTS_SSO
AG_DEBUG=all
export AG_DEBUG

GIO_EXTRA_MODULES="${plugins}"
export GIO_EXTRA_MODULES
MC_FILTER_PLUGIN_DIR="${plugins}"
export MC_FILTER_PLUGIN_DIR

XDG_CONFIG_DIRS="${test_src}/twisted"
export XDG_CONFIG_DIRS

MC_CLIENTS_DIR="${test_src}/twisted/telepathy/clients"
export MC_CLIENTS_DIR
MC_MANAGER_DIR="${test_src}/twisted/telepathy/managers"
export MC_MANAGER_DIR

if [ -n "$1" ] ; then
  list="$1"
else
  list=$(cat "${test_build}"/twisted/mc-twisted-tests.list)
fi

any_failed=0
for i in $list ; do
  echo "Testing $i ..."

  tmp="${MC_TEST_CURDIR}/tmp-`echo $i | tr ./ __`"
  rm -fr "$tmp"
  mkdir "$tmp"

  MC_TEST_LOG_DIR="${tmp}"
  export MC_TEST_LOG_DIR
  MC_ACCOUNT_DIR="${tmp}/mc-account-dir"
  export MC_ACCOUNT_DIR
  XDG_CONFIG_HOME="${tmp}/config"
  export XDG_CONFIG_HOME
  XDG_DATA_HOME="${tmp}/localshare"
  export XDG_DATA_HOME
  XDG_DATA_DIRS="${tmp}/share:${test_src}/twisted"
  export XDG_DATA_DIRS
  XDG_CACHE_HOME="${tmp}/cache"
  export XDG_CACHE_HOME
  XDG_CACHE_DIR="${tmp}/cache"
  export XDG_CACHE_DIR

  # for ENABLE_LIBACCOUNTS_SSO
  ACCOUNTS="${tmp}/libaccounts-accounts"
  export ACCOUNTS
  AG_SERVICES="${tmp}/libaccounts-services"
  export AG_SERVICES

  e=0
  sh "${test_src}/twisted/tools/with-session-bus.sh" \
    ${MC_TEST_SLEEP} \
    --also-for-system \
    --config-file="${config_file}" \
    -- \
    @TEST_PYTHON@ -u "${test_src}/twisted/$i" || e=$?
  case "$e" in
    (0)
      echo "PASS: $i"
      if test -z "$MC_TEST_KEEP_TEMP"; then
        rm -fr "$tmp"
      fi
      ;;
    (77)
      echo "SKIP: $i"
      if test -z "$MC_TEST_KEEP_TEMP"; then
        rm -fr "$tmp"
      fi
      ;;
    (*)
      any_failed=1
      echo "FAIL: $i ($e)"
      ;;
  esac
done

exit $any_failed