99import os
1010import re
1111
12+ skip_nesting_level = 0
1213
1314###############################################################################################
1415###
@@ -115,7 +116,7 @@ def updown_process_line(
115116 return
116117 if len (options ) > 1 :
117118 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" ,
119120 suppress_list = None ,
120121 replace_list = None ,
121122 )
@@ -137,7 +138,8 @@ def updown_process_line(
137138def process_command (
138139 line , lineno , filename , predicate_list , replace_list , suppress_list , create_sections
139140) -> bool :
140-
141+
142+ global skip_nesting_level
141143 command = r"^\[\s*(\w+)\s+(\w+)\s*\]\s*:\s*(.*)"
142144 match = re .search (command , line )
143145
@@ -168,12 +170,25 @@ def process_command(
168170 )
169171 elif keyword == "skip" :
170172 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+ )
171180 output (
172181 "if false; then" ,
173182 replace_list = replace_list ,
174183 suppress_list = suppress_list ,
175184 )
176185 elif trailing_command == "end" :
186+ if skip_nesting_level < 0 :
187+ output (
188+ "echo 'skip end without matching skip begin in line {lineno} of {filename}'\n exit 1;" ,
189+ replace_list = replace_list ,
190+ suppress_list = suppress_list ,
191+ )
177192 output (
178193 "fi" ,
179194 replace_list = replace_list ,
@@ -187,6 +202,12 @@ def process_command(
187202 )
188203 exit (1 )
189204 elif keyword == "end" :
205+ if skip_nesting_level > 0 :
206+ output (
207+ "echo 'skip begin without matching skip end in line {lineno} of {filename}'\n exit 1;" ,
208+ replace_list = replace_list ,
209+ suppress_list = suppress_list ,
210+ )
190211 if create_sections :
191212 output (
192213 "echo '::endgroup::'" ,
@@ -303,7 +324,7 @@ def updown_processor(
303324 )
304325
305326 output (
306- "echo 'reached end of file without exit command'\n exit 1;" ,
327+ "echo 'reached end of file without `end` command'\n exit 1;" ,
307328 suppress_list = None ,
308329 replace_list = None ,
309330 )
0 commit comments