Skip to content

Commit 243d57b

Browse files
committed
improvements to test performance for workspacebuilder integration tests
1 parent 91fb671 commit 243d57b

File tree

1 file changed

+35
-40
lines changed

1 file changed

+35
-40
lines changed

tmuxp/testsuite/workspacebuilder.py

Lines changed: 35 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -188,12 +188,12 @@ def test_focus_pane_index(self):
188188
self.assertNotEqual(w.get('window_name'), 'man')
189189

190190
pane_path = '/usr'
191-
for i in range(60):
191+
for i in range(10):
192192
p = w.attached_pane()
193193
p.server._update_panes()
194194
if p.get('pane_current_path') == pane_path:
195195
break
196-
time.sleep(.2)
196+
time.sleep(.4)
197197

198198
self.assertEqual(p.get('pane_current_path'), pane_path)
199199

@@ -206,12 +206,12 @@ def test_focus_pane_index(self):
206206

207207
p = None
208208
pane_path = '/'
209-
for i in range(60):
209+
for i in range(10):
210210
p = window3.attached_pane()
211211
p.server._update_panes()
212212
if p.get('pane_current_path') == pane_path:
213213
break
214-
time.sleep(.2)
214+
time.sleep(.4)
215215

216216
self.assertEqual(p.get('pane_current_path'), pane_path)
217217

@@ -308,31 +308,31 @@ def test_automatic_rename_option(self):
308308
if 'BSD' in platform.system():
309309
man_window_name = 'less'
310310

311-
for i in range(60):
311+
for i in range(10):
312312
self.session.server._update_windows()
313313
if w.get('window_name') != man_window_name:
314314
break
315-
time.sleep(.1)
315+
time.sleep(.2)
316316

317317
self.assertNotEqual(w.get('window_name'), man_window_name)
318318

319319
pane_base_index = w.show_window_option('pane-base-index', g=True)
320320
w.select_pane(pane_base_index)
321321

322-
for i in range(60):
322+
for i in range(10):
323323
self.session.server._update_windows()
324324
if w.get('window_name') == man_window_name:
325325
break
326-
time.sleep(.1)
326+
time.sleep(.2)
327327

328328
self.assertEqual(w.get('window_name'), text_type(man_window_name))
329329

330330
w.select_pane('-D')
331-
for i in range(60):
331+
for i in range(10):
332332
self.session.server._update_windows()
333333
if w['window_name'] != man_window_name:
334334
break
335-
time.sleep(.1)
335+
time.sleep(.2)
336336

337337
self.assertNotEqual(w.get('window_name'), text_type(man_window_name))
338338

@@ -375,9 +375,9 @@ class StartDirectoryTest(TmuxTestCase):
375375
start_directory: '/usr'
376376
windows:
377377
- window_name: supposed to be /usr/bin
378-
start_directory: '/usr/bin'
379-
layout: main-horizontal
380378
window_index: 1
379+
start_directory: /usr/bin
380+
layout: main-horizontal
381381
options:
382382
main-pane-height: 50
383383
panes:
@@ -386,9 +386,9 @@ class StartDirectoryTest(TmuxTestCase):
386386
- shell_command:
387387
- echo "moo"
388388
- window_name: support to be /dev
389-
start_directory: '/dev'
390-
layout: main-horizontal
391389
window_index: 2
390+
start_directory: /dev
391+
layout: main-horizontal
392392
panes:
393393
- shell_command:
394394
- pwd
@@ -397,9 +397,9 @@ class StartDirectoryTest(TmuxTestCase):
397397
- shell_command:
398398
- echo "moo"
399399
- window_name: cwd containing a space
400+
window_index: 3
400401
start_directory: {TEST_DIR}
401402
layout: main-horizontal
402-
window_index: 3
403403
panes:
404404
- shell_command:
405405
- pwd
@@ -408,19 +408,19 @@ class StartDirectoryTest(TmuxTestCase):
408408
- shell_command:
409409
- echo "moo"
410410
- window_name: testsa3
411-
layout: main-horizontal
412411
window_index: 4
412+
layout: main-horizontal
413413
panes:
414414
- shell_command:
415415
- pwd
416416
- shell_command:
417417
- echo "hey"
418418
- shell_command:
419419
- echo "moo3"
420-
- window_name: cwd relative to config file
420+
- window_name: cwd relative to start_directory since no rel dir entered
421+
window_index: 5
421422
layout: main-horizontal
422423
start_directory: ./
423-
window_index: 5
424424
panes:
425425
- shell_command:
426426
- pwd
@@ -466,22 +466,23 @@ def test_start_directory(self):
466466
dirs = [
467467
'/usr/bin', '/dev', self.test_dir,
468468
'/usr',
469-
os.getcwd(),
469+
'/usr'
470470
]
471471

472472
for path, window in zip(dirs, self.session.windows):
473473
for p in window.panes:
474474
for i in range(60):
475475
p.server._update_panes()
476-
if p.get('pane_current_path') is None:
476+
pane_path = p.get('pane_current_path')
477+
if pane_path is None:
477478
pass
478479
elif (
479-
path in p.get('pane_current_path') or
480-
p.get('pane_current_path') == path
480+
path in pane_path or
481+
pane_path == path
481482
):
482483
result = (
483-
path in p.get('pane_current_path') or
484-
p.get('pane_current_path') == path
484+
path == pane_path or
485+
path in pane_path
485486
)
486487
break
487488
time.sleep(.2)
@@ -516,7 +517,6 @@ class StartDirectoryRelativeTest(TmuxTestCase):
516517
- echo "hey"
517518
- shell_command:
518519
- echo "moo"
519-
window_index: 1
520520
- window_name: support to be /dev
521521
start_directory: '/dev'
522522
layout: main-horizontal
@@ -527,7 +527,6 @@ class StartDirectoryRelativeTest(TmuxTestCase):
527527
- echo "hey"
528528
- shell_command:
529529
- echo "moo"
530-
window_index: 2
531530
- window_name: cwd containing a space
532531
start_directory: {TEST_DIR}
533532
layout: main-horizontal
@@ -538,8 +537,7 @@ class StartDirectoryRelativeTest(TmuxTestCase):
538537
- echo "hey"
539538
- shell_command:
540539
- echo "moo"
541-
window_index: 3
542-
- window_name: testsa3
540+
- window_name: inherit start_directory which is rel to config file
543541
layout: main-horizontal
544542
panes:
545543
- shell_command:
@@ -548,7 +546,6 @@ class StartDirectoryRelativeTest(TmuxTestCase):
548546
- echo "hey"
549547
- shell_command:
550548
- echo "moo3"
551-
window_index: 4
552549
- window_name: cwd relative to config file
553550
layout: main-horizontal
554551
start_directory: ./
@@ -559,7 +556,6 @@ class StartDirectoryRelativeTest(TmuxTestCase):
559556
- echo "hey"
560557
- shell_command:
561558
- echo "moo3"
562-
window_index: 5
563559
"""
564560

565561
def setUp(self):
@@ -613,15 +609,16 @@ def test_start_directory(self):
613609
assert(self.session == builder.session)
614610

615611
dirs = [
616-
'/usr/bin', '/dev',
612+
'/usr/bin',
613+
'/dev',
617614
self.test_dir,
618-
os.getcwd(),
615+
self.config_dir,
619616
self.config_dir,
620617
]
621618

622619
for path, window in zip(dirs, self.session.windows):
623620
for p in window.panes:
624-
for i in range(10):
621+
for i in range(60):
625622
p.server._update_panes()
626623
# Handle case where directories resolve to /private/ in OSX
627624
pane_path = p.get('pane_current_path')
@@ -666,7 +663,6 @@ class PaneOrderingTest(TmuxTestCase):
666663
HOME=os.path.realpath(os.path.expanduser('~'))
667664
)
668665

669-
670666
def test_pane_order(self):
671667

672668
# test order of `panes` (and pane_index) above aganist pane_dirs
@@ -784,9 +780,9 @@ def test_throw_error_if_retcode_error(self):
784780
sconfig = kaptan.Kaptan(handler='yaml')
785781
yaml = self.config_script_fails.format(
786782
fixtures_dir=fixtures_dir,
787-
script_failed=os.path.join(fixtures_dir,'script_failed.sh')
783+
script_failed=os.path.join(fixtures_dir, 'script_failed.sh')
788784
)
789-
print(fixtures_dir)
785+
790786
sconfig = sconfig.import_config(yaml).get()
791787
sconfig = config.expand(sconfig)
792788
sconfig = config.trickle(sconfig)
@@ -810,7 +806,7 @@ def test_throw_error_if_file_not_exists(self):
810806
sconfig = kaptan.Kaptan(handler='yaml')
811807
yaml = self.config_script_not_exists.format(
812808
fixtures_dir=fixtures_dir,
813-
script_not_exists=os.path.join(fixtures_dir,'script_not_exists.sh')
809+
script_not_exists=os.path.join(fixtures_dir, 'script_not_exists.sh')
814810
)
815811
sconfig = sconfig.import_config(yaml).get()
816812
sconfig = config.expand(sconfig)
@@ -833,13 +829,12 @@ def test_throw_error_if_file_not_exists(self):
833829
msg="Kills session if before_script doesn't exist"
834830
)
835831

836-
837832
def test_true_if_test_passes(self):
838-
assert(os.path.exists(os.path.join(fixtures_dir,'script_complete.sh')))
833+
assert(os.path.exists(os.path.join(fixtures_dir, 'script_complete.sh')))
839834
sconfig = kaptan.Kaptan(handler='yaml')
840835
yaml = self.config_script_completes.format(
841836
fixtures_dir=fixtures_dir,
842-
script_complete=os.path.join(fixtures_dir,'script_complete.sh')
837+
script_complete=os.path.join(fixtures_dir, 'script_complete.sh')
843838
)
844839

845840
sconfig = sconfig.import_config(yaml).get()

0 commit comments

Comments
 (0)