From a05857e64eeed334996cd0de5d2c5c44ef2dc9ee Mon Sep 17 00:00:00 2001 From: Foo Date: Sun, 30 Apr 2017 13:40:29 +0300 Subject: [PATCH] Move some code away of test_tmux.sh --- tests/common.sh | 6 ++++-- tests/test_in_vterm/test_tmux.sh | 15 +++------------ tests/vterm.sh | 26 ++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 14 deletions(-) create mode 100644 tests/vterm.sh diff --git a/tests/common.sh b/tests/common.sh index 5b3627a1..1b323b7b 100644 --- a/tests/common.sh +++ b/tests/common.sh @@ -3,9 +3,11 @@ set +x : ${PYTHON:=python} -FAILED=0 +if test -z "$FAILED" ; then + FAILED=0 -FAIL_SUMMARY="" + FAIL_SUMMARY="" +fi enter_suite() { local suite_name="$1" diff --git a/tests/test_in_vterm/test_tmux.sh b/tests/test_in_vterm/test_tmux.sh index 070532a8..3e8a5c57 100755 --- a/tests/test_in_vterm/test_tmux.sh +++ b/tests/test_in_vterm/test_tmux.sh @@ -1,23 +1,18 @@ #!/bin/sh . tests/common.sh +. tests/vterm.sh enter_suite tmux VTERM_TEST_DIR="$ROOT/tests/vterm_tmux" -rm -rf "$VTERM_TEST_DIR" -mkdir "$VTERM_TEST_DIR" -mkdir "$VTERM_TEST_DIR/path" +vterm_setup "$VTERM_TEST_DIR" -ln -s "$(which "${PYTHON}")" "$VTERM_TEST_DIR/path/python" -ln -s "$(which bash)" "$VTERM_TEST_DIR/path" ln -s "$(which env)" "$VTERM_TEST_DIR/path" ln -s "$(which cut)" "$VTERM_TEST_DIR/path" ln -s "$ROOT/scripts/powerline-render" "$VTERM_TEST_DIR/path" ln -s "$ROOT/scripts/powerline-config" "$VTERM_TEST_DIR/path" -cp -r "$ROOT/tests/terminfo" "$VTERM_TEST_DIR" - test_tmux() { if test "$PYTHON_IMPLEMENTATION" = PyPy; then # FIXME PyPy3 segfaults for some reason, PyPy does it as well, but @@ -46,10 +41,6 @@ else test_tmux || true fi -if test $FAILED -eq 0 ; then - rm -rf "$VTERM_TEST_DIR" -else - echo "$FAIL_SUMMARY" -fi +vterm_shutdown "$VTERM_TEST_DIR" exit_suite diff --git a/tests/vterm.sh b/tests/vterm.sh new file mode 100644 index 00000000..8105ed29 --- /dev/null +++ b/tests/vterm.sh @@ -0,0 +1,26 @@ +. tests/common.sh +. tests/bot-ci/scripts/common/main.sh +set +x + +vterm_setup() { + local test_dir="$1" ; shift + + rm -rf "$test_dir" + mkdir "$test_dir" + mkdir "$test_dir/path" + + ln -s "$(which "${PYTHON}")" "$test_dir/path/python" + ln -s "$(which bash)" "$test_dir/path" + + cp -r "$ROOT/tests/terminfo" "$test_dir" +} + +vterm_shutdown() { + local test_dir="$1" ; shift + + if test $FAILED -eq 0 ; then + rm -rf "$test_dir" + else + echo "$FAIL_SUMMARY" + fi +}