Skip to content

Commit 853e083

Browse files
committed
Adde a script to verify JRuby rubyspec exclusion tags.
The script scans all tag files and report invalid entries, i.e., those that have references to already resolved/closed bugs. Sample output is like this: Verifying tags in '/opt/work/jruby.git/spec/tags'... 62 JRuby jira issues used in the tags. JRUBY-3885 -- Wrong State: Resolved. Used in the following tag files: - /opt/work/jruby.git/spec/tags/1.8/ruby/core/enumerable/none_tags.txt JRUBY-3473 -- Wrong State: Resolved. Used in the following tag files: - /opt/work/jruby.git/spec/tags/1.8/ruby/core/thread/exit_tags.txt - /opt/work/jruby.git/spec/tags/1.8/ruby/core/thread/terminate_tags.txt
1 parent ff7e099 commit 853e083

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

spec/tags_verify.rb

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
require 'xmlrpc/client'
2+
require 'pp'
3+
require 'set'
4+
5+
# Simple script to scan all JRuby's rubyspec tags
6+
# and report invalid ones, i.e. those that have
7+
# references to already resolved/closed bugs.
8+
9+
if ARGV.size != 2
10+
puts "Usage: tags_verify.rb jira-login jira-password"
11+
exit 1
12+
end
13+
14+
class JiraVerifier
15+
INVALID_STATUSES = {"5"=>"Resolved", "6"=>"Closed"}
16+
def initialize(login, pass)
17+
@server = XMLRPC::Client.new('jira.codehaus.org', "/rpc/xmlrpc")
18+
@auth = @server.call("jira1.login", login, pass)
19+
@stat_info = {}
20+
@server.call("jira1.getStatuses", @auth).each { |s|
21+
@stat_info[s["id"]] = s["name"]
22+
}
23+
# pp @stat_info
24+
end
25+
def get_issue(id)
26+
@server.call("jira1.getIssue", @auth, id)
27+
end
28+
def get_status(issue)
29+
issue["status"]
30+
end
31+
def is_valid(issue)
32+
INVALID_STATUSES[get_status(issue)].nil?
33+
end
34+
def check_ids(ids)
35+
ids.each { |id, files|
36+
issue = get_issue(id)
37+
unless (is_valid(issue))
38+
puts "#{id} -- Wrong State: #{@stat_info[get_status(issue)]}. Used in the following tag files:"
39+
files.each { |filename|
40+
puts " - #{filename}"
41+
}
42+
end
43+
}
44+
end
45+
def logout
46+
@server.call("jira1.logout", @auth)
47+
end
48+
end
49+
50+
TAGS_DIR = File.expand_path(File.join(File.dirname(__FILE__), 'tags'))
51+
puts "Verifying tags in '#{TAGS_DIR}'..."
52+
53+
ids = {}
54+
55+
Dir.glob(TAGS_DIR + "/**/*.txt").each { |filename|
56+
File.open(filename, 'r') { |f|
57+
while (line = f.gets)
58+
line.scan(/JRUBY-\d+/) { |id|
59+
(ids[id] ||= Set.new) << filename
60+
}
61+
end
62+
}
63+
}
64+
65+
puts "#{ids.size} JRuby jira issues used in the tags."
66+
67+
jira = JiraVerifier.new(ARGV[0], ARGV[1])
68+
jira.check_ids(ids)
69+
jira.logout

0 commit comments

Comments
 (0)