commit:     3994939f982f22afbc7aaf3b8eca6680ad85c617
Author:     Thomas Bracht Laumann Jespersen <t <AT> laumann <DOT> xyz>
AuthorDate: Tue Apr 12 08:59:11 2022 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri Apr 15 04:47:35 2022 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=3994939f

ebegin: Output QA warning if call to eend is missing

The idea here is to check if EBEGIN_EEND is set after the phase has been
executed. If so, then a call to eend is probably missing. This is under
the assumption that ebegin-eend invocations should be properly paired
within the same phase.

In ebegin, the EBEGIN_EEND variable is also checked, and, if set,
indicates that ebegin has been called and is missing the closing call to
eend.

I doubt that this check is perfect, but it seems to work in what little
testing I've done.

Closes: https://bugs.gentoo.org/835823
Signed-off-by: Thomas Bracht Laumann Jespersen <t <AT> laumann.xyz>
Closes: https://github.com/gentoo/portage/pull/811
Signed-off-by: Sam James <sam <AT> gentoo.org>

 bin/isolated-functions.sh | 3 +++
 bin/phase-functions.sh    | 4 ++++
 2 files changed, 7 insertions(+)

diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh
index 41ca106a4..03983a9fa 100644
--- a/bin/isolated-functions.sh
+++ b/bin/isolated-functions.sh
@@ -339,6 +339,9 @@ ebegin() {
        [[ ${RC_ENDCOL} == "yes" ]] && echo >&2
        LAST_E_LEN=$(( 3 + ${#RC_INDENTATION} + ${#msg} ))
        LAST_E_CMD="ebegin"
+       if [[ -v EBEGIN_EEND ]] ; then
+               eqawarn "QA Notice: ebegin called, but missing call to eend 
(phase: ${EBUILD_PHASE})"
+       fi
        EBEGIN_EEND=1
        return 0
 }

diff --git a/bin/phase-functions.sh b/bin/phase-functions.sh
index 301ce75ea..bccf88226 100644
--- a/bin/phase-functions.sh
+++ b/bin/phase-functions.sh
@@ -1088,6 +1088,10 @@ __ebuild_main() {
                ;;
        esac
 
+       if [[ -v EBEGIN_EEND ]] ; then
+               eqawarn "QA Notice: ebegin called, but missing call to eend 
(phase: ${1})"
+       fi
+
        # Save the env only for relevant phases.
        if ! has "${1}" clean help info nofetch ; then
                umask 002

Reply via email to