@@ -1021,3 +1021,109 @@ def test_load_workspace_enter(
1021
1021
assert output in captured_pane
1022
1022
else :
1023
1023
assert output not in captured_pane
1024
+
1025
+
1026
+ @pytest .mark .parametrize (
1027
+ "yaml,sleep,output" ,
1028
+ [
1029
+ [
1030
+ textwrap .dedent (
1031
+ """
1032
+ session_name: Should not execute
1033
+ windows:
1034
+ - panes:
1035
+ - shell_command:
1036
+ - cmd: echo "___$((1 + 3))___"
1037
+ sleep_before: 2
1038
+ - cmd: echo "___$((1 + 3))___"
1039
+ sleep_before: 1
1040
+ """
1041
+ ),
1042
+ 3 ,
1043
+ "___4___" ,
1044
+ ],
1045
+ [
1046
+ textwrap .dedent (
1047
+ """
1048
+ session_name: Should not execute
1049
+ windows:
1050
+ - panes:
1051
+ - shell_command:
1052
+ - cmd: echo "___$((1 + 3))___"
1053
+ sleep_before: 2
1054
+ - cmd: echo "___$((1 + 3))___"
1055
+ sleep_before: 1
1056
+ """
1057
+ ),
1058
+ 3 ,
1059
+ "___4___" ,
1060
+ ],
1061
+ [
1062
+ textwrap .dedent (
1063
+ """
1064
+ session_name: Should not execute
1065
+ windows:
1066
+ - panes:
1067
+ - shell_command:
1068
+ - cmd: echo "___$((1 + 3))___"
1069
+ sleep_before: 2
1070
+ """
1071
+ ),
1072
+ 2 ,
1073
+ "___4___" ,
1074
+ ],
1075
+ [
1076
+ textwrap .dedent (
1077
+ """
1078
+ session_name: Should not execute
1079
+ windows:
1080
+ - panes:
1081
+ - shell_command:
1082
+ - cmd: echo "___$((1 + 3))___"
1083
+ sleep_before: 2
1084
+ """
1085
+ ),
1086
+ 2 ,
1087
+ "___4___" ,
1088
+ ],
1089
+ ],
1090
+ ids = [
1091
+ "command_level_sleep_3_shortform" ,
1092
+ "command_level_pane_sleep_3_longform" ,
1093
+ "pane_sleep_2_shortform" ,
1094
+ "pane_sleep_2_longform" ,
1095
+ ],
1096
+ )
1097
+ def test_load_workspace_sleep (
1098
+ tmp_path : pathlib .Path ,
1099
+ server : libtmux .Server ,
1100
+ monkeypatch : pytest .MonkeyPatch ,
1101
+ yaml ,
1102
+ sleep : int ,
1103
+ output ,
1104
+ ):
1105
+ yaml_config = tmp_path / "simple.yaml"
1106
+ yaml_config .write_text (
1107
+ yaml ,
1108
+ encoding = "utf-8" ,
1109
+ )
1110
+ sconfig = kaptan .Kaptan (handler = "yaml" )
1111
+ sconfig = sconfig .import_config (str (yaml_config )).get ()
1112
+ sconfig = config .expand (sconfig )
1113
+ sconfig = config .trickle (sconfig )
1114
+ builder = WorkspaceBuilder (sconf = sconfig , server = server )
1115
+ builder .build ()
1116
+
1117
+ t = time .process_time ()
1118
+
1119
+ time .sleep (1 )
1120
+ session = builder .session
1121
+ pane = session .attached_pane
1122
+
1123
+ while (time .process_time () - t ) * 1000 < sleep :
1124
+ captured_pane = "\n " .join (pane .capture_pane ())
1125
+
1126
+ assert output not in captured_pane
1127
+ time .sleep (0.1 )
1128
+ captured_pane = "\n " .join (pane .capture_pane ())
1129
+ assert output in captured_pane
0 commit comments