9
9
import os
10
10
import re
11
11
12
+ skip_nesting_level = 0
12
13
13
14
###############################################################################################
14
15
###
@@ -115,7 +116,7 @@ def updown_process_line(
115
116
return
116
117
if len (options ) > 1 :
117
118
output (
118
- "echo 'cross product of options not yet supported anot line {line} of {filename}'\n exit 1" ,
119
+ "echo 'cross product of options not yet supported in line {line} of {filename}'\n exit 1" ,
119
120
suppress_list = None ,
120
121
replace_list = None ,
121
122
)
@@ -137,7 +138,8 @@ def updown_process_line(
137
138
def process_command (
138
139
line , lineno , filename , predicate_list , replace_list , suppress_list , create_sections
139
140
) -> bool :
140
-
141
+
142
+ global skip_nesting_level
141
143
command = r"^\[\s*(\w+)\s+(\w+)\s*\]\s*:\s*(.*)"
142
144
match = re .search (command , line )
143
145
@@ -168,12 +170,26 @@ def process_command(
168
170
)
169
171
elif keyword == "skip" :
170
172
if trailing_command == "begin" :
173
+ skip_nesting_level += 1
174
+ if skip_nesting_level > 1 :
175
+ output (
176
+ "echo 'nested skips are discouraged in line {lineno} of {filename} and may be prohibited in the future'" ,
177
+ replace_list = replace_list ,
178
+ suppress_list = suppress_list ,
179
+ )
171
180
output (
172
181
"if false; then" ,
173
182
replace_list = replace_list ,
174
183
suppress_list = suppress_list ,
175
184
)
176
185
elif trailing_command == "end" :
186
+ skip_nesting_level -= 1
187
+ if skip_nesting_level < 0 :
188
+ output (
189
+ "echo 'skip end without matching skip begin in line {lineno} of {filename}'\n exit 1;" ,
190
+ replace_list = replace_list ,
191
+ suppress_list = suppress_list ,
192
+ )
177
193
output (
178
194
"fi" ,
179
195
replace_list = replace_list ,
@@ -187,6 +203,12 @@ def process_command(
187
203
)
188
204
exit (1 )
189
205
elif keyword == "end" :
206
+ if skip_nesting_level > 0 :
207
+ output (
208
+ "echo 'skip begin without matching skip end in line {lineno} of {filename}'\n exit 1;" ,
209
+ replace_list = replace_list ,
210
+ suppress_list = suppress_list ,
211
+ )
190
212
if create_sections :
191
213
output (
192
214
"echo '::endgroup::'" ,
@@ -303,7 +325,7 @@ def updown_processor(
303
325
)
304
326
305
327
output (
306
- "echo 'reached end of file without exit command'\n exit 1;" ,
328
+ "echo 'reached end of file without `end` command'\n exit 1;" ,
307
329
suppress_list = None ,
308
330
replace_list = None ,
309
331
)
0 commit comments