diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-22 18:09:14 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-22 18:09:14 +0300 |
commit | aaf158bcb57386a043d8cb7dc491a2f306a4ac13 (patch) | |
tree | a421128fc10c4b12eaa48a0a18492bb7d64e98b3 /scripts/utils.sh | |
parent | a59aa00d8aeea39a6360d9be12ffee564802c63c (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'scripts/utils.sh')
-rw-r--r-- | scripts/utils.sh | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/scripts/utils.sh b/scripts/utils.sh index c9e4a6a487d..2bbe7e10de8 100644 --- a/scripts/utils.sh +++ b/scripts/utils.sh @@ -107,6 +107,37 @@ function install_junit_merge_gem() { run_timed_command "gem install junit_merge --no-document --version 0.1.2" } +function fail_on_warnings() { + local cmd="$*" + local warning_file + warning_file="$(mktemp)" + + local allowed_warning_file + allowed_warning_file="$(mktemp)" + + eval "$cmd 2>$warning_file" + local ret=$? + + # Filter out comments and empty lines from allowed warnings file. + grep --invert-match --extended-regexp "^#|^$" scripts/allowed_warnings.txt > "$allowed_warning_file" + + local warnings + # Filter out allowed warnings from stderr. + # Turn grep errors into warnings so we fail later. + warnings=$(grep --invert-match --file "$allowed_warning_file" "$warning_file" 2>&1 || true) + + rm -f "$warning_file" "$allowed_warning_file" + + if [ "$warnings" != "" ] + then + echoerr "There were warnings:" + echoerr "$warnings" + return 1 + fi + + return $ret +} + function run_timed_command() { local cmd="${1}" local metric_name="${2:-no}" |