6
6
# TEST_OPENSHIFT_MODE - If set, run OpenShift tests (if present)
7
7
# VERSIONS - Must be set to a list with possible versions (subdirectories)
8
8
9
- set -eE
9
+ [ -n " ${DEBUG :- } " ] && set -x
10
10
11
- trap ' echo "errexit on line $LINENO, $0" >&2 ' ERR
11
+ FAILED_VERSIONS= " "
12
12
13
- [ -n " ${DEBUG:- } " ] && set -x
13
+ # failed_version
14
+ # -----------------------------
15
+ # Check if testcase ended in error and update FAILED_VERSIONS variable
16
+ # Argument: result - testcase result value
17
+ # version - version that failed
18
+ failed_version () {
19
+ local result=" $1 "
20
+ local version=" $2 "
21
+ if [[ " $result " != " 0" ]]; then
22
+ FAILED_VERSIONS=" ${FAILED_VERSIONS} ${version} "
23
+ fi
24
+ return " $result "
25
+ }
14
26
15
27
# This adds backwards compatibility if only single version needs to be testing
16
28
# In CI we would like to test single version but VERSIONS= means, that nothing is tested
@@ -21,7 +33,7 @@ echo "Tested versions are: $VERSIONS"
21
33
22
34
for dir in ${VERSIONS} ; do
23
35
[ ! -e " ${dir} /.image-id" ] && echo " -> Image for version $dir not built, skipping tests." && continue
24
- pushd " ${dir} " > /dev/null
36
+ pushd " ${dir} " > /dev/null || exit 1
25
37
IMAGE_ID=$( cat .image-id)
26
38
export IMAGE_ID
27
39
IMAGE_VERSION=$( docker inspect -f " {{.Config.Labels.version}}" " $IMAGE_ID " )
@@ -36,6 +48,7 @@ for dir in ${VERSIONS}; do
36
48
37
49
if [ -n " ${TEST_MODE} " ]; then
38
50
VERSION=$dir test/run
51
+ failed_version " $? " " $dir "
39
52
fi
40
53
41
54
if [ -n " ${TEST_OPENSHIFT_4} " ]; then
@@ -46,6 +59,7 @@ for dir in ${VERSIONS}; do
46
59
else
47
60
if [[ -x test/run-openshift-remote-cluster ]]; then
48
61
VERSION=$dir test/run-openshift-remote-cluster
62
+ failed_version " $? " " $dir "
49
63
else
50
64
echo " -> Tests for OpenShift 4 are not present. Add run-openshift-remote-cluster script, skipping"
51
65
fi
@@ -56,9 +70,17 @@ for dir in ${VERSIONS}; do
56
70
if [ -n " ${TEST_UPSTREAM} " ]; then
57
71
if [[ -x test/run-upstream ]]; then
58
72
VERSION=$dir test/run-upstream
73
+ failed_version " $? " " $dir "
59
74
else
60
75
echo " -> Upstream tests are not present, skipping"
61
76
fi
62
77
fi
63
- popd > /dev/null
78
+ popd > /dev/null || exit 1
64
79
done
80
+
81
+ if [[ -n " $FAILED_VERSIONS " ]]; then
82
+ echo " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
83
+ echo " Test for image ${IMAGE_NAME} FAILED in these versions ${FAILED_VERSIONS} ."
84
+ echo " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
85
+ exit 1
86
+ fi
0 commit comments