Skip to content

Commit 741a503

Browse files
phracekzmiklank
andauthored
Remove set -e and add to the end FAILED message (#369)
* Remove set -e and add to the end FAILED message in case of test failed. --------- Signed-off-by: Petr "Stone" Hracek <[email protected]> Co-authored-by: Zuzana Miklánková <[email protected]>
1 parent a957816 commit 741a503

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

test.sh

+27-5
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,23 @@
66
# TEST_OPENSHIFT_MODE - If set, run OpenShift tests (if present)
77
# VERSIONS - Must be set to a list with possible versions (subdirectories)
88

9-
set -eE
9+
[ -n "${DEBUG:-}" ] && set -x
1010

11-
trap 'echo "errexit on line $LINENO, $0" >&2' ERR
11+
FAILED_VERSIONS=""
1212

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+
}
1426

1527
# This adds backwards compatibility if only single version needs to be testing
1628
# 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"
2133

2234
for dir in ${VERSIONS}; do
2335
[ ! -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
2537
IMAGE_ID=$(cat .image-id)
2638
export IMAGE_ID
2739
IMAGE_VERSION=$(docker inspect -f "{{.Config.Labels.version}}" "$IMAGE_ID")
@@ -36,6 +48,7 @@ for dir in ${VERSIONS}; do
3648

3749
if [ -n "${TEST_MODE}" ]; then
3850
VERSION=$dir test/run
51+
failed_version "$?" "$dir"
3952
fi
4053

4154
if [ -n "${TEST_OPENSHIFT_4}" ]; then
@@ -46,6 +59,7 @@ for dir in ${VERSIONS}; do
4659
else
4760
if [[ -x test/run-openshift-remote-cluster ]]; then
4861
VERSION=$dir test/run-openshift-remote-cluster
62+
failed_version "$?" "$dir"
4963
else
5064
echo "-> Tests for OpenShift 4 are not present. Add run-openshift-remote-cluster script, skipping"
5165
fi
@@ -56,9 +70,17 @@ for dir in ${VERSIONS}; do
5670
if [ -n "${TEST_UPSTREAM}" ]; then
5771
if [[ -x test/run-upstream ]]; then
5872
VERSION=$dir test/run-upstream
73+
failed_version "$?" "$dir"
5974
else
6075
echo "-> Upstream tests are not present, skipping"
6176
fi
6277
fi
63-
popd > /dev/null
78+
popd > /dev/null || exit 1
6479
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

Comments
 (0)