Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions ci/cloudbuild/builds/lib/quickstart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ source module ci/cloudbuild/builds/lib/cmake.sh
source module ci/etc/quickstart-config.sh
source module ci/lib/io.sh

function cleanup() {
local exit_status=$?
io::log_h2 "cleanup on EXIT with exit_status=${exit_status}"
io::run find . -name '*core*'
}
Comment on lines +34 to +38

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The cleanup function, when triggered by the EXIT trap, will cause the script to exit with the status of the last command it runs (io::run find ...), which is likely 0. This can mask the original exit status of the script if it was failing. To preserve the original exit status, the trap handler should ensure it exits with that status.

Suggested change
function cleanup() {
local exit_status=$?
io::log_h2 "cleanup on EXIT with exit_status=${exit_status}"
io::run find . -name '*core*'
}
function cleanup() {
local exit_status=$?
io::log_h2 "cleanup on EXIT with exit_status=${exit_status}"
io::run find . -name '*core*'
(exit "${exit_status}")
}


trap 'cleanup' INT TERM EXIT

# Builds the CMake and Makefile quickstart programs but DOES NOT RUN THEM. This
# is a useful way to test that the artifacts installed by `google-cloud-cpp`
# work for compilation. This function requires a single argument specifying the
Expand Down Expand Up @@ -97,8 +105,6 @@ function quickstart::run_cmake_and_make() {
mapfile -t run_args < <(quickstart::arguments "${lib}")
quickstart::run_one_quickstart "${prefix}" "${lib}" "${run_args[@]}"
done

io::run find . -name '*core*'
}

function quickstart::run_gcs_grpc_quickstart() {
Expand Down
Loading