Skip to content

Commit d71b2bc

Browse files
committed
test(workspacebuilder): Sleep in command
1 parent fb25241 commit d71b2bc

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

tests/test_workspacebuilder.py

+68
Original file line numberDiff line numberDiff line change
@@ -963,3 +963,71 @@ def test_load_workspace_enter(
963963
assert output in captured_pane
964964
else:
965965
assert output not in captured_pane
966+
967+
968+
@pytest.mark.parametrize(
969+
"yaml,output",
970+
[
971+
[
972+
textwrap.dedent(
973+
"""
974+
session_name: Should not execute
975+
windows:
976+
- panes:
977+
- shell_command: echo "___$((1 + 3))___"
978+
sleep: 2
979+
"""
980+
),
981+
"___4___",
982+
],
983+
[
984+
textwrap.dedent(
985+
"""
986+
session_name: Should not execute
987+
windows:
988+
- panes:
989+
- shell_command:
990+
- echo "___$((1 + 3))___"
991+
sleep: 2
992+
"""
993+
),
994+
"___4___",
995+
],
996+
],
997+
ids=[
998+
"pane_sleep_3_shortform",
999+
"pane_sleep_3_longform",
1000+
],
1001+
)
1002+
def test_load_workspace_sleep(
1003+
tmp_path: pathlib.Path,
1004+
server: libtmux.Server,
1005+
monkeypatch: pytest.MonkeyPatch,
1006+
yaml,
1007+
output,
1008+
):
1009+
yaml_config = tmp_path / "simple.yaml"
1010+
yaml_config.write_text(
1011+
yaml,
1012+
encoding="utf-8",
1013+
)
1014+
sconfig = kaptan.Kaptan(handler="yaml")
1015+
sconfig = sconfig.import_config(str(yaml_config)).get()
1016+
sconfig = config.expand(sconfig)
1017+
sconfig = config.trickle(sconfig)
1018+
builder = WorkspaceBuilder(sconf=sconfig, server=server)
1019+
builder.build()
1020+
1021+
t = time.process_time()
1022+
1023+
time.sleep(1)
1024+
session = builder.session
1025+
pane = session.attached_pane
1026+
1027+
while (time.process_time() - t) * 1000 < 2:
1028+
captured_pane = "\n".join(pane.capture_pane())
1029+
1030+
assert output not in captured_pane
1031+
time.sleep(0.1)
1032+
captured_pane = "\n".join(pane.capture_pane())
1033+
assert output in captured_pane

0 commit comments

Comments
 (0)