blob: 661be4e5637de91ff4ffd951b435bcea82af8c05 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
=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
|