diff --git a/tools/check-iwyu b/tools/check-iwyu index 4efd45c649daf898e8ee982e933955200355d0b0..67b431eae9156bc3737c628d063eda80fbbe71bf 100755 --- a/tools/check-iwyu +++ b/tools/check-iwyu @@ -64,10 +64,23 @@ else echo "WARNING: ${IWYU_TOOL} does not support --load" fi +set +e ${IWYU_TOOL} ${IWYU_TOOL_ARGS[@]} \ -- \ -Xiwyu --mapping_file="${MESON_SOURCE_ROOT}/iwyu-mappings.imp" \ > "${IWYU_LOG}" +set -e +# Only newer versions of IWYU_TOOL fail with an exit code (IWYU > +# 0.15, since commit +# https://github.com/include-what-you-use/include-what-you-use/commit/a7499e4a2b416592777cc4c33fca746d091af738). Therefore +# we have to manually see if this IWYU_TOOL run failed with an error +# exit code. +# shellcheck: disable=SC2181 +if [[ ${?} -gt 0 ]]; then + echoerr "IWYU exited with ${?}" + cat "${IWYU_LOG}" + exit $? +fi if [[ ! -s "${IWYU_LOG}" ]]; then echoerr "${IWYU_LOG} is empty (or non existent)"