From 56ef798218604aea11f57a9c16a056bb99d8b706 Mon Sep 17 00:00:00 2001 From: ZyX Date: Fri, 17 Jan 2014 21:34:18 +0400 Subject: [PATCH] On travis there are differences in CRs for some reason MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit strips CRs from *.ok files and test output. Test failure used to be not recognized due to pipe: `cat -v` always succeeds meaning that `if ! diff … | cat -v` always succeeds too. --- tests/test_shells/bash.ok | 24 ++++++++++++------------ tests/test_shells/postproc.py | 3 +++ tests/test_shells/test.sh | 15 +++++++++++++-- tests/test_shells/zsh.ok | 24 ++++++++++++------------ 4 files changed, 40 insertions(+), 26 deletions(-) diff --git a/tests/test_shells/bash.ok b/tests/test_shells/bash.ok index 123b9fd6..00824923 100644 --- a/tests/test_shells/bash.ok +++ b/tests/test_shells/bash.ok @@ -1,12 +1,12 @@ -  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  cd .git -  HOSTNAME  USER   BRANCH  ⋯  shell  3rd  .git  cd .. -  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  VIRTUAL_ENV="$HOME/.virtenvs/some-virtual-environment" -  HOSTNAME  USER  ⓔ  some-virtual-environment   BRANCH  ⋯  tests  shell  3rd  VIRTUAL_ENV= -  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  bash -c "echo \$\$>pid ; while true ; do sleep 0.1s ; done" & -[1] PID -  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  false -  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  1  kill `cat pid` ; sleep 1s -[1]+ Terminated bash -c "echo \$\$>pid ; while true ; do sleep 0.1s ; done" -  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  false -  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  exit -exit +  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  cd .git +  HOSTNAME  USER   BRANCH  ⋯  shell  3rd  .git  cd .. +  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  VIRTUAL_ENV="$HOME/.virtenvs/some-virtual-environment" +  HOSTNAME  USER  ⓔ  some-virtual-environment   BRANCH  ⋯  tests  shell  3rd  VIRTUAL_ENV= +  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  bash -c "echo \$\$>pid ; while true ; do sleep 0.1s ; done" & +[1] PID +  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  false +  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  1  kill `cat pid` ; sleep 1s +[1]+ Terminated bash -c "echo \$\$>pid ; while true ; do sleep 0.1s ; done" +  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  false +  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  exit +exit diff --git a/tests/test_shells/postproc.py b/tests/test_shells/postproc.py index 8cd037d0..5ee721c9 100755 --- a/tests/test_shells/postproc.py +++ b/tests/test_shells/postproc.py @@ -24,6 +24,9 @@ with codecs.open(fname, 'r', encoding='utf-8') as R: if not found_cd: found_cd = ('cd tests/shell/3rd' in line) continue + line = line.translate({ + ord('\r'): None + }) line = line.replace(pid, 'PID') line = line.replace(hostname, 'HOSTNAME') line = line.replace(user, 'USER') diff --git a/tests/test_shells/test.sh b/tests/test_shells/test.sh index e5febb8f..f47ab5a5 100755 --- a/tests/test_shells/test.sh +++ b/tests/test_shells/test.sh @@ -11,21 +11,32 @@ else } fi +check_screen_log() { + diff -u tests/test_shells/${1}.ok tests/shell/screen.log + # Explicit is better then implicit + return $? +} + run_test() { SH="$1" SESNAME="powerline-shell-test-$$" 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 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 + # Wait for screen to exit (sending command to non-existing screen session + # fails; when launched instance exits corresponding session is deleted) while screen -S "$SESNAME" -X blankerprg "" > /dev/null ; do - sleep 1s + sleep 0.1s done ./tests/test_shells/postproc.py tests/shell/screen.log - if ! diff -u tests/test_shells/${SH}.ok tests/shell/screen.log | cat -v ; then + if ! check_screen_log ${SH} ; then + # Repeat the diff to make it better viewable in travis output + check_screen_log ${SH} | cat -v return 1 fi return 0 diff --git a/tests/test_shells/zsh.ok b/tests/test_shells/zsh.ok index 2f7256b4..9a7b0502 100644 --- a/tests/test_shells/zsh.ok +++ b/tests/test_shells/zsh.ok @@ -1,12 +1,12 @@ - -   HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  cd .git -   HOSTNAME  USER   BRANCH  ⋯  shell  3rd  .git  cd .. -   HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  VIRTUAL_ENV="$HOME/.virtenvs/some-virtual-environment" -   HOSTNAME  USER  ⓔ  some-virtual-environment   BRANCH  ⋯  tests  shell  3rd  VIRTUAL_ENV= -   HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  bash -c "echo \$\$>pid ; while true ; do sleep 0.1s ; done" & -[1] PID -   HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  false -   HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  1  kill `cat pid` ; sleep 1s -[1] + terminated bash -c "echo \$\$>pid ; while true ; do sleep 0.1s ; done" -   HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  false -   HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  exit + +  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  cd .git +  HOSTNAME  USER   BRANCH  ⋯  shell  3rd  .git  cd .. +  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  VIRTUAL_ENV="$HOME/.virtenvs/some-virtual-environment" +  HOSTNAME  USER  ⓔ  some-virtual-environment   BRANCH  ⋯  tests  shell  3rd  VIRTUAL_ENV= +  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  bash -c "echo \$\$>pid ; while true ; do sleep 0.1s ; done" & +[1] PID +  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  false +  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  1  kill `cat pid` ; sleep 1s +[1] + terminated bash -c "echo \$\$>pid ; while true ; do sleep 0.1s ; done" +  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  false +  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  exit