Signed-off-by: Anna (cybertailor) Vyalkova <[email protected]>
---
eclass/vim-plugin.eclass | 78 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 78 insertions(+)
diff --git a/eclass/vim-plugin.eclass b/eclass/vim-plugin.eclass
index 31cb87eaf38..0f844fda600 100644
--- a/eclass/vim-plugin.eclass
+++ b/eclass/vim-plugin.eclass
@@ -160,6 +160,58 @@ if [[ ${PV} != 9999* ]] ; then
fi
SLOT="0"
+# @ECLASS_VARIABLE: VIM
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# The executable name of the current Vim implementation.
+#
+# This variable is set automatically in functions called by vim_foreach_impl().
+
+if _using_vim_pack; then
+# @FUNCTION: vim_foreach_impl
+# @USAGE: <command> [<args>...]
+# @DESCRIPTION:
+# Run the given command for each of the enabled Vim implementations.
+# If additional parameters are passed, they will be passed through
+# to the command.
+#
+# The function will return 0 status if all invocations succeed.
+# Otherwise, the return code from first failing invocation will
+# be returned.
+#
+# For each command being run, VIM is set locally and exported to
+# the command environment.
+#
+# This function is only defined since EAPI 9.
+vim_foreach_impl() {
+ debug-print-function ${FUNCNAME} "$@"
+
+ local ret=0 lret=0 impl
+ for impl in "${VIM_COMPAT[@]}"; do
+ if ! command -v "${impl}" >/dev/null; then
+ ewarn "${impl} is not installed, skipping"
+ continue
+ fi
+
+ _multibuild_run() {
+ # find the first non-private command
+ local i=1
+ while [[ ${!i} == _* ]]; do
+ (( i += 1 ))
+ done
+
+ [[ ${i} -le ${#} ]] && einfo "${impl}: running
${@:${i}}"
+ "${@}"
+ }
+
+ local -x VIM="${impl}"
+ _multibuild_run "${@}"
+ lret=${?}
+ [[ ${ret} -eq 0 && ${lret} -ne 0 ]] && ret=${lret}
+ done
+}
+fi
+
if [[ ${_DEFINE_VIM_PLUGIN_SRC_PREPARE} ]]; then
# @FUNCTION: vim-plugin_src_prepare
# @DESCRIPTION:
@@ -193,6 +245,29 @@ vim-plugin_src_prepare() {
}
fi
+if _using_vim_pack; then
+# @FUNCTION: vim-plugin_src_test
+# @DESCRIPTION:
+# Overrides the default src_test phase.
+#
+# If vim_test() function is defined, run it for each supported
+# Vim implementation.
+# Note that nothing is set up automatically, you'll have to handle
+# VIM="vim" or VIM="nvim" yourself.
+#
+# This function is only defined and exported since EAPI 9.
+vim-plugin_src_test() {
+ debug-print-function ${FUNCNAME} "$@"
+ local ret=0
+
+ if declare -f vim_test >/dev/null; then
+ vim_foreach_impl vim_test || ret=${?}
+ fi
+
+ return ${ret}
+}
+fi
+
# @ECLASS_VARIABLE: _VIM_PLUGIN_ALLOWED_DIRS
# @INTERNAL
# @DESCRIPTION:
@@ -435,6 +510,9 @@ fi
# src_prepare is only exported in EAPI >= 8
[[ ${_DEFINE_VIM_PLUGIN_SRC_PREPARE} ]] && EXPORT_FUNCTIONS src_prepare
+# src_test is only exported in EAPI >= 9
+_using_vim_pack && EXPORT_FUNCTIONS src_test
+
# pkg_postrm is only exported in EAPI < 9
_using_vim_pack || EXPORT_FUNCTIONS pkg_postrm
--
2.52.0