Skip to content

Commit

Permalink
Enhance tag tool with grouping tags (openshift#2371)
Browse files Browse the repository at this point in the history
* Enhance tag tool with grouping tags

* Fix spaces issue between tags
  • Loading branch information
liangxia authored Oct 15, 2021
1 parent d298e4e commit ab55103
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
File renamed without changes.
File renamed without changes.
35 changes: 29 additions & 6 deletions tools/case_id_splitter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,10 @@ def run
res = ranges_loc[case_id]

current_tags = []
start_line_num = 0
insert_at_line = 0
insert_at_line_version = 0
insert_at_line_ipi = 0
insert_at_line_upi = 0
indention = ''

content = IO.readlines(res[:file])
Expand All @@ -200,14 +203,23 @@ def run
current_tags << tag_in_line
end
end
if content[i] =~ /^\s+(Scenario:)/
start_line_num = i
if content[i] =~ /^\s+(@4.)/
insert_at_line_version = i
next
elsif content[i] =~ /^\s+(@.*ipi)/
insert_at_line_ipi = i
next
elsif content[i] =~ /^\s+(@.*upi)/
insert_at_line_upi = i
next
elsif content[i] =~ /^\s+(Scenario:)/
insert_at_line = i
indention = ' '
break
elsif content[i] =~ /^\s+(Scenario Outline:)/
next
elsif content[i] =~ /^\s+(Examples:)/
start_line_num = i
insert_at_line = i
indention = ' '
break
end
Expand All @@ -219,9 +231,20 @@ def run
next
end

line_to_add = "#{indention}#{tag}"
puts "Adding tag #{tag} to #{res[:file]} for test case #{case_id}"
content.insert(start_line_num, line_to_add)
if tag =~ /@4[.][0-9]+/ && insert_at_line_version != 0
content_to_add = " #{tag} "
content[insert_at_line_version].lstrip!.prepend(content_to_add)
elsif tag =~ /@.*ipi/ && insert_at_line_ipi != 0
content_to_add = "#{indention}#{tag} "
content[insert_at_line_ipi].lstrip!.prepend(content_to_add)
elsif tag =~ /@.*upi/ && insert_at_line_upi != 0
content_to_add = "#{indention}#{tag} "
content[insert_at_line_upi].lstrip!.prepend(content_to_add)
else
content_to_add = "#{indention}#{tag}"
content.insert(insert_at_line, content_to_add)
end
end

File.open(res[:file], 'w') { |f| f.puts(content) }
Expand Down

0 comments on commit ab55103

Please sign in to comment.