tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwilli...@apache.org
Subject svn commit: r666955 - /incubator/tuscany/java/etc/listignores.rb
Date Thu, 12 Jun 2008 05:10:54 GMT
Author: kwilliams
Date: Wed Jun 11 22:10:54 2008
New Revision: 666955

URL: http://svn.apache.org/viewvc?rev=666955&view=rev
Log:
Ruby script to scan test cases and list ignored test methods

Added:
    incubator/tuscany/java/etc/listignores.rb

Added: incubator/tuscany/java/etc/listignores.rb
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/etc/listignores.rb?rev=666955&view=auto
==============================================================================
--- incubator/tuscany/java/etc/listignores.rb (added)
+++ incubator/tuscany/java/etc/listignores.rb Wed Jun 11 22:10:54 2008
@@ -0,0 +1,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 ingnored 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
+
+
+
+
+



Mime
View raw message