From 166f827c9faa0ea2eb9014622a11d9847c760c48 Mon Sep 17 00:00:00 2001 From: ZyX Date: Thu, 23 Jan 2014 07:36:08 +0400 Subject: [PATCH] Improve test_shells/test.sh: - Add argument that makes it run only one shell - Make this argument also force skipping removal of tests/shell directory - Make it copy logs to tests/shell before and after processing --- tests/test_shells/test.sh | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/tests/test_shells/test.sh b/tests/test_shells/test.sh index d2350190..f2f07e71 100755 --- a/tests/test_shells/test.sh +++ b/tests/test_shells/test.sh @@ -1,15 +1,6 @@ #!/bin/sh FAILED=0 - -if [ "$(echo '\e')" != '\e' ] ; then - safe_echo() { - echo -E "$@" - } -else - safe_echo() { - echo "$@" - } -fi +ONLY_SHELL="$1" check_screen_log() { if test -e tests/test_shells/${1}.ok ; then @@ -23,12 +14,15 @@ check_screen_log() { run_test() { SH="$1" - SESNAME="powerline-shell-test-$$" + SESNAME="powerline-shell-test-${SH}-$$" + + test "x$ONLY_SHELL" = "x" || test "x$ONLY_SHELL" = "x$SH" || return 0 + screen -L -c tests/test_shells/screenrc -d -m -S "$SESNAME" \ env LANG=en_US.UTF-8 BINDFILE="$BINDFILE" "$@" screen -S "$SESNAME" -X readreg a tests/test_shells/input.$SH # Wait for screen to initialize - sleep 0.3s + sleep 1s screen -S "$SESNAME" -p 0 -X width 300 1 screen -S "$SESNAME" -p 0 -X logfile tests/shell/screen.log screen -S "$SESNAME" -p 0 -X paste a @@ -37,16 +31,21 @@ run_test() { while screen -S "$SESNAME" -X blankerprg "" > /dev/null ; do sleep 0.1s done + cp tests/shell/screen.log tests/shell/${SH}.full.log ./tests/test_shells/postproc.py tests/shell/screen.log + cp tests/shell/screen.log tests/shell/${SH}.log if ! check_screen_log ${SH} ; then # Repeat the diff to make it better viewable in travis output check_screen_log ${SH} | cat -v echo "Failed ${SH}" + rm tests/shell/screen.log return 1 fi + rm tests/shell/screen.log return 0 } +test -d tests/shell && rm -r tests/shell mkdir tests/shell git init tests/shell/3rd git --git-dir=tests/shell/3rd/.git checkout -b BRANCH @@ -54,18 +53,15 @@ git --git-dir=tests/shell/3rd/.git checkout -b BRANCH if ! run_test bash --norc --noprofile -i ; then FAILED=1 fi -rm tests/shell/screen.log if ! run_test zsh -f -i ; then FAILED=1 fi -rm tests/shell/screen.log export XDG_CONFIG_HOME=/dev/null if ! run_test fish -i ; then FAILED=1 fi -rm tests/shell/screen.log -rm -r tests/shell +test "x$ONLY_SHELL" = "x" && rm -r tests/shell exit $FAILED