fa66067486
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@669975 13f79535-47bb-0310-9956-ffa450edef68
126 lines
2.7 KiB
Ruby
126 lines
2.7 KiB
Ruby
=begin
|
|
|
|
Scans java test source files, recursively from the current directory,
|
|
looking for ignored test methods producing a list of such test methods
|
|
and their associated blocking Jiras.
|
|
|
|
The implementation makes heavy use of my scant knowledge of regex. I'll
|
|
comeback and clean this up as time allows.
|
|
|
|
Only proceses testfiles and assumes they are named like: *TestCase.java
|
|
|
|
Assumes a test annotation convention like this:
|
|
|
|
@Ignores("TUSCANY-xxxx")
|
|
public void someTest() throws Exception {
|
|
|
|
Example command line usage
|
|
>ruby listignores.rb > scan.txt
|
|
|
|
Current output is formatted as normal text
|
|
|
|
=end
|
|
class TestMethod
|
|
|
|
def initialize(text, parent)
|
|
@text = text
|
|
@parent = parent
|
|
end
|
|
|
|
def name
|
|
regex = /void\s*\S*\(\) /
|
|
str = @text[regex]
|
|
str.sub(/void\s*/, '')
|
|
end
|
|
|
|
def ignore_line
|
|
@text[/^\s*@Ignore.*/]
|
|
end
|
|
|
|
def jira
|
|
result = ignore_line
|
|
result = result[/\d{4,5}/]
|
|
result ? ", T-" + result : ", no associated jira"
|
|
end
|
|
|
|
def ignore_string
|
|
ignore_line ? jira : ""
|
|
end
|
|
|
|
def to_s
|
|
self.name + ignore_string + "\n"
|
|
end
|
|
end
|
|
|
|
class TestCase
|
|
attr_accessor :text, :ignored_methods
|
|
|
|
def initialize(text)
|
|
@text = text
|
|
@ignored_methods = Array.new
|
|
create_ignored_methods
|
|
end
|
|
|
|
def create_ignored_methods
|
|
regex = /@Ignore.*?\{/m
|
|
test_method_text_array = text.scan(regex)
|
|
test_method_text_array.each do |t|
|
|
@ignored_methods<<TestMethod.new(t, self)
|
|
end
|
|
end
|
|
|
|
def package_name
|
|
line = @text[/pack.*$/]
|
|
line.sub!(/package /, '')
|
|
line.sub(/;/, '')
|
|
end
|
|
|
|
def testcase_name
|
|
text[/\S*TestCase/]
|
|
end
|
|
|
|
def long_name
|
|
package_name + "." + testcase_name
|
|
end
|
|
|
|
def has_ignored_methods
|
|
@ignored_methods.size > 0
|
|
end
|
|
|
|
end
|
|
|
|
def process_file(fn)
|
|
text = String.new
|
|
File.open(fn) { |f| text = f.read }
|
|
$testcases << TestCase.new(text)
|
|
end
|
|
|
|
$testcases = Array.new
|
|
svn_info = `svn info`
|
|
svn_revision = svn_info[/Revision: \d*/]
|
|
|
|
Dir["**/*TestCase.java"].each do |filename|
|
|
process_file(filename)
|
|
end
|
|
|
|
puts "Content generated by from #{Dir.pwd}"
|
|
puts "Test case files scanned " + Date.today.to_s + " (svn:" + svn_revision + ")"
|
|
puts "* Total files processed = #{$testcases.size}"
|
|
num_ignored = 0
|
|
$testcases.each {|c|num_ignored = num_ignored + c.ignored_methods.size}
|
|
puts "* Total ignored test cases = " + num_ignored.to_s
|
|
puts ""
|
|
|
|
puts "The following test cases have ignored test methods ..."
|
|
puts ""
|
|
cases = $testcases.select{|c| c.has_ignored_methods}
|
|
cases.each do |c|
|
|
puts c.long_name
|
|
c.ignored_methods.each {|m| puts " " + m.to_s}
|
|
puts ""
|
|
end
|
|
|
|
|
|
|
|
|
|
|