aboutsummaryrefslogtreecommitdiff
path: root/tests/run-eds-ics-test.sh
blob: 4cbc0d35b82d945f945aef9a75f462ddd2caea13 (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
#!/bin/sh

SELF=$0        # this script
TEST_RUNNER=$1 # full executable path of dbus-test-runner
TEST_EXEC=$2   # full executable path of test app
TEST_NAME=$3   # test name
CONFIG_DIR=$4  # config files
ICS_FILE=$5    # ical file holding test data
ACCOUNTS_DB=$6 # online account database

echo "this script: ${SELF}"
echo "test-runner: ${TEST_RUNNER}"
echo "test-exec: ${TEST_EXEC}"
echo "test-name: ${TEST_NAME}"
echo "config-dir: ${CONFIG_DIR}"
echo "ics-file: ${ICS_FILE}"

# set up the tmpdir
export TEST_TMP_DIR=$(mktemp -p "${TMPDIR:-/tmp}" -d ${TEST_NAME}-XXXXXXXXXX) || exit 1
echo "running test '${TEST_NAME}' in ${TEST_TMP_DIR}"

# set up the environment variables
export QT_QPA_PLATFORM=minimal
export HOME=${TEST_TMP_DIR}
export XDG_RUNTIME_DIR=${TEST_TMP_DIR}
export XDG_CACHE_HOME=${TEST_TMP_DIR}/.cache
export XDG_CONFIG_HOME=${TEST_TMP_DIR}/.config
export XDG_DATA_HOME=${TEST_TMP_DIR}/.local/share
export XDG_DESKTOP_DIR=${TEST_TMP_DIR}
export XDG_DOCUMENTS_DIR=${TEST_TMP_DIR}
export XDG_DOWNLOAD_DIR=${TEST_TMP_DIR}
export XDG_MUSIC_DIR=${TEST_TMP_DIR}
export XDG_PICTURES_DIR=${TEST_TMP_DIR}
export XDG_PUBLICSHARE_DIR=${TEST_TMP_DIR}
export XDG_TEMPLATES_DIR=${TEST_TMP_DIR}
export XDG_VIDEOS_DIR=${TEST_TMP_DIR}
export QORGANIZER_EDS_DEBUG=On
export GIO_USE_VFS=local # needed to ensure GVFS shuts down cleanly after the test is over

export G_MESSAGES_DEBUG=all
export G_DBUS_DEBUG=messages

echo HOMEDIR=${HOME}
rm -rf ${XDG_DATA_HOME}

# if there are canned config files for this test, move them into place now
if [ -d ${CONFIG_DIR} ]; then
  echo "copying files from ${CONFIG_DIR} to $HOME"
  cp --verbose --archive ${CONFIG_DIR}/. $HOME
fi

# if there's a specific ics file to test, copy it on top of the canned config files
if [ -e ${ICS_FILE} ]; then
  echo "copying ${ICS_FILE} into $HOME"
  mkdir -p ${XDG_DATA_HOME}/evolution/tasks/system/
  cp --verbose --archive ${ICS_FILE} ${XDG_DATA_HOME}/evolution/tasks/system/tasks.ics
fi

# prepare online accounts database
if [ -e ${ACCOUNTS_DB} ]; then
  echo "copying ${ACCOUNTS_DB} into $HOME"
  mkdir -p ${XDG_CONFIG_HOME}/libaccounts-glib/
  cp --verbose --archive ${ACCOUNTS_DB} ${XDG_CONFIG_HOME}/libaccounts-glib/accounts.db
fi

# run the test
${TEST_RUNNER} --keep-env --max-wait=90 --task ${TEST_EXEC} --task-name ${TEST_NAME} --wait-until-complete
rv=$?

# if the test passed, blow away the tmpdir
if [ $rv -eq 0 ]; then
    sleep 5
    rm -rf $TEST_TMP_DIR
fi

# pass the test's return code to the caller.
exit "$rv"