@@ -91,6 +91,41 @@ readonly -A gitconfig=(
91
91
92
92
[[ -n " $DEBUG " ]] && set -x
93
93
94
+ # Positive test & non-zero exit status = ERROR.
95
+ # Negative test & zero exit status = ERROR.
96
+ # Tests with '-should-fail-' in their name should fail during a build,
97
+ # expecting non-zero exit status.
98
+ evaluate_build_result () {
99
+ local _result=" $1 "
100
+ local _app=" $2 "
101
+ local _type=" positive"
102
+ local _test_msg=" [PASSED]"
103
+ local _ret_code=0
104
+
105
+ if [[ " $_app " == * " -should-fail-" * ]]; then
106
+ _type=" negative"
107
+ fi
108
+
109
+ if [[ " $_type " == " positive" && " $_result " != " 0" ]]; then
110
+ info " TEST FAILED (${_type} ), EXPECTED:0 GOT:${_result} "
111
+ _ret_code=$_result
112
+ elif [[ " $_type " == " negative" && " $_result " == " 0" ]]; then
113
+ info " TEST FAILED (${_type} ), EXPECTED: non-zero GOT:${_result} "
114
+ _ret_code=1
115
+ fi
116
+ if [ $_ret_code != 0 ]; then
117
+ cleanup
118
+ TESTSUITE_RESULT=1
119
+ _test_msg=" [FAILED]"
120
+ fi
121
+ ct_update_test_result " $_test_msg " " $_app " run_s2i_build
122
+
123
+ if [[ " $_type " == " negative" && " $_result " != " 0" ]]; then
124
+ _ret_code=127 # even though this is success, the app is still not built
125
+ fi
126
+ return $_ret_code
127
+ }
128
+
94
129
ct_init
95
130
cid_file=$CID_FILE_DIR /$( mktemp -u -p . --suffix=.cid)
96
131
@@ -100,27 +135,32 @@ prepare app
100
135
check_prep_result $? app || exit
101
136
echo " Testing the production image build"
102
137
run_s2i_build
103
- ct_check_testcase_result $?
138
+ evaluate_build_result $? " default "
104
139
105
140
TEST_SET=${TESTS:- $TEST_LIST_APP } ct_run_tests_from_testset " app"
106
141
107
- echo " Testing the development image build: s2i build -e \" NODE_ENV=development\" )"
142
+ cleanup
143
+
108
144
run_s2i_build " -e NODE_ENV=development"
109
- ct_check_testcase_result $?
145
+ evaluate_build_result $? " -e NODE_ENV=development "
110
146
111
147
TEST_SET=${TESTS:- $TEST_LIST_NODE_ENV } ct_run_tests_from_testset " node_env_development"
112
148
149
+ cleanup
150
+
113
151
echo " Testing the development image build: s2i build -e \" DEV_MODE=true\" )"
114
152
run_s2i_build " -e DEV_MODE=true"
115
- ct_check_testcase_result $?
153
+ evaluate_build_result $? " -e DEV_MODE=true "
116
154
117
155
TEST_SET=${TESTS:- $TEST_LIST_DEV_MODE } ct_run_tests_from_testset " dev_mode"
118
156
157
+ cleanup
158
+
119
159
echo " Testing proxy safe logging..."
120
160
prepare hw
121
161
check_prep_result $? hw || exit
122
162
run_s2i_build_proxy http://
[email protected] :8000 https://
[email protected] :8000
> /tmp/build-log
2>&1
123
- ct_check_testcase_result $?
163
+ evaluate_build_result $? " proxy "
124
164
125
165
TEST_SET=${TESTS:- $TEST_LIST_HW } ct_run_tests_from_testset " hw"
126
166
@@ -134,4 +174,6 @@ if [[ "$VERSION" != "18" ]]; then
134
174
# npm ERR! gyp ERR! node-gyp -v v10.0.1
135
175
# npm ERR! gyp ERR! not ok
136
176
TEST_SET=${TESTS:- $TEST_LIST_BINARY } ct_run_tests_from_testset " binary"
177
+
178
+ cleanup
137
179
fi
0 commit comments