Skip to content

Commit 4c4759d

Browse files
committed
Make test more robust against slow CI runs
Similar to test_suppress_history
1 parent bdfa625 commit 4c4759d

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

tests/test_workspacebuilder.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ def test_window_options(session):
259259
w.select_layout(wconf['layout'])
260260

261261

262+
@pytest.mark.flaky(reruns=5)
262263
def test_window_options_after(session):
263264
yaml_config = loadfixture("workspacebuilder/window_options_after.yaml")
264265
s = session
@@ -270,21 +271,35 @@ def test_window_options_after(session):
270271
builder.build(session=session)
271272

272273
def assert_last_line(p, s):
273-
# Print output for easier debugging if test fails
274-
print('\n'.join(p.cmd('capture-pane', '-p').stdout))
275-
assert p.cmd('capture-pane', '-p').stdout[-2] == s
274+
correct = False
275+
for _ in range(10):
276+
pane_out = p.cmd('capture-pane', '-p', '-J').stdout
277+
if len(pane_out) > 1 and pane_out[-2].strip() == s:
278+
correct = True
279+
break
280+
281+
time.sleep(0.1)
282+
283+
# Print output for easier debugging if assertion fails
284+
if not correct:
285+
print('\n'.join(pane_out))
286+
287+
return correct
276288

277289
for i, pane in enumerate(session.attached_window.panes):
278-
assert_last_line(pane, str(i))
290+
assert assert_last_line(pane, str(i)), \
291+
"Initial command did not execute properly/" + str(i)
279292
pane.cmd('send-keys', 'Up') # Will repeat echo
280293
pane.enter() # in each iteration
281-
assert_last_line(pane, str(i))
294+
assert assert_last_line(pane, str(i)), \
295+
"Repeated command did not execute properly/" + str(i)
282296

283297
session.cmd('send-keys', ' echo moo')
284298
session.cmd('send-keys', 'Enter')
285299

286300
for pane in session.attached_window.panes:
287-
assert_last_line(pane, 'moo')
301+
assert assert_last_line(pane, 'moo'), \
302+
"Synchronized command did not execute properly"
288303

289304

290305
def test_window_shell(session):

0 commit comments

Comments
 (0)