From f846e8e8de1ea8d9ed073e617b814c6562d0df25 Mon Sep 17 00:00:00 2001 From: ThiefMaster Date: Mon, 31 Mar 2014 00:01:54 +0200 Subject: [PATCH 1/7] Fix StartDirectoryTest It never checked if the start directory was properly set on the right window. Now it does. --- tmuxp/testsuite/workspacebuilder.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tmuxp/testsuite/workspacebuilder.py b/tmuxp/testsuite/workspacebuilder.py index d980bbcbe2..e59cfe04e2 100644 --- a/tmuxp/testsuite/workspacebuilder.py +++ b/tmuxp/testsuite/workspacebuilder.py @@ -416,10 +416,10 @@ def test_start_directory(self): builder.build(session=self.session) assert(self.session == builder.session) - for path in ['/usr/bin', '/dev/', '/usr/', os.getcwd()]: - for window in self.session.windows: - for p in window.panes: - self.assertTrue(p.get('pane_start_path', path)) + dirs = ['/usr/bin', '/dev', '/usr', os.getcwd()] + for path, window in zip(dirs, self.session.windows): + for p in window.panes: + self.assertEqual(p.get('pane_start_path'), path) class PaneOrderingTest(TmuxTestCase): From 7b030d1a2dfaaa92f43d3243ae2b0ac4f53d041e Mon Sep 17 00:00:00 2001 From: ThiefMaster Date: Mon, 31 Mar 2014 00:13:31 +0200 Subject: [PATCH 2/7] Add testcase for start_directory with a space --- tmuxp/testsuite/workspacebuilder.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tmuxp/testsuite/workspacebuilder.py b/tmuxp/testsuite/workspacebuilder.py index e59cfe04e2..b8fd184581 100644 --- a/tmuxp/testsuite/workspacebuilder.py +++ b/tmuxp/testsuite/workspacebuilder.py @@ -384,6 +384,16 @@ class StartDirectoryTest(TmuxTestCase): - echo "hey" - shell_command: - echo "moo" + - window_name: cwd containing a space + start_directory: /tmp/foo bar + layout: main-horizontal + panes: + - shell_command: + - pwd + - shell_command: + - echo "hey" + - shell_command: + - echo "moo" - window_name: testsa3 layout: main-horizontal panes: @@ -416,7 +426,7 @@ def test_start_directory(self): builder.build(session=self.session) assert(self.session == builder.session) - dirs = ['/usr/bin', '/dev', '/usr', os.getcwd()] + dirs = ['/usr/bin', '/dev', '/tmp/foo bar', '/usr', os.getcwd()] for path, window in zip(dirs, self.session.windows): for p in window.panes: self.assertEqual(p.get('pane_start_path'), path) From 9776d487522dfdaa085e7ebb19a09af6c4b2f9af Mon Sep 17 00:00:00 2001 From: ThiefMaster Date: Mon, 31 Mar 2014 00:41:43 +0200 Subject: [PATCH 3/7] Fix start directory with a space --- tmuxp/session.py | 1 - tmuxp/window.py | 1 - 2 files changed, 2 deletions(-) diff --git a/tmuxp/session.py b/tmuxp/session.py index b4ef7a3731..88716c214f 100644 --- a/tmuxp/session.py +++ b/tmuxp/session.py @@ -164,7 +164,6 @@ def new_window(self, if start_directory: # as of 2014-02-08 tmux 1.9-dev doesn't expand ~ in new-window -c. start_directory = os.path.expanduser(start_directory) - start_directory = pipes.quote(start_directory) window_args += ('-c%s' % start_directory,) window_args += ( diff --git a/tmuxp/window.py b/tmuxp/window.py index 93439d6edd..bc259ea013 100644 --- a/tmuxp/window.py +++ b/tmuxp/window.py @@ -378,7 +378,6 @@ def split_window( if start_directory: # as of 2014-02-08 tmux 1.9-dev doesn't expand ~ in new-window -c. start_directory = os.path.expanduser(start_directory) - start_directory = pipes.quote(start_directory) tmux_args += ('-c%s' % start_directory,) if not attach: From 3128b8a0d73129f461d05018414eb9b8b709eae2 Mon Sep 17 00:00:00 2001 From: ThiefMaster Date: Mon, 31 Mar 2014 00:42:03 +0200 Subject: [PATCH 4/7] Fix session renaming with a space --- tmuxp/session.py | 1 - tmuxp/testsuite/helpers.py | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/tmuxp/session.py b/tmuxp/session.py index 88716c214f..105332222f 100644 --- a/tmuxp/session.py +++ b/tmuxp/session.py @@ -108,7 +108,6 @@ def rename_session(self, new_name): :rtype: :class:`Session` """ - new_name = pipes.quote(new_name) proc = self.tmux( 'rename-session', '-t%s' % self.get('session_id'), diff --git a/tmuxp/testsuite/helpers.py b/tmuxp/testsuite/helpers.py index d51d1139fe..8d7004fefe 100644 --- a/tmuxp/testsuite/helpers.py +++ b/tmuxp/testsuite/helpers.py @@ -20,7 +20,7 @@ logger = logging.getLogger(__name__) -TEST_SESSION_PREFIX = 'tmuxp_' +TEST_SESSION_PREFIX = 'test tmuxp_' def get_test_session_name(server, prefix='tmuxp_'): From 0dd07c09061c4002ca2438afe81c8563ef99b465 Mon Sep 17 00:00:00 2001 From: ThiefMaster Date: Mon, 31 Mar 2014 00:42:32 +0200 Subject: [PATCH 5/7] Remove now-unnecessary import --- tmuxp/session.py | 1 - tmuxp/window.py | 1 - 2 files changed, 2 deletions(-) diff --git a/tmuxp/session.py b/tmuxp/session.py index 105332222f..558be22b47 100644 --- a/tmuxp/session.py +++ b/tmuxp/session.py @@ -9,7 +9,6 @@ with_statement, unicode_literals import os -import pipes import logging from .window import Window diff --git a/tmuxp/window.py b/tmuxp/window.py index bc259ea013..dc55f8fcd0 100644 --- a/tmuxp/window.py +++ b/tmuxp/window.py @@ -9,7 +9,6 @@ with_statement, unicode_literals import os -import pipes import logging from . import util, formats, exc From 47c92bbb6aa73594c8327171a477a8e228ca31cf Mon Sep 17 00:00:00 2001 From: ThiefMaster Date: Tue, 1 Apr 2014 21:09:45 +0200 Subject: [PATCH 6/7] Use pane_current_path instead of pane_start_path tmux 1.9 removed the latter --- tmuxp/testsuite/workspacebuilder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmuxp/testsuite/workspacebuilder.py b/tmuxp/testsuite/workspacebuilder.py index b8fd184581..f83d29d786 100644 --- a/tmuxp/testsuite/workspacebuilder.py +++ b/tmuxp/testsuite/workspacebuilder.py @@ -429,7 +429,7 @@ def test_start_directory(self): dirs = ['/usr/bin', '/dev', '/tmp/foo bar', '/usr', os.getcwd()] for path, window in zip(dirs, self.session.windows): for p in window.panes: - self.assertEqual(p.get('pane_start_path'), path) + self.assertEqual(p.get('pane_current_path'), path) class PaneOrderingTest(TmuxTestCase): From b006dfe064feae4e4e7fb58dcf57ef7125ca73e2 Mon Sep 17 00:00:00 2001 From: ThiefMaster Date: Tue, 1 Apr 2014 22:01:46 +0200 Subject: [PATCH 7/7] Create spaces test dir if necessary --- tmuxp/testsuite/workspacebuilder.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tmuxp/testsuite/workspacebuilder.py b/tmuxp/testsuite/workspacebuilder.py index f83d29d786..4e73064cf1 100644 --- a/tmuxp/testsuite/workspacebuilder.py +++ b/tmuxp/testsuite/workspacebuilder.py @@ -415,6 +415,19 @@ class StartDirectoryTest(TmuxTestCase): - echo "moo3" """ + def setUp(self): + super(StartDirectoryTest, self).setUp() + if not os.path.exists('/tmp/foo bar'): + os.mkdir('/tmp/foo bar') + self._temp_dir_created = True + else: + self._temp_dir_created = False + + def tearDown(self): + super(StartDirectoryTest, self).tearDown() + if self._temp_dir_created: + os.rmdir('/tmp/foo bar') + def test_start_directory(self): sconfig = kaptan.Kaptan(handler='yaml')