42
42
TRUNCATION_SIGN = "...'"
43
43
REMOVED_KEYWORD_LOG = 'Keyword data removed using --RemoveKeywords option.'
44
44
WKUS_KEYWORD_NAME = 'BuiltIn.Wait Until Keyword Succeeds'
45
+ FOR_KEYWORD_NAME = 'BuiltIn.For'
46
+ WHILE_KEYWORD_NAME = 'BuiltIn.While'
45
47
46
48
47
49
def check_rp_enabled (func ):
@@ -94,6 +96,8 @@ def match(self, kw: Keyword) -> bool:
94
96
95
97
96
98
WKUS_KEYWORD_MATCH = _KeywordNameMatch (WKUS_KEYWORD_NAME )
99
+ FOR_KEYWORD_MATCH = _KeywordNameMatch (FOR_KEYWORD_NAME )
100
+ WHILE_KEYWORD_NAME = _KeywordNameMatch (WHILE_KEYWORD_NAME )
97
101
98
102
99
103
# noinspection PyPep8Naming
@@ -214,7 +218,7 @@ def _log_message(self, message: LogMessage) -> None:
214
218
current_item = self .current_item
215
219
if current_item and not getattr (current_item , 'posted' , True ) and message .level not in ['ERROR' , 'WARN' ]:
216
220
self .current_item .skipped_logs .append (message )
217
- else :
221
+ elif getattr ( current_item , 'matched_filter' , None ) is not WKUS_KEYWORD_MATCH :
218
222
# Post everything skipped by '--removekeywords' option
219
223
self ._post_skipped_keywords ()
220
224
self .service .log (message = message )
@@ -280,13 +284,15 @@ def _process_keyword_skip(self):
280
284
self ._remove_keywords = True
281
285
break
282
286
if pattern_str_upper in {'NOT_RUN' , 'NOTRUN' , 'NOT RUN' }:
283
- self ._keyword_filters = [ _KeywordStatusMatch ('NOT RUN' )]
287
+ self ._keyword_filters . append ( _KeywordStatusMatch ('NOT RUN' ))
284
288
continue
285
289
if pattern_str_upper in {'FOR' , 'WHILE' , 'WUKS' }:
286
290
if pattern_str_upper == 'WUKS' :
287
- self ._keyword_filters = [WKUS_KEYWORD_MATCH ]
291
+ self ._keyword_filters .append (WKUS_KEYWORD_MATCH )
292
+ elif pattern_str_upper == 'FOR' :
293
+ self ._keyword_filters .append (FOR_KEYWORD_MATCH )
288
294
else :
289
- self ._keyword_filters = [ _KeywordNameMatch ( pattern_str )]
295
+ self ._keyword_filters . append ( WHILE_KEYWORD_NAME )
290
296
continue
291
297
if ':' in pattern_str :
292
298
pattern_type , pattern = pattern_str .split (':' , 1 )
@@ -430,7 +436,16 @@ def start_keyword(self, name: str, attributes: Dict, ts: Optional[Any] = None) -
430
436
parent = self .current_item
431
437
kwd .rp_parent_item_id = parent .rp_item_id
432
438
skip_kwd = parent .remove_data
433
- kwd .remove_data = skip_kwd or self ._remove_keyword_data or any (m .match (kwd ) for m in self ._keyword_filters )
439
+ kwd .remove_data = skip_kwd or self ._remove_keyword_data
440
+
441
+ if kwd .remove_data :
442
+ kwd .matched_filter = getattr (parent , 'matched_filter' , None )
443
+ else :
444
+ for m in self ._keyword_filters :
445
+ if m .match (kwd ):
446
+ kwd .remove_data = True
447
+ kwd .matched_filter = m
448
+ break
434
449
435
450
if skip_kwd :
436
451
kwd .rp_item_id = str (uuid .uuid4 ())
@@ -455,10 +470,11 @@ def end_keyword(self, _: Optional[str], attributes: Dict, ts: Optional[Any] = No
455
470
:param attributes: Dictionary passed by the Robot Framework
456
471
:param ts: Timestamp(used by the ResultVisitor)
457
472
"""
458
- if attributes .get ('status' ) == 'FAIL' and not self .current_item .posted :
473
+ kwd = self .current_item .update (attributes )
474
+ if kwd .status == 'FAIL' and not kwd .posted and kwd .matched_filter is not WKUS_KEYWORD_MATCH :
459
475
self ._post_skipped_keywords ()
460
476
461
- kwd = self ._remove_current_item (). update ( attributes )
477
+ self ._remove_current_item ()
462
478
if not kwd .posted :
463
479
return
464
480
self ._do_end_keyword (kwd , ts )
0 commit comments