Skip to content

Commit 34dff7d

Browse files
committed
Get unittests running with freebsd
1 parent d101e75 commit 34dff7d

File tree

2 files changed

+39
-22
lines changed

2 files changed

+39
-22
lines changed

tmuxp/testsuite/util.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424

2525
logger = logging.getLogger(__name__)
2626

27-
current_dir = os.path.abspath(os.path.dirname(__file__))
28-
fixtures_dir = os.path.abspath(os.path.join(current_dir, 'fixtures'))
27+
current_dir = os.path.realpath(os.path.dirname(__file__))
28+
fixtures_dir = os.path.realpath(os.path.join(current_dir, 'fixtures'))
2929

3030

3131
class TmuxVersionTest(TmuxTestCase):

tmuxp/testsuite/workspacebuilder.py

Lines changed: 37 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
with_statement, unicode_literals
1111

1212
import os
13+
import platform
1314
import sys
1415
import logging
1516
import unittest
@@ -24,9 +25,9 @@
2425

2526
logger = logging.getLogger(__name__)
2627

27-
current_dir = os.path.abspath(os.path.dirname(__file__))
28-
example_dir = os.path.abspath(os.path.join(current_dir, '..', '..', 'examples'))
29-
fixtures_dir = os.path.abspath(os.path.join(current_dir, 'fixtures'))
28+
current_dir = os.path.realpath(os.path.dirname(__file__))
29+
example_dir = os.path.realpath(os.path.join(current_dir, '..', '..', 'examples'))
30+
fixtures_dir = os.path.realpath(os.path.join(current_dir, 'fixtures'))
3031

3132

3233
class TwoPaneTest(TmuxTestCase):
@@ -300,33 +301,39 @@ def test_automatic_rename_option(self):
300301
self.assertNotEqual(s.get('session_name'), 'tmuxp')
301302
w = s.windows[0]
302303

304+
man_window_name = 'man'
305+
306+
# BSD operating systems will wrap manual pages in less
307+
if 'BSD' in platform.system():
308+
man_window_name = 'less'
309+
303310
for i in range(60):
304311
self.session.server._update_windows()
305-
if w.get('window_name') != 'man':
312+
if w.get('window_name') != man_window_name:
306313
break
307314
time.sleep(.1)
308315

309-
self.assertNotEqual(w.get('window_name'), 'man')
316+
self.assertNotEqual(w.get('window_name'), man_window_name)
310317

311318
pane_base_index = w.show_window_option('pane-base-index', g=True)
312319
w.select_pane(pane_base_index)
313320

314321
for i in range(60):
315322
self.session.server._update_windows()
316-
if w.get('window_name') == 'man':
323+
if w.get('window_name') == man_window_name:
317324
break
318325
time.sleep(.1)
319326

320-
self.assertEqual(w.get('window_name'), text_type('man'))
327+
self.assertEqual(w.get('window_name'), text_type(man_window_name))
321328

322329
w.select_pane('-D')
323330
for i in range(60):
324331
self.session.server._update_windows()
325-
if w['window_name'] != 'man':
332+
if w['window_name'] != man_window_name:
326333
break
327334
time.sleep(.1)
328335

329-
self.assertNotEqual(w.get('window_name'), text_type('man'))
336+
self.assertNotEqual(w.get('window_name'), text_type(man_window_name))
330337

331338

332339
class BlankPaneTest(TmuxTestCase):
@@ -575,7 +582,7 @@ class PaneOrderingTest(TmuxTestCase):
575582

576583
yaml_config = """
577584
session_name: sampleconfig
578-
start_directory: '~'
585+
start_directory: {HOME}
579586
windows:
580587
- options:
581588
- automatic_rename: on
@@ -584,8 +591,11 @@ class PaneOrderingTest(TmuxTestCase):
584591
- cd /usr/bin
585592
- cd /usr
586593
- cd /sbin
587-
- cd /home
588-
"""
594+
- cd {HOME}
595+
""".format(
596+
HOME=os.path.realpath(os.path.expanduser('~'))
597+
)
598+
589599

590600
def test_pane_order(self):
591601

@@ -594,8 +604,9 @@ def test_pane_order(self):
594604
'/usr/bin',
595605
'/usr',
596606
'/sbin',
597-
'/home'
607+
os.path.realpath(os.path.expanduser('~'))
598608
]
609+
599610
s = self.session
600611
sconfig = kaptan.Kaptan(handler='yaml')
601612
sconfig = sconfig.import_config(self.yaml_config).get()
@@ -676,23 +687,23 @@ class BeforeLoadScript(TmuxTestCase):
676687

677688
config_script_not_exists = """
678689
session_name: sampleconfig
679-
before_script: {fixtures_dir}/script_not_exists.sh
690+
before_script: {script_not_exists}
680691
windows:
681692
- panes:
682693
- pane
683694
"""
684695

685696
config_script_fails = """
686697
session_name: sampleconfig
687-
before_script: {fixtures_dir}/script_failed.sh
698+
before_script: {script_failed}
688699
windows:
689700
- panes:
690701
- pane
691702
"""
692703

693704
config_script_completes = """
694705
session_name: sampleconfig
695-
before_script: {fixtures_dir}/script_complete.sh
706+
before_script: {script_complete}
696707
windows:
697708
- panes:
698709
- pane
@@ -702,8 +713,10 @@ def test_throw_error_if_retcode_error(self):
702713

703714
sconfig = kaptan.Kaptan(handler='yaml')
704715
yaml = self.config_script_fails.format(
705-
fixtures_dir=fixtures_dir
716+
fixtures_dir=fixtures_dir,
717+
script_failed=os.path.join(fixtures_dir,'script_failed.sh')
706718
)
719+
print(fixtures_dir)
707720
sconfig = sconfig.import_config(yaml).get()
708721
sconfig = config.expand(sconfig)
709722
sconfig = config.trickle(sconfig)
@@ -726,7 +739,8 @@ def test_throw_error_if_file_not_exists(self):
726739

727740
sconfig = kaptan.Kaptan(handler='yaml')
728741
yaml = self.config_script_not_exists.format(
729-
fixtures_dir=fixtures_dir
742+
fixtures_dir=fixtures_dir,
743+
script_not_exists=os.path.join(fixtures_dir,'script_not_exists.sh')
730744
)
731745
sconfig = sconfig.import_config(yaml).get()
732746
sconfig = config.expand(sconfig)
@@ -749,12 +763,15 @@ def test_throw_error_if_file_not_exists(self):
749763
msg="Kills session if before_script doesn't exist"
750764
)
751765

752-
def test_true_if_test_passes(self):
753766

767+
def test_true_if_test_passes(self):
768+
assert(os.path.exists(os.path.join(fixtures_dir,'script_complete.sh')))
754769
sconfig = kaptan.Kaptan(handler='yaml')
755770
yaml = self.config_script_completes.format(
756-
fixtures_dir=fixtures_dir
771+
fixtures_dir=fixtures_dir,
772+
script_complete=os.path.join(fixtures_dir,'script_complete.sh')
757773
)
774+
758775
sconfig = sconfig.import_config(yaml).get()
759776
sconfig = config.expand(sconfig)
760777
sconfig = config.trickle(sconfig)

0 commit comments

Comments
 (0)