mirror of
https://github.com/keymanapp/keyman.git
synced 2026-09-23 16:17:40 +00:00
chore(common): fix child build error handling
Fixes #8322. This issue was arising due to subshells masking the exit code. set -e is not really to be trusted.
This commit is contained in:
parent
04189d2e3d
commit
e6ea381aba
4 changed files with 63 additions and 4 deletions
|
|
@ -162,6 +162,16 @@ $THIS_SCRIPT_PATH/build-utils-traps.test.sh error-in-function
|
|||
$THIS_SCRIPT_PATH/build-utils-traps.test.sh incomplete
|
||||
echo "${COLOR_BLUE}## Running dependency tests${COLOR_RESET}"
|
||||
$THIS_SCRIPT_PATH/builder-deps.test.sh
|
||||
$THIS_SCRIPT_PATH/dependencies/app/build.sh configure build
|
||||
|
||||
$THIS_SCRIPT_PATH/dependencies/app/build.sh error && \
|
||||
builder_die "FAIL: error code 0 but should have failed with exit code 22 from child dep" || (
|
||||
result=$?
|
||||
if [[ $result != 22 ]]; then
|
||||
builder_die "FAIL: exit code $result but should have failed with exit code 22 from child dep"
|
||||
fi
|
||||
) || exit $?
|
||||
|
||||
echo "${COLOR_BLUE}## End external tests${COLOR_RESET}"
|
||||
echo
|
||||
|
||||
|
|
|
|||
|
|
@ -14,8 +14,10 @@ cd "$THIS_SCRIPT_PATH"
|
|||
|
||||
builder_describe "app test module" \
|
||||
@../library \
|
||||
"@../error error" \
|
||||
configure \
|
||||
build
|
||||
build \
|
||||
error
|
||||
|
||||
builder_parse "$@"
|
||||
|
||||
|
|
@ -39,3 +41,9 @@ if builder_start_action build:project; then
|
|||
touch out.build
|
||||
builder_finish_action success build:project
|
||||
fi
|
||||
|
||||
if builder_start_action error:project; then
|
||||
echo " ... doing the 'error' action for 'app'; we shouldn't have gotten here"
|
||||
echo " ... because dependencies/error should have failed"
|
||||
exit 99
|
||||
fi
|
||||
|
|
|
|||
33
resources/build/tests/dependencies/error/build.sh
Executable file
33
resources/build/tests/dependencies/error/build.sh
Executable file
|
|
@ -0,0 +1,33 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -eu
|
||||
|
||||
## START STANDARD BUILD SCRIPT INCLUDE
|
||||
# adjust relative paths as necessary
|
||||
THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")"
|
||||
. "${THIS_SCRIPT%/*}/../../../build-utils.sh"
|
||||
# END STANDARD BUILD SCRIPT INCLUDE
|
||||
|
||||
cd "$THIS_SCRIPT_PATH"
|
||||
|
||||
# Test builder_describe_outputs and dependencies
|
||||
|
||||
builder_describe "library test module" \
|
||||
configure \
|
||||
build
|
||||
|
||||
builder_parse "$@"
|
||||
|
||||
builder_describe_outputs \
|
||||
configure:project out.configure \
|
||||
build:project out.build
|
||||
|
||||
if builder_start_action configure:project; then
|
||||
echo " ... doing the 'configure' action for 'library'"
|
||||
exit 22
|
||||
fi
|
||||
|
||||
if builder_start_action build:project; then
|
||||
echo " ... doing the 'build' action for 'library'"
|
||||
exit 22
|
||||
fi
|
||||
|
|
@ -290,7 +290,7 @@ _builder_execute_child() {
|
|||
result=$?
|
||||
echo "${COLOR_RED}## $scope$action$target failed with exit code $result${COLOR_RESET}"
|
||||
exit $result
|
||||
)
|
||||
) || exit $? # Required due to above subshell masking exit
|
||||
}
|
||||
|
||||
_builder_run_child_action() {
|
||||
|
|
@ -1263,7 +1263,7 @@ _builder_do_build_deps() {
|
|||
# Don't attempt to build dependencies that don't match the current
|
||||
# action:target (wildcards supported for matches here)
|
||||
if ! _builder_should_build_dep "$action_target" "$dep"; then
|
||||
echo "[$THIS_SCRIPT_IDENTIFIER] Skipping dependency build $dep for $_builder_matched_action_name"
|
||||
echo "[$THIS_SCRIPT_IDENTIFIER] Skipping dependency $dep for $_builder_matched_action_name"
|
||||
continue
|
||||
fi
|
||||
|
||||
|
|
@ -1279,7 +1279,15 @@ _builder_do_build_deps() {
|
|||
$builder_debug \
|
||||
$_builder_build_deps \
|
||||
--builder-deps-built "$_builder_deps_built" \
|
||||
--builder-dep-parent "$THIS_SCRIPT_IDENTIFIER"
|
||||
--builder-dep-parent "$THIS_SCRIPT_IDENTIFIER" && (
|
||||
if $_builder_debug; then
|
||||
echo "${COLOR_GREEN}## [$THIS_SCRIPT_IDENTIFIER] Dependency $dep for $_builder_matched_action_name successfully${COLOR_RESET}"
|
||||
fi
|
||||
) || (
|
||||
result=$?
|
||||
echo "${COLOR_RED}## [$THIS_SCRIPT_IDENTIFIER] Dependency failed with exit code $result${COLOR_RESET}"
|
||||
exit $result
|
||||
) || exit $? # Required due to above subshell masking exit
|
||||
done
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue