From 5f139d3b78514c6d42771ac10dd939d6db56e09e Mon Sep 17 00:00:00 2001 From: Whisperity Date: Wed, 17 Jan 2018 11:51:12 +0100 Subject: [PATCH] Fix the daily analysis integration template script always saying there are new bugs --- docs/script_daily.md | 16 +++++++++++----- docs/script_update.md | 16 +++++++++++----- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/docs/script_daily.md b/docs/script_daily.md index b9fab26679..261369bca1 100644 --- a/docs/script_daily.md +++ b/docs/script_daily.md @@ -63,13 +63,18 @@ DIFF_CMD=$(cat << END \ END ) -WAS_OUTPUT=1 +# Assume that there are new bugs introduced, unless proven otherwise. +echo -n "1" > "${WORKSPACE}/was_output.txt" + eval "${DIFF_CMD}" | while read -r line do - # If CodeChecker says there aren't new bugs, introduce them. + # If CodeChecker says there aren't new bugs, don't introduce them. if [[ "$line" =~ "- No results" ]] then - WAS_OUTPUT=0 + # This file is needed because the output of "CodeChecker cmd diff" + # may contain lines that are only information for the user, so we can + # not rely on the existence of 'bugs.txt' as only indicator of new bugs. + echo -n "0" > "${WORKSPACE}/was_output.txt" fi echo "${line}" @@ -82,8 +87,9 @@ then eval "${DIFF_CMD}" echo "Bug visualisation HTML files generated at \"${HTML_DIR}\"." -end +fi +WAS_OUTPUT=$(cat "${WORKSPACE}/was_output.txt") if [ $WAS_OUTPUT -eq 1 ] then echo "New bugs introduced!" @@ -100,4 +106,4 @@ maintainers. This can be done via e-mail sending, setting these as attachments, or copying these files into a persistent (outside the CI job's workspace!) place and -sending its URL to the maintainers. \ No newline at end of file +sending its URL to the maintainers. diff --git a/docs/script_update.md b/docs/script_update.md index 7d7a5ab55b..7a7bc7bdb4 100644 --- a/docs/script_update.md +++ b/docs/script_update.md @@ -59,13 +59,18 @@ DIFF_CMD=$(cat << END \ END ) -WAS_OUTPUT=1 +# Assume that there are new bugs introduced, unless proven otherwise. +echo -n "1" > "${WORKSPACE}/was_output.txt" + eval "${DIFF_CMD}" | while read -r line do - # If CodeChecker says there aren't new bugs, introduce them. + # If CodeChecker says there aren't new bugs, don't introduce them. if [[ "$line" =~ "- No results" ]] then - WAS_OUTPUT=0 + # This file is needed because the output of "CodeChecker cmd diff" + # may contain lines that are only information for the user, so we can + # not rely on the existence of 'bugs.txt' as only indicator of new bugs. + echo -n "0" > "${WORKSPACE}/was_output.txt" fi echo "${line}" @@ -78,8 +83,9 @@ then eval "${DIFF_CMD}" echo "Bug visualisation HTML files generated at \"${HTML_DIR}\"." -end +fi +WAS_OUTPUT=$(cat "${WORKSPACE}/was_output.txt") if [ $WAS_OUTPUT -eq 1 ] then echo "New bugs would be introduced -- rejecting pull request!" @@ -99,4 +105,4 @@ these files into a persistent (outside the CI job's workspace!) place and sending its URL to the maintainers. The return code of this script can be further used in the CI job to set ticket -or pull request status on the code tracker (such as Gerrit or GitLab). \ No newline at end of file +or pull request status on the code tracker (such as Gerrit or GitLab).