-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathrun-all-tests.sh
executable file
·60 lines (50 loc) · 1.64 KB
/
run-all-tests.sh
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
#!/bin/bash
SCRIPT_DIR="$(dirname $0)"
echo "SCRIPT_DIR: ${SCRIPT_DIR}"
BATS_SERVER_CONFIG_FILE_DIRECTORY="${SCRIPT_DIR}/test-common/configuration"
BATS_SERVER_CONFIG_FILE_NAME="standalone-openshift.xml"
BATS_SERVER_CONFIG_FILE="${BATS_SERVER_CONFIG_FILE_DIRECTORY}/${BATS_SERVER_CONFIG_FILE_NAME}"
BATS_CONFIG_ENV_FILE="${BATS_SERVER_CONFIG_FILE_DIRECTORY}/bats-config.env"
FILE_TEST_PATTERN="*.bats"
# CI passes --tap as the only arg, if its there, ignore the pattern
if [ "${1}" != "--tap" ]; then
FILE_TEST_PATTERN="${1:-*.bats}"
fi
if [ -z "${BATS_STANDALONE_XML_URL}" ] && [ -f "${BATS_CONFIG_ENV_FILE}" ]; then
source "${BATS_CONFIG_ENV_FILE}"
fi
if [ -z "${BATS_STANDALONE_XML_URL}" ] && [ ! -f "${BATS_SERVER_CONFIG_FILE}" ]; then
echo "No ${BATS_SERVER_CONFIG_FILE} found and no download url specified via BATS_STANDALONE_XML_URL or in ${BATS_CONFIG_ENV_FILE}"
exit 1
fi
if [ -n "${BATS_STANDALONE_XML_URL}" ]; then
if [ -f "${BATS_SERVER_CONFIG_FILE}" ]; then
echo "Skipping download as ${BATS_SERVER_CONFIG_FILE} already exists!"
else
cd "${BATS_SERVER_CONFIG_FILE_DIRECTORY}"
wget "${BATS_SERVER_CONFIG_FILE_NAME}" "${BATS_STANDALONE_XML_URL}"
cd ../..
fi
fi
rc=0
failed=()
tap=""
# passing --tap will enable TAP output for CI
if [ "${1}" = "--tap" ]; then
echo "TAP version 13"
tap="--tap"
fi
for testName in `find ./ -name "${FILE_TEST_PATTERN}"`;
do
echo ${testName};
bats ${tap} ${testName}
if [ "$?" -ne 0 ]; then
rc=1
failed+=(${testName})
fi
done
if [ "${rc}" -ne 0 ]; then
echo "There are test failures! "
printf '[FAILED]: %s\n' "${failed[@]}"
fi
exit ${rc}