[macruby-changes] [2270] MacRuby/trunk/mspec/lib/mspec/runner
source_changes at macosforge.org
source_changes at macosforge.org
Sun Aug 9 19:32:31 PDT 2009
Revision: 2270
http://trac.macosforge.org/projects/ruby/changeset/2270
Author: mattaimonetti at gmail.com
Date: 2009-08-09 19:32:29 -0700 (Sun, 09 Aug 2009)
Log Message:
-----------
modified stats to look the way lrz want them
Modified Paths:
--------------
MacRuby/trunk/mspec/lib/mspec/runner/actions/macruby_stats.rb
MacRuby/trunk/mspec/lib/mspec/runner/formatters/macruby.rb
Modified: MacRuby/trunk/mspec/lib/mspec/runner/actions/macruby_stats.rb
===================================================================
--- MacRuby/trunk/mspec/lib/mspec/runner/actions/macruby_stats.rb 2009-08-09 22:15:34 UTC (rev 2269)
+++ MacRuby/trunk/mspec/lib/mspec/runner/actions/macruby_stats.rb 2009-08-10 02:32:29 UTC (rev 2270)
@@ -1,48 +1,51 @@
class MacRubySpecStats
attr_accessor :categories
- attr_reader :category, :subcategory, :file
+ attr_reader :category, :subcategory, :file, :tag_files
def initialize
@categories = {}
+ @tag_files = []
end
# return the current arborescence
def push_file(path)
- cat, subcat, specfile = parse_path(path)
- @categories[cat] ||= {}
- @categories[cat][subcat] ||= {:files => 0, :examples => 0, :expectations => 0, :failures => 0, :errors => 0}
- @categories[cat][subcat][:files] += 1
- [cat, subcat, specfile]
+ category = parse_path(path)
+ @categories[category] ||= {:files => 0, :examples => 0, :expectations => 0, :failures => 0, :errors => 0, :skipped => 0}
+ @categories[category][:files] += 1
+ category
end
+ def push_skipped(category, amount)
+ increase_stats(category, :skipped, amount)
+ end
+
# increases the amount of examples in the category
- def example!(arborescence)
- increase_stats(arborescence, :examples)
+ def example!(category)
+ increase_stats(category, :examples)
end
- def expectation!(arborescence)
- increase_stats(arborescence, :expectations)
+ def expectation!(category)
+ increase_stats(category, :expectations)
end
- def failure!(arborescence)
- increase_stats(arborescence, :failures)
+ def failure!(category)
+ increase_stats(category, :failures)
end
- def error!(arborescence)
- increase_stats(arborescence, :errors)
+ def error!(category)
+ increase_stats(category, :errors)
end
protected
+ # Return the spec category
def parse_path(path)
- # Ruby 1.9 only
- /.*frozen\/(?<category>.+?)\/(?<subcategory>.+)\/(?<file>.+_spec)\.rb/ =~ path
- [category, subcategory, file]
+ /spec\/(frozen|macruby)\/(.+?)\// =~ path
+ $2
end
- def increase_stats(arborescence, type)
- cat, subcat, specfile = arborescence
- @categories[cat][subcat][type] += 1
+ def increase_stats(category, type, amount=1)
+ @categories[category][type] += amount
end
end
@@ -50,45 +53,51 @@
class MacRubyStatsAction
- attr_reader :current_arborescence
+ attr_reader :current_category
def initialize
@stats = MacRubySpecStats.new
end
-
+
def register
MSpec.register :load, self
MSpec.register :exception, self
MSpec.register :example, self
- MSpec.register :expectation, self
+ MSpec.register :expectation, self
end
def unregister
MSpec.unregister :load, self
MSpec.unregister :exception, self
MSpec.unregister :example, self
- MSpec.unregister :expectation, self
+ MSpec.unregister :expectation, self
end
def load
- @current_arborescence = @stats.push_file(MSpec.retrieve(:file))
+ @current_category = @stats.push_file(MSpec.retrieve(:file))
+ skilled_specs = MSpec.read_tags(['critical', 'fails']).size
+ @stats.push_skipped(current_category, skilled_specs) if skilled_specs > 0
end
def example(state, block)
- @stats.example!(current_arborescence)
+ @stats.example!(current_category)
end
def expectation(state)
print "."
- @stats.expectation!(current_arborescence)
+ @stats.expectation!(current_category)
end
def exception(exception)
- exception.failure? ? @stats.failure!(current_arborescence) : @stats.error!(current_arborescence)
+ exception.failure? ? @stats.failure!(current_category) : @stats.error!(current_category)
end
def categories
@stats.categories
end
+ def tags
+ @stats.tag_files
+ end
+
end
\ No newline at end of file
Modified: MacRuby/trunk/mspec/lib/mspec/runner/formatters/macruby.rb
===================================================================
--- MacRuby/trunk/mspec/lib/mspec/runner/formatters/macruby.rb 2009-08-09 22:15:34 UTC (rev 2269)
+++ MacRuby/trunk/mspec/lib/mspec/runner/formatters/macruby.rb 2009-08-10 02:32:29 UTC (rev 2270)
@@ -32,27 +32,26 @@
switch
print "\n"
- @stats.categories.each do |category, subcategories|
- print "#{category}:\n"
- subcategories.each do |subcat, stats|
- print " #{subcat}: #{stats[:failures]} failures, #{stats[:errors]} errors (#{stats[:examples]} examples, #{stats[:expectations]} expectations, #{stats[:files]} files) \n"
-
- end
+ @stats.categories.each do |key, details|
+ print "#{key}:\n"
+ print " -> #{details[:failures]} failures, #{details[:errors]} errors (#{details[:expectations]} expectations, #{details[:examples]} examples, #{details[:skipped]} examples skipped, #{details[:files]} files) \n"
end
+ print "\nSummary:\n"
+ print "files: ", @tally.counter.files, "\n"
+ print "examples: ", @tally.counter.examples, "\n"
+ print "skipped examples: ", @stats.categories.inject(0){|sum, cat| sum += cat[:skipped]}, "\n"
+ print "expectations: ", @tally.counter.expectations, "\n"
+ print "failures: ", @tally.counter.failures, "\n"
+ print "errors: ", @tally.counter.errors, "\n"
+
+ print "\nExceptions:\n"
count = 0
@exceptions.each do |exc|
outcome = exc.failure? ? "FAILED" : "ERROR"
print "\n#{count += 1})\n#{exc.description} #{outcome}\n"
print exc.message, "\n"
print exc.backtrace, "\n"
- end
-
- print "\nSummary:\n"
- print "files: ", @tally.counter.files, "\n"
- print "examples: ", @tally.counter.examples, "\n"
- print "expectations: ", @tally.counter.expectations, "\n"
- print "failures: ", @tally.counter.failures, "\n"
- print "errors: ", @tally.counter.errors, "\n"
+ end
end
end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090809/541669d3/attachment-0001.html>
More information about the macruby-changes
mailing list