commit:     be8077d728a39ae606dc6ace51cb18fe45955f78
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Fri Jun  9 20:30:57 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri Jun  9 20:45:18 2023 +0000
URL:        
https://gitweb.gentoo.org/proj/gentoo-functions.git/commit/?id=be8077d7

test-functions: Ensure that ecma48-cpr can be resolved during src_test()

The test phase is run prior to the install phase. Compensate for this by
wrapping ecma48-cpr with a shim function and redeclaring said function
where the value of EBUILD_PHASE is equal to "test".

Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>

 functions.sh.in | 6 +++++-
 test-functions  | 8 ++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/functions.sh.in b/functions.sh.in
index 3053162..673be7d 100644
--- a/functions.sh.in
+++ b/functions.sh.in
@@ -627,7 +627,7 @@ _update_winsize() {
 
 _update_cursor_coords() {
        # shellcheck disable=2046
-       set -- $(@GENTOO_LIBEXEC_DIR@/ecma48-cpr)
+       set -- $(_ecma48_cpr)
        if [ "$#" -eq 2 ] && is_int "$1" && is_int "$2"; then
                genfun_y=$1
                genfun_x=$2
@@ -638,6 +638,10 @@ _update_cursor_coords() {
        fi
 }
 
+_ecma48_cpr() {
+       @GENTOO_LIBEXEC_DIR@/ecma48-cpr "$@"
+}
+
 # This is the main script, please add all functions above this point!
 # shellcheck disable=2034
 RC_GOT_FUNCTIONS="yes"

diff --git a/test-functions b/test-functions
index 5a6b23b..0d7b1ab 100755
--- a/test-functions
+++ b/test-functions
@@ -408,6 +408,14 @@ if ! . ./functions.sh; then
        bailout "Couldn't source ./functions.sh"
 fi
 
+# Since the test suite is normally executed during the src_test phase, the
+# ecma48-cpr utility will not yet have been installed. Account for that by
+# redeclaring its shim function.
+if [ "${EBUILD_PHASE}" = test ]; then
+       export BUILD_DIR=${PWD}
+       _ecma48_cpr() { "${BUILD_DIR}"/ecma48-cpr "$@"; }
+fi
+
 assign_tmpdir
 
 export TEST_GENFUNCS=1

Reply via email to