Skip to content

Commit

Permalink
Fixed outline_reporter to use 'trace' option.
Browse files Browse the repository at this point in the history
  • Loading branch information
yalab committed May 24, 2011
1 parent 442e66c commit 00b391c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
10 changes: 10 additions & 0 deletions lib/turn/command.rb
Expand Up @@ -16,6 +16,7 @@ module Turn
# -I --loadpath=PATHS add given PATHS to the $LOAD_PATH
# -r --requires=LIBS require given LIBS before running tests
# -m --minitest Force use of MiniTest framework.
# -t --trace Turn on invoke/execute tracing, enable full backtrace.
#
# RUN MODES
# --normal run all tests in a single process [default]
Expand Down Expand Up @@ -64,6 +65,9 @@ def self.main(*argv)
# Output mode.
attr :outmode

# Enable full backtrace
attr :trace

#
def initialize
@live = nil
Expand All @@ -75,6 +79,7 @@ def initialize
@runmode = nil
@outmode = nil
@framework = RUBY_VERSION >= "1.9" ? :minitest : :testunit
@trace = nil
end

#
Expand Down Expand Up @@ -118,6 +123,10 @@ def option_parser
@framework = :minitest
end

opts.on("-t", '--trace', "Turn on invoke/execute tracing, enable full backtrace") do
@trace = true
end

# Turn does not support Test::Unit 2.0+
#opts.on('-u', '--testunit', "Force use of TestUnit framework") do
# @framework = :testunit
Expand Down Expand Up @@ -216,6 +225,7 @@ def main(*argv)
c.pattern = pattern
c.matchcase = matchcase
c.framework = framework
c.trace = trace
end

result = controller.start
Expand Down
5 changes: 4 additions & 1 deletion lib/turn/controller.rb
Expand Up @@ -51,6 +51,9 @@ class Controller
# Test framework, either :minitest or :testunit
attr_accessor :framework

# Enable full backtrace
attr_accessor :trace

def verbose? ; @verbose ; end
def live? ; @live ; end

Expand Down Expand Up @@ -171,7 +174,7 @@ def reporter
Turn::CueReporter.new($stdout)
else
require 'turn/reporters/outline_reporter'
Turn::OutlineReporter.new($stdout)
Turn::OutlineReporter.new($stdout, :trace => @trace)
end
)
end
Expand Down
3 changes: 2 additions & 1 deletion lib/turn/reporter.rb
Expand Up @@ -18,8 +18,9 @@ class Reporter

attr :io

def initialize(io)
def initialize(io, opts={})
@io = io || $stdout
@trace = opts[:trace]
end

# These methods are called in the process of running the tests.
Expand Down
12 changes: 9 additions & 3 deletions lib/turn/reporters/outline_reporter.rb
Expand Up @@ -60,9 +60,15 @@ def fail(assertion)
io.puts(" #{FAIL}")
io.puts Colorize.bold(message).tabto(8)
unless backtrace.empty?
backtrace = "Assertion at " + filter_backtrace(assertion.backtrace).first
io.puts "STDERR:".tabto(8)
io.puts(backtrace.tabto(8))
_backtrace = filter_backtrace(assertion.backtrace)
_backtrace << "error hogehoge"
label = "Assertion at "
tabsize = 8
backtrace = label + _backtrace.shift
io.puts(backtrace.tabto(tabsize))
if @trace
io.puts _backtrace.map{|l| l.tabto(label.length + tabsize) }.join("\n")
end
end
show_captured_output
end
Expand Down

0 comments on commit 00b391c

Please sign in to comment.