17
17
from robot .output import LOGGER , Message
18
18
from robot .running .builder import TestSuiteBuilder
19
19
from robot .running .builder .builders import SuiteStructureParser
20
- from robot .utils import NormalizedDict
20
+ from robot .utils import NormalizedDict , normalize
21
21
from robot .utils .filereader import FileReader
22
22
from robotcode .core .dataclasses import from_json
23
23
from robotcode .core .lsp .types import (
@@ -234,6 +234,7 @@ def __init__(self) -> None:
234
234
self .suites : List [TestItem ] = []
235
235
self .tests : List [TestItem ] = []
236
236
self .tags : Dict [str , List [TestItem ]] = defaultdict (list )
237
+ self .normalized_tags : Dict [str , List [TestItem ]] = defaultdict (list )
237
238
self .statistics = Statistics ()
238
239
self ._collected = [NormalizedDict (ignore = "_" )]
239
240
@@ -321,6 +322,7 @@ def visit_test(self, test: TestCase) -> None:
321
322
322
323
for tag in test .tags :
323
324
self .tags [str (tag )].append (item )
325
+ self .normalized_tags [normalize (str (tag ), ignore = "_" )].append (item )
324
326
325
327
self .tests .append (item )
326
328
self ._current .children .append (item )
@@ -662,10 +664,17 @@ class TagsResult:
662
664
add_help_option = True ,
663
665
epilog = 'Use "-- --help" to see `robot` help.' ,
664
666
)
667
+ @click .option (
668
+ "--normalized / --not-normalized" ,
669
+ "normalized" ,
670
+ default = True ,
671
+ help = "Whether or not normalized tags are shown." ,
672
+ )
665
673
@add_options (* ROBOT_OPTIONS )
666
674
@pass_application
667
675
def tags (
668
676
app : Application ,
677
+ normalized : bool ,
669
678
by_longname : Tuple [str , ...],
670
679
exclude_by_longname : Tuple [str , ...],
671
680
robot_options_and_args : Tuple [str , ...],
@@ -692,12 +701,14 @@ def tags(
692
701
def print (tags : Dict [str , List [TestItem ]]) -> Iterable [str ]:
693
702
for tag , items in tags .items ():
694
703
yield f"{ tag } { os .linesep } "
704
+ # for t in items:
705
+ # yield f" {t.longname}{os.linesep}"
695
706
696
- if collector .suites :
697
- app .echo_via_pager (print (collector .tags ))
707
+ if collector .normalized_tags :
708
+ app .echo_via_pager (print (collector .normalized_tags if normalized else collector . tags ))
698
709
699
710
else :
700
- app .print_data (TagsResult (collector .tags ), remove_defaults = True )
711
+ app .print_data (TagsResult (collector .normalized_tags ), remove_defaults = True )
701
712
702
713
703
714
@dataclass
0 commit comments