[macruby-changes] [2267] MacRuby/trunk/mspec/lib/mspec/runner
source_changes at macosforge.org
source_changes at macosforge.org
Sat Aug 8 17:02:59 PDT 2009
Revision: 2267
http://trac.macosforge.org/projects/ruby/changeset/2267
Author: mattaimonetti at gmail.com
Date: 2009-08-08 17:02:59 -0700 (Sat, 08 Aug 2009)
Log Message:
-----------
optimized the formatter to only scan the current file once and avoid global regexp variable conflicts
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 00:02:56 UTC (rev 2266)
+++ MacRuby/trunk/mspec/lib/mspec/runner/actions/macruby_stats.rb 2009-08-09 00:02:59 UTC (rev 2267)
@@ -6,39 +6,42 @@
@categories = {}
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]
end
# increases the amount of examples in the category
- def example!(path)
- increase_stats(path, :examples)
+ def example!(arborescence)
+ increase_stats(arborescence, :examples)
end
- def expectation!(path)
- increase_stats(path, :expectations)
+ def expectation!(arborescence)
+ increase_stats(arborescence, :expectations)
end
- def failure!(path)
- increase_stats(path, :failures)
+ def failure!(arborescence)
+ increase_stats(arborescence, :failures)
end
- def error!(path)
- increase_stats(path, :errors)
+ def error!(arborescence)
+ increase_stats(arborescence, :errors)
end
protected
def parse_path(path)
- path =~ /frozen\/(.+?)\/(.+)\/(.+_spec)\.rb/
- [$1, $2, $3]
+ # Ruby 1.9 only
+ /.*frozen\/(?<category>.+?)\/(?<subcategory>.+)\/(?<file>.+_spec)\.rb/ =~ path
+ [category, subcategory, file]
end
- def increase_stats(path, type)
- cat, subcat, specfile = parse_path(path)
+ def increase_stats(arborescence, type)
+ cat, subcat, specfile = arborescence
@categories[cat][subcat][type] += 1
end
@@ -47,6 +50,8 @@
class MacRubyStatsAction
+ attr_reader :current_arborescence
+
def initialize
@stats = MacRubySpecStats.new
end
@@ -66,20 +71,20 @@
end
def load
- @stats.push_file MSpec.retrieve(:file)
+ @current_arborescence = @stats.push_file(MSpec.retrieve(:file))
end
def example(state, block)
- @stats.example! MSpec.retrieve(:file)
+ @stats.example!(current_arborescence)
end
def expectation(state)
print "."
- @stats.expectation! MSpec.retrieve(:file)
+ @stats.expectation!(current_arborescence)
end
def exception(exception)
- exception.failure? ? @stats.failure!(MSpec.retrieve(:file)) : @stats.error!(MSpec.retrieve(:file))
+ exception.failure? ? @stats.failure!(current_arborescence) : @stats.error!(current_arborescence)
end
def categories
Modified: MacRuby/trunk/mspec/lib/mspec/runner/formatters/macruby.rb
===================================================================
--- MacRuby/trunk/mspec/lib/mspec/runner/formatters/macruby.rb 2009-08-09 00:02:56 UTC (rev 2266)
+++ MacRuby/trunk/mspec/lib/mspec/runner/formatters/macruby.rb 2009-08-09 00:02:59 UTC (rev 2267)
@@ -38,7 +38,16 @@
print " #{subcat}: #{stats[:failures]} failures, #{stats[:errors]} errors (#{stats[:examples]} examples, #{stats[:expectations]} expectations, #{stats[:files]} files) \n"
end
+ end
+
+ 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"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090808/e70f5546/attachment.html>
More information about the macruby-changes
mailing list