File tree Expand file tree Collapse file tree 2 files changed +41
-0
lines changed
Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change 172172 ./script.bat || fail " Run should succeed"
173173}
174174
175+ function test_run_test_exit_code() {
176+ # EXPERIMENTAL_SPLIT_XML_GENERATION is set by the outer bazel and influences
177+ # the test setup of the inner bazel. To make sure we hit the codepath we want
178+ # to test here, unset the variable.
179+ unset EXPERIMENTAL_SPLIT_XML_GENERATION
180+
181+ mkdir -p foo
182+ cat > foo/BUILD << 'EOF '
183+ sh_test(
184+ name = "exit0",
185+ srcs = ["exit0.sh"],
186+ )
187+
188+ sh_test(
189+ name = "exit1",
190+ srcs = ["exit1.sh"],
191+ )
192+ EOF
193+
194+ cat > foo/exit0.sh << 'EOF '
195+ set -x
196+ exit 0
197+ EOF
198+ chmod +x foo/exit0.sh
199+ bazel run //foo:exit0 & > " $TEST_log " \
200+ || fail " Expected exit code 0, received $? "
201+
202+ cat > foo/exit1.sh << 'EOF '
203+ set -x
204+ exit 1
205+ EOF
206+ chmod +x foo/exit1.sh
207+ bazel run --noexperimental_split_xml_generation //foo:exit1 & > " $TEST_log " \
208+ && fail " Expected exit code 1, received $? "
209+
210+ # Avoid failing the test because of the last non-zero exit-code.
211+ true
212+ }
213+
175214run_suite " run_under_tests"
Original file line number Diff line number Diff line change @@ -323,11 +323,13 @@ if [[ "${EXPERIMENTAL_SPLIT_XML_GENERATION}" == "1" ]]; then
323323 (" $1 " " $TEST_PATH " " ${@: 3} " 2>&1 ) < & 0 &
324324 fi
325325else
326+ set -o pipefail
326327 if [ -z " $COVERAGE_DIR " ]; then
327328 (" ${TEST_PATH} " " $@ " 2>&1 | tee -a " ${XML_OUTPUT_FILE} .log" ) < & 0 &
328329 else
329330 (" $1 " " $TEST_PATH " " ${@: 3} " 2>&1 | tee -a " ${XML_OUTPUT_FILE} .log" ) < & 0 &
330331 fi
332+ set +o pipefail
331333fi
332334childPid=$!
333335
You can’t perform that action at this time.
0 commit comments