From c403eef4340f4014305eb7b4cc6521f0abcbcd97 Mon Sep 17 00:00:00 2001 From: ZyX Date: Wed, 6 Aug 2014 17:18:42 +0400 Subject: [PATCH 1/5] Add ipython shell tests --- tests/install.sh | 2 +- tests/test_shells/input.ipython | 7 ++ tests/test_shells/ipython.ok | 14 +++ .../profile_default/ipython_config.py | 3 + tests/test_shells/postproc.py | 10 +- tests/test_shells/test.sh | 100 ++++++++++-------- 6 files changed, 86 insertions(+), 50 deletions(-) create mode 100644 tests/test_shells/input.ipython create mode 100644 tests/test_shells/ipython.ok create mode 100644 tests/test_shells/ipython_home/profile_default/ipython_config.py diff --git a/tests/install.sh b/tests/install.sh index 1f1a3729..573a5beb 100755 --- a/tests/install.sh +++ b/tests/install.sh @@ -12,7 +12,7 @@ if python -c 'import sys; sys.exit(1 * (sys.version_info[0] != 2))' ; then pip install unittest2 argparse fi fi -sudo apt-get install -qq screen zsh tcsh mksh busybox +sudo apt-get install -qq screen zsh tcsh mksh busybox ipython # Travis has too outdated fish. It cannot be used for tests. # sudo apt-get install fish true diff --git a/tests/test_shells/input.ipython b/tests/test_shells/input.ipython new file mode 100644 index 00000000..23b80198 --- /dev/null +++ b/tests/test_shells/input.ipython @@ -0,0 +1,7 @@ +print ('cd ' + 'tests/shell/3rd') # Start of the test marker +bool 42 +bool 44 +class Test(object): +pass + +exit diff --git a/tests/test_shells/ipython.ok b/tests/test_shells/ipython.ok new file mode 100644 index 00000000..85bd82a4 --- /dev/null +++ b/tests/test_shells/ipython.ok @@ -0,0 +1,14 @@ + + In [2]  bool 42 +     2>  bool(42) + Out[2]  True + + In [3]  bool 44 +     3>  bool(44) + Out[3]  True + + In [4]  class Test(object): +          pass +          + + In [5]  exit diff --git a/tests/test_shells/ipython_home/profile_default/ipython_config.py b/tests/test_shells/ipython_home/profile_default/ipython_config.py new file mode 100644 index 00000000..babd9e79 --- /dev/null +++ b/tests/test_shells/ipython_home/profile_default/ipython_config.py @@ -0,0 +1,3 @@ +c = get_config() +c.InteractiveShellApp.extensions = ['powerline.bindings.ipython.post_0_11'] +c.TerminalInteractiveShell.autocall = 1 diff --git a/tests/test_shells/postproc.py b/tests/test_shells/postproc.py index f34fa81c..dd12f829 100755 --- a/tests/test_shells/postproc.py +++ b/tests/test_shells/postproc.py @@ -15,8 +15,11 @@ new_fname = os.path.join('tests', 'shell', shell + '.' + test_type + '.log') pid_fname = os.path.join('tests', 'shell', '3rd', 'pid') -with open(pid_fname, 'r') as P: - pid = P.read().strip() +try: + with open(pid_fname, 'r') as P: + pid = P.read().strip() +except IOError: + pid = None hostname = socket.gethostname() user = os.environ['USER'] @@ -34,7 +37,8 @@ with codecs.open(fname, 'r', encoding='utf-8') as R: }) line = line.replace(hostname, 'HOSTNAME') line = line.replace(user, 'USER') - line = line.replace(pid, 'PID') + if pid is not None: + line = line.replace(pid, 'PID') if shell == 'fish': try: start = line.index('\033[0;') diff --git a/tests/test_shells/test.sh b/tests/test_shells/test.sh index f224e22f..3977d77f 100755 --- a/tests/test_shells/test.sh +++ b/tests/test_shells/test.sh @@ -120,60 +120,68 @@ mkdir tests/shell/3rd/'$(echo)' mkdir tests/shell/3rd/'`echo`' mkdir tests/shell/fish_home +cp -r tests/test_shells/ipython_home tests/shell export XDG_CONFIG_HOME="$PWD/tests/shell/fish_home" +export IPYTHONDIR="$PWD/tests/shell/ipython_home" unset ENV -powerline-daemon -k || true -sleep 1s +if test "x${ONLY_SHELL%sh}" != "x${ONLY_SHELL}" || test "x${ONLY_SHELL}" = xbb ; then + powerline-daemon -k || true + sleep 1s -scripts/powerline-config shell command + scripts/powerline-config shell command -for TEST_TYPE in "daemon" "nodaemon" ; do - if test $TEST_TYPE == daemon ; then - sh -c 'echo $$ > tests/shell/daemon_pid; ./scripts/powerline-daemon -f &>tests/shell/daemon_log' & - fi - if ! run_test $TEST_TYPE bash --norc --noprofile -i ; then - FAILED=1 - fi - - if ! run_test $TEST_TYPE zsh -f -i ; then - FAILED=1 - fi - - if ! run_test $TEST_TYPE fish -i ; then - FAILED=1 - fi - - if ! run_test $TEST_TYPE tcsh -f -i ; then - FAILED=1 - fi - - if ! run_test $TEST_TYPE bb -i ; then - FAILED=1 - fi - - if ! run_test $TEST_TYPE mksh -i ; then - FAILED=1 - fi - - if ! run_test $TEST_TYPE dash -i ; then - # dash tests are not stable, see #931 - # FAILED=1 - true - fi - if test $TEST_TYPE == daemon ; then - ./scripts/powerline-daemon -k - wait $(cat tests/shell/daemon_pid) - if ! test -z "$(cat tests/shell/daemon_log)" ; then - echo '____________________________________________________________' - echo "Daemon log:" - echo '============================================================' - cat tests/shell/daemon_log + for TEST_TYPE in "daemon" "nodaemon" ; do + if test $TEST_TYPE == daemon ; then + sh -c 'echo $$ > tests/shell/daemon_pid; ./scripts/powerline-daemon -f &>tests/shell/daemon_log' & + fi + if ! run_test $TEST_TYPE bash --norc --noprofile -i ; then FAILED=1 fi - fi -done + + if ! run_test $TEST_TYPE zsh -f -i ; then + FAILED=1 + fi + + if ! run_test $TEST_TYPE fish -i ; then + FAILED=1 + fi + + if ! run_test $TEST_TYPE tcsh -f -i ; then + FAILED=1 + fi + + if ! run_test $TEST_TYPE bb -i ; then + FAILED=1 + fi + + if ! run_test $TEST_TYPE mksh -i ; then + FAILED=1 + fi + + if ! run_test $TEST_TYPE dash -i ; then + # dash tests are not stable, see #931 + # FAILED=1 + true + fi + if test $TEST_TYPE == daemon ; then + ./scripts/powerline-daemon -k + wait $(cat tests/shell/daemon_pid) + if ! test -z "$(cat tests/shell/daemon_log)" ; then + echo '____________________________________________________________' + echo "Daemon log:" + echo '============================================================' + cat tests/shell/daemon_log + FAILED=1 + fi + fi + done +fi + +if ! run_test ipython ipython ; then + FAILED=1 +fi test "x$ONLY_SHELL" = "x" && rm -r tests/shell exit $FAILED From 3e43995d2ce2dd5a757daae02bdd6dda9f559e93 Mon Sep 17 00:00:00 2001 From: ZyX Date: Wed, 6 Aug 2014 17:21:01 +0400 Subject: [PATCH 2/5] Use pip to install ipython, not apt-get I am very unsure that it will install ipython for all required python versions --- tests/install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/install.sh b/tests/install.sh index 573a5beb..24fdd09b 100755 --- a/tests/install.sh +++ b/tests/install.sh @@ -1,6 +1,6 @@ #!/bin/sh pip install . -pip install psutil +pip install psutil ipython if python -c 'import sys; sys.exit(1 * (sys.version_info[0] != 2))' ; then # Python 2 if python -c 'import platform, sys; sys.exit(1 - (platform.python_implementation() == "CPython"))' ; then @@ -12,7 +12,7 @@ if python -c 'import sys; sys.exit(1 * (sys.version_info[0] != 2))' ; then pip install unittest2 argparse fi fi -sudo apt-get install -qq screen zsh tcsh mksh busybox ipython +sudo apt-get install -qq screen zsh tcsh mksh busybox # Travis has too outdated fish. It cannot be used for tests. # sudo apt-get install fish true From accb174b8ba855556b00b0f5ff4ae1f207928ba7 Mon Sep 17 00:00:00 2001 From: ZyX Date: Wed, 6 Aug 2014 18:06:54 +0400 Subject: [PATCH 3/5] Do not install ipython when using python-2.6 --- tests/install.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/install.sh b/tests/install.sh index 24fdd09b..f40b99ee 100755 --- a/tests/install.sh +++ b/tests/install.sh @@ -1,15 +1,19 @@ #!/bin/sh pip install . -pip install psutil ipython +pip install psutil if python -c 'import sys; sys.exit(1 * (sys.version_info[0] != 2))' ; then # Python 2 if python -c 'import platform, sys; sys.exit(1 - (platform.python_implementation() == "CPython"))' ; then + # PyPy pip install mercurial pip install --allow-external bzr --allow-unverified bzr bzr fi if python -c 'import sys; sys.exit(1 * (sys.version_info[1] >= 7))' ; then # Python 2.6 pip install unittest2 argparse + else + # Python 2.7 + pip install ipython fi fi sudo apt-get install -qq screen zsh tcsh mksh busybox From 863264cd9945cc033c657baf048eb2959005dcb9 Mon Sep 17 00:00:00 2001 From: ZyX Date: Wed, 6 Aug 2014 18:09:57 +0400 Subject: [PATCH 4/5] Disable virtualenv segment, also test config_overrides --- tests/test_shells/ipython.ok | 20 +++++++++---------- .../profile_default/ipython_config.py | 14 +++++++++++++ 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/tests/test_shells/ipython.ok b/tests/test_shells/ipython.ok index 85bd82a4..2ccd6e14 100644 --- a/tests/test_shells/ipython.ok +++ b/tests/test_shells/ipython.ok @@ -1,14 +1,14 @@ - In [2]  bool 42 -     2>  bool(42) - Out[2]  True + In [2]  bool 42 +     2>  bool(42) + Out[2]  True - In [3]  bool 44 -     3>  bool(44) - Out[3]  True + In [3]  bool 44 +     3>  bool(44) + Out[3]  True - In [4]  class Test(object): -          pass -          + In [4]  class Test(object): +          pass +          - In [5]  exit + In [5]  exit diff --git a/tests/test_shells/ipython_home/profile_default/ipython_config.py b/tests/test_shells/ipython_home/profile_default/ipython_config.py index babd9e79..658334f1 100644 --- a/tests/test_shells/ipython_home/profile_default/ipython_config.py +++ b/tests/test_shells/ipython_home/profile_default/ipython_config.py @@ -1,3 +1,17 @@ c = get_config() c.InteractiveShellApp.extensions = ['powerline.bindings.ipython.post_0_11'] c.TerminalInteractiveShell.autocall = 1 +c.Powerline.theme_overrides = { + 'in': { + 'segment_data': { + 'virtualenv': { + 'display': False + } + } + } +} +c.Powerline.config_overrides = { + 'common': { + 'default_top_theme': 'ascii' + } +} From c3e2358931c16451c8064629c742985a0145a2e6 Mon Sep 17 00:00:00 2001 From: ZyX Date: Wed, 6 Aug 2014 18:12:59 +0400 Subject: [PATCH 5/5] Also install ipython on Python-3.3+ --- tests/install.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/install.sh b/tests/install.sh index f40b99ee..fcfd0b73 100755 --- a/tests/install.sh +++ b/tests/install.sh @@ -15,6 +15,12 @@ if python -c 'import sys; sys.exit(1 * (sys.version_info[0] != 2))' ; then # Python 2.7 pip install ipython fi +else + # Python 3 + if python -c 'import sys; sys.exit(1 * (sys.version_info < (3, 3)))' ; then + # Python 3.3+ + pip install ipython + fi fi sudo apt-get install -qq screen zsh tcsh mksh busybox # Travis has too outdated fish. It cannot be used for tests.