Permalink
Browse files

Add verbose and runtime mark options.

  • Loading branch information...
trans committed Apr 15, 2012
1 parent c778653 commit 2d756ca3e11c91f22451e93f65a94c9f55fcbfd5
Showing with 47 additions and 5 deletions.
  1. +4 −0 lib/turn/colorize.rb
  2. +19 −1 lib/turn/command.rb
  3. +12 −2 lib/turn/configuration.rb
  4. +2 −0 lib/turn/reporter.rb
  5. +10 −2 lib/turn/reporters/pretty_reporter.rb
View
@@ -65,6 +65,10 @@ def self.bold(string)
colorize? ? ::ANSI::Code.bold{ string } : string
end
+ def self.mark(string)
+ colorize? ? ::ANSI::Code.yellow{ string } : string
+ end
+
def self.pass(string)
colorize? ? ::ANSI::Code.green{ string } : string
end
View
@@ -76,6 +76,12 @@ def self.main(*argv)
# Use natural test case names.
attr :natural
+ # Show extra information.
+ attr :verbose
+
+ # Show extra information.
+ attr :mark
+
# Force ANSI use on or off.
attr :ansi
@@ -91,6 +97,8 @@ def initialize
@outmode = nil
@trace = nil
@natural = false
+ @verbose = false
+ @mark = nil
@ansi = nil
end
@@ -131,6 +139,10 @@ def option_parser
end
end
+ opts.on('-m', '--mark=SECONDS', "Mark test if it exceeds runtime threshold.") do |int|
+ @mark = int.to_i
+ end
+
opts.on('-b', '--backtrace', '--trace INT', "Limit the number of lines of backtrace.") do |int|
@trace = int
end
@@ -139,6 +151,10 @@ def option_parser
@natural = bool
end
+ opts.on('-v', '--verbose', "Show extra information.") do |bool|
+ @verbose = bool
+ end
+
opts.on('--[no-]ansi', "Force use of ANSI codes on or off.") do |bool|
@ansi = bool
end
@@ -218,7 +234,7 @@ def option_parser
exit
end
- opts.on_tail('--help', '-h', "display this help information") do
+ opts.on_tail('-h', '--help', "display this help information") do
puts opts
exit
end
@@ -246,6 +262,8 @@ def main(*argv)
c.matchcase = matchcase
c.trace = trace
c.natural = natural
+ c.verbose = verbose
+ c.mark = mark
c.ansi = ansi unless ansi.nil?
end
View
@@ -48,7 +48,11 @@ class Configuration
# Verbose output?
attr_accessor :verbose
- # Test framework, either :minitest or :testunit
+ # Runtime threshold.
+ attr_accessor :mark
+
+ # Test framework, either `:minitest` or `:testunit`.
+ # @todo Is this used any more?
attr_accessor :framework
# Enable full backtrace
@@ -93,6 +97,7 @@ def initialize_defaults
@matchcase ||= nil
@pattern ||= /.*/
@natural ||= false
+ @verbose ||= false
@format ||= environment_format
@trace ||= environment_trace
@ansi ||= environment_ansi
@@ -175,7 +180,7 @@ def suite_name
# Select reporter based on output mode.
def reporter
@reporter ||= (
- opts = { :trace=>trace, :natural=>natural? }
+ opts = reporter_options
case format
when :marshal
require 'turn/reporters/marshal_reporter'
@@ -202,6 +207,11 @@ def reporter
)
end
+ #
+ def reporter_options
+ { :trace=>trace, :natural=>natural?, :verbose=>verbose?, :mark=>mark }
+ end
+
#
def environment_format
ENV['rpt']
View
@@ -21,6 +21,8 @@ def initialize(io, opts={})
@io = io || $stdout
@trace = opts[:trace]
@natural = opts[:natural]
+ @verbose = opts[:verbose]
+ @mark = opts[:mark].to_i
end
# These methods are called in the process of running the tests.
@@ -126,8 +126,16 @@ def colorize_count(str, count, colorize_method)
# PASS test: Test decription. (0.15s 0:00:02:059)
def banner(event)
name = naturalized_name(@test)
- delta = Time.now - @test_time # Test runtime
- io.puts "%18s (%s %0.3fs) %s" % [event, ticktock, delta, name]
+ delta = Time.now - @test_time # test runtime
+ if @verbose
+ out = "%18s (%0.5fs) [%s] %s" % [event, delta, ticktock, name]
+ else
+ out = "%18s [%s] %s" % [event, ticktock, name]
+ end
+ if @mark > 0 && delta > @mark
+ out[1] = Colorize.mark('*')
+ end
+ io.puts out
end
# Cleanups and prints test payload

0 comments on commit 2d756ca

Please sign in to comment.