summaryrefslogtreecommitdiffstats
path: root/tests/shlib
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 16:40:16 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 16:40:16 +0000
commit3f25952c13d5847d510c0cae22a8ba876638d570 (patch)
tree02f505f016ed5a1029277dcae520d5e2a75906fb /tests/shlib
parentInitial commit. (diff)
downloadpowerline-3f25952c13d5847d510c0cae22a8ba876638d570.tar.xz
powerline-3f25952c13d5847d510c0cae22a8ba876638d570.zip
Adding upstream version 2.8.3.upstream/2.8.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/shlib')
-rw-r--r--tests/shlib/common.sh150
-rw-r--r--tests/shlib/vim.sh33
-rw-r--r--tests/shlib/vterm.sh17
3 files changed, 200 insertions, 0 deletions
diff --git a/tests/shlib/common.sh b/tests/shlib/common.sh
new file mode 100644
index 0000000..7794192
--- /dev/null
+++ b/tests/shlib/common.sh
@@ -0,0 +1,150 @@
+: ${USER:=`id -un`}
+: ${HOME:=`getent passwd $USER | cut -d: -f6`}
+
+if test -z "${PYTHON}" ; then
+ if test -n "$USE_UCS2_PYTHON" ; then
+ LD_LIBRARY_PATH="$HOME/opt/cpython-ucs2-$UCS2_PYTHON_VARIANT/lib${LD_LIBRARY_PATH:+:}${LD_LIBRARY_PATH}"
+ fi
+fi
+
+export LD_LIBRARY_PATH
+export USER
+export HOME
+
+if test -n "$USE_UCS2_PYTHON" ; then
+ POWERLINE_VIRTUALENV="cpython-ucs2-$UCS2_PYTHON_VARIANT"
+ PYTHON="$HOME/.virtualenvs/$POWERLINE_VIRTUALENV/bin/python"
+ if test -n "$BASH_VERSION" ; then
+ set +e
+ . virtualenvwrapper.sh
+ workon "$POWERLINE_VIRTUALENV"
+ set -e
+ fi
+fi
+
+. tests/bot-ci/scripts/common/main.sh silent
+
+export USER HOME
+
+if test -z "$FAILED" ; then
+ FAILED=0
+
+ FAIL_SUMMARY=""
+
+ TMP_ROOT="$ROOT/tests/tmp"
+ export FAILURES_FILE="$ROOT/tests/status"
+fi
+
+ANSI_CLEAR="\033[0K"
+
+travis_fold() {
+ local action="$1"
+ local name="$2"
+ name="$(echo -n "$name" | tr '\n\0' '--' | sed -r 's/[^A-Za-z0-9]+/-/g')"
+ name="$(echo -n "$name" | sed -r 's/-$//')"
+ echo -en "travis_fold:${action}:${name}\r${ANSI_CLEAR}"
+}
+
+print_environ() {
+ echo "Using $PYTHON_IMPLEMENTATION version $PYTHON_VERSION."
+ echo "Path to Python executable: $PYTHON."
+ echo "Root: $ROOT."
+ echo "Branch: $BRANCH_NAME."
+ echo "sys.path:"
+ "$PYTHON" -c "for path in __import__('sys').path: print(' %r' % path)"
+}
+
+enter_suite() {
+ set +x
+ local suite_name="$1" ; shift
+ local final="$1"
+ export POWERLINE_CURRENT_SUITE="${POWERLINE_CURRENT_SUITE}/$suite_name"
+ travis_fold start "$POWERLINE_CURRENT_SUITE"
+ print_environ
+ if test "$final" = final ; then
+ if test -n "$POWERLINE_SUITE_FINAL" ; then
+ fail __suite__/enter/final E "Final suites do not allow nesting"
+ fi
+ export POWERLINE_SUITE_FINAL=1
+ # set -x
+ fi
+}
+
+exit_suite() {
+ if test "$POWERLINE_CURRENT_SUITE" = "$POWERLINE_TMP_DIR_SUITE" ; then
+ rm_test_root
+ fi
+ if test $FAILED -ne 0 ; then
+ echo "Suite ${POWERLINE_CURRENT_SUITE} failed, summary:"
+ echo "${FAIL_SUMMARY}"
+ fi
+ set +x
+ travis_fold end "$POWERLINE_CURRENT_SUITE"
+ export POWERLINE_CURRENT_SUITE="${POWERLINE_CURRENT_SUITE%/*}"
+ if test "$1" != "--continue" ; then
+ exit $FAILED
+ else
+ unset POWERLINE_SUITE_FINAL
+ fi
+}
+
+_fail() {
+ local allow_failure=
+ if test "$1" = "--allow-failure" ; then
+ shift
+ allow_failure=A
+ fi
+ local test_name="$1" ; shift
+ local fail_char="$allow_failure$1" ; shift
+ local message="$1" ; shift
+ local verb="$1" ; shift
+ local full_msg="$fail_char $POWERLINE_CURRENT_SUITE|$test_name :: $message"
+ FAIL_SUMMARY="${FAIL_SUMMARY}${NL}${full_msg}"
+ echo "$verb: $full_msg"
+ echo "$full_msg" >> "$FAILURES_FILE"
+ if test -z "$allow_failure" ; then
+ FAILED=1
+ fi
+}
+
+fail() {
+ _fail "$@" "Failed"
+}
+
+skip() {
+ local test_name="$1" ; shift
+ local message="$1" ; shift
+ _fail --allow-failure "$test_name" S "$message" "Skipped"
+}
+
+make_test_root() {
+ local suffix="${POWERLINE_CURRENT_SUITE##*/}"
+
+ local tmpdir="$TMP_ROOT/$suffix/"
+ export POWERLINE_TMP_DIR_SUITE="$POWERLINE_CURRENT_SUITE"
+
+ if test -d "$tmpdir" ; then
+ rm -r "$tmpdir"
+ fi
+
+ mkdir -p "$tmpdir"
+
+ export TEST_ROOT="$tmpdir"
+}
+
+rm_test_root() {
+ if test -e "$FAILURES_FILE" ; then
+ return 0
+ fi
+ local suffix="${POWERLINE_CURRENT_SUITE##*/}"
+ if test -d "$TMP_ROOT/$suffix" ; then
+ rm -r "$TMP_ROOT/$suffix"
+ rmdir "$TMP_ROOT" &>/dev/null || true
+ fi
+}
+
+if ! command -v realpath ; then
+ realpath() {
+ $PYTHON -c 'import os, sys; print(os.path.realpath(sys.argv[1]))' "$1"
+ }
+fi
diff --git a/tests/shlib/vim.sh b/tests/shlib/vim.sh
new file mode 100644
index 0000000..49346da
--- /dev/null
+++ b/tests/shlib/vim.sh
@@ -0,0 +1,33 @@
+. tests/bot-ci/scripts/common/main.sh
+
+if test -z "$POWERLINE_VIM_EXE" ; then
+ if test -n "$USE_UCS2_PYTHON" ; then
+ NEW_VIM="$ROOT/tests/bot-ci/deps/vim/master-$UCS2_PYTHON_VARIANT-ucs2-double/vim"
+ OLD_VIM="$ROOT/tests/bot-ci/deps/vim/v7.0.112-$UCS2_PYTHON_VARIANT-ucs2/vim"
+ opt_dir="$HOME/opt/cpython-ucs2-$UCS2_PYTHON_VARIANT"
+ main_path="$opt_dir/lib/python$UCS2_PYTHON_VARIANT"
+ site_path="$main_path/site-packages"
+ venv_main_path="$VIRTUAL_ENV/lib/python$UCS2_PYTHON_VARIANT"
+ venv_site_path="$venv_main_path/site-packages"
+ new_paths="${main_path}:${site_path}:${venv_main_path}:${venv_site_path}"
+ export PYTHONPATH="$new_paths${PYTHONPATH:+:}$PYTHONPATH"
+ else
+ if test "$PYTHON_IMPLEMENTATION" != "CPython" ; then
+ exit 0
+ fi
+ if test -d "$ROOT/tests/bot-ci/deps" ; then
+ NEW_VIM="$ROOT/tests/bot-ci/deps/vim/master-$PYTHON_MM/vim"
+ OLD_VIM="$ROOT/tests/bot-ci/deps/vim/v7.0.112-$PYTHON_MM/vim"
+ else
+ NEW_VIM="vim"
+ fi
+ if test -e "$OLD_VIM" ; then
+ VIMS="NEW_VIM OLD_VIM"
+ else
+ VIMS="NEW_VIM"
+ fi
+ fi
+else
+ NEW_VIM="$POWERLINE_VIM_EXE"
+ OLD_VIM="$POWERLINE_VIM_EXE"
+fi
diff --git a/tests/shlib/vterm.sh b/tests/shlib/vterm.sh
new file mode 100644
index 0000000..bf95bb1
--- /dev/null
+++ b/tests/shlib/vterm.sh
@@ -0,0 +1,17 @@
+. tests/shlib/common.sh
+set +x
+
+vterm_setup() {
+ make_test_root
+
+ mkdir "$TEST_ROOT/path"
+
+ ln -s "$(command -v "${PYTHON}")" "$TEST_ROOT/path/python"
+ ln -s "$(command -v bash)" "$TEST_ROOT/path"
+
+ cp -r "$ROOT/tests/terminfo" "$TEST_ROOT"
+}
+
+vterm_shutdown() {
+ rm_test_root
+}