Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #2 from tmornini/master

Context squashing FTW!
  • Loading branch information...
commit 5a757468826c30d3103dfe12d30756243037054d 2 parents 291ce92 + 50dc631
Tom Mornini authored
Showing with 37 additions and 25 deletions.
  1. +37 −25 lib/turn/reporters/snuggs_reporter.rb
View
62 lib/turn/reporters/snuggs_reporter.rb
@@ -16,6 +16,8 @@ def start_suite suite
@suite = suite
@time = Time.now
+ @squasher = {}
+
# @FIXME (y8): Why we need to capture stdout and stderr?
@stdout = StringIO.new
@@ -24,33 +26,41 @@ def start_suite suite
#files = suite.collect{ |s| s.file }.join(' ')
io.puts '=' * 78
+ end
- if suite.seed
- io.puts "MorSnuggs #{suite.name} (SEED #{suite.seed})"
- else
- io.puts "MorSnuggs #{suite.name}"
- end
+ def indent
+ ' ' * ( @contexts.length - 1 )
+ end
- io.puts '=' * 78
+ def hash
@snuggs
snuggs added a note

Can you provide an example of hash? Seems like the reporter and each context needs a hash.

The idea is that each set of contexts creates a hash in the form of hash_of_first:hash_of_second, etc.

That way we know if we've already seen the same set of contexts each time and can simply skip the output for those that we have.

Hopefully that explains all. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ @contexts.collect { |c| c.hash }.join(':')
end
- def start_case kase
- @indentation = ""
+ def squash
+ @squasher[hash] = true
+ end
- formatted_kase_name = kase.name.split('::').inject("") do |result, desc|
- result += "\n#{ @indentation + desc }"
- @indentation += TAB
- result
- end
+ def squashed
+ @squasher[hash]
+ end
- io.puts( formatted_kase_name.bold ) if kase.size > 0
+ def start_case kase
+ @contexts = []
+
+ kase.name.split('::').each do |context|
+ @contexts << context
+ unless squashed
+ squash
+ io.puts indent + context
+ end
+ end
end
def start_test test
# @FIXME: Should we move naturalized_name to test itself?
- name = naturalized_name(test).gsub(/^\s\d+/, @indentation)
+ @contexts << naturalized_name(test).gsub(/^\s\d+/, '')
- io.print "%-57s" % name
+ io.print "%-74s" % ( indent + @contexts.last )
@stdout.rewind
@stderr.rewind
@@ -60,7 +70,8 @@ def start_test test
end
def pass message=nil
- io.puts " %s %s" % [ticktock, PASS]
+ io.puts '%s' % PASS
+ io.puts
if message
message = message.magenta
@@ -149,17 +160,18 @@ def finish_suite(suite)
errors = suite.count_errors
skips = suite.count_skips
- bar = '=' * 78
+ passed = passes == total
- bar = pass == total ? bar.green : bar.red
+ bar = '=' * 78
- # @FIXME: Should we add suite.runtime, instead if this lame time calculations?
- tally = [total, assertions, (Time.new - @time)]
+ bottom = [bar]
+ bottom << " pass: %d, fail: %d, error: %d, skip: %d" % [passes, failures, errors, skips]
+ bottom << " total: %d tests with %d assertions in %f seconds" % [total, assertions, (Time.new - @time)]
+ bottom << bar
- io.puts bar
- io.puts " pass: %d, fail: %d, error: %d, skip: %d" % [passes, failures, errors, skips]
- io.puts " total: %d tests with %d assertions in %f seconds" % tally
- io.puts bar
+ bottom.each do |line|
+ io.puts passed ? line.green : line.red
+ end
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.