turn 0.9.4 → 0.9.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/History.txt CHANGED
@@ -1,3 +1,10 @@
1
+ == 0.9.5 / 2012-04-15
2
+ * Add -m/-mark option to flag tests with high runtimes.
3
+ * Show per-test runtime in Pretty reporter. (#83)
4
+ * Fix colorization of result box. (Don Wilson) (#81, #85)
5
+ * Add support for natural test names in pretty format. (Don Wilson) (#86)
6
+ * Fix test rake task on Windows. (Don Wilson) (#88)
7
+
1
8
  == 0.9.4 / 2012-03-16
2
9
  * Fix dot reporter to use `.` instead of `S` for passed tests.
3
10
  * Do not filter backtraces of local directory.
data/README.md CHANGED
@@ -88,7 +88,7 @@ For a Rails application, put the require line into the 'test/test_helper.rb'
88
88
  script. Now your Rails tests will use TURN formatting.
89
89
 
90
90
  <b>Note:</b> This changed in version 0.9. It used to be just `require 'turn'`,
91
- but becuase of how `bundle exec` works, it was better to require a subdirectory
91
+ but because of how `bundle exec` works, it was better to require a subdirectory
92
92
  file.
93
93
 
94
94
  ### Configuration
data/Version.txt CHANGED
@@ -1 +1 @@
1
- 0.9.4
1
+ 0.9.5
data/lib/turn/colorize.rb CHANGED
@@ -65,6 +65,10 @@ module Turn
65
65
  colorize? ? ::ANSI::Code.bold{ string } : string
66
66
  end
67
67
 
68
+ def self.mark(string)
69
+ colorize? ? ::ANSI::Code.yellow{ string } : string
70
+ end
71
+
68
72
  def self.pass(string)
69
73
  colorize? ? ::ANSI::Code.green{ string } : string
70
74
  end
data/lib/turn/command.rb CHANGED
@@ -76,6 +76,12 @@ module Turn
76
76
  # Use natural test case names.
77
77
  attr :natural
78
78
 
79
+ # Show extra information.
80
+ attr :verbose
81
+
82
+ # Show extra information.
83
+ attr :mark
84
+
79
85
  # Force ANSI use on or off.
80
86
  attr :ansi
81
87
 
@@ -91,6 +97,8 @@ module Turn
91
97
  @outmode = nil
92
98
  @trace = nil
93
99
  @natural = false
100
+ @verbose = false
101
+ @mark = nil
94
102
  @ansi = nil
95
103
  end
96
104
 
@@ -131,6 +139,10 @@ module Turn
131
139
  end
132
140
  end
133
141
 
142
+ opts.on('-m', '--mark=SECONDS', "Mark test if it exceeds runtime threshold.") do |int|
143
+ @mark = int.to_i
144
+ end
145
+
134
146
  opts.on('-b', '--backtrace', '--trace INT', "Limit the number of lines of backtrace.") do |int|
135
147
  @trace = int
136
148
  end
@@ -139,6 +151,10 @@ module Turn
139
151
  @natural = bool
140
152
  end
141
153
 
154
+ opts.on('-v', '--verbose', "Show extra information.") do |bool|
155
+ @verbose = bool
156
+ end
157
+
142
158
  opts.on('--[no-]ansi', "Force use of ANSI codes on or off.") do |bool|
143
159
  @ansi = bool
144
160
  end
@@ -218,7 +234,7 @@ module Turn
218
234
  exit
219
235
  end
220
236
 
221
- opts.on_tail('--help', '-h', "display this help information") do
237
+ opts.on_tail('-h', '--help', "display this help information") do
222
238
  puts opts
223
239
  exit
224
240
  end
@@ -246,6 +262,8 @@ module Turn
246
262
  c.matchcase = matchcase
247
263
  c.trace = trace
248
264
  c.natural = natural
265
+ c.verbose = verbose
266
+ c.mark = mark
249
267
  c.ansi = ansi unless ansi.nil?
250
268
  end
251
269
 
@@ -48,7 +48,11 @@ module Turn
48
48
  # Verbose output?
49
49
  attr_accessor :verbose
50
50
 
51
- # Test framework, either :minitest or :testunit
51
+ # Runtime threshold.
52
+ attr_accessor :mark
53
+
54
+ # Test framework, either `:minitest` or `:testunit`.
55
+ # @todo Is this used any more?
52
56
  attr_accessor :framework
53
57
 
54
58
  # Enable full backtrace
@@ -93,6 +97,7 @@ module Turn
93
97
  @matchcase ||= nil
94
98
  @pattern ||= /.*/
95
99
  @natural ||= false
100
+ @verbose ||= false
96
101
  @format ||= environment_format
97
102
  @trace ||= environment_trace
98
103
  @ansi ||= environment_ansi
@@ -175,7 +180,7 @@ module Turn
175
180
  # Select reporter based on output mode.
176
181
  def reporter
177
182
  @reporter ||= (
178
- opts = { :trace=>trace, :natural=>natural? }
183
+ opts = reporter_options
179
184
  case format
180
185
  when :marshal
181
186
  require 'turn/reporters/marshal_reporter'
@@ -202,6 +207,11 @@ module Turn
202
207
  )
203
208
  end
204
209
 
210
+ #
211
+ def reporter_options
212
+ { :trace=>trace, :natural=>natural?, :verbose=>verbose?, :mark=>mark }
213
+ end
214
+
205
215
  #
206
216
  def environment_format
207
217
  ENV['rpt']
data/lib/turn/reporter.rb CHANGED
@@ -21,6 +21,8 @@ module Turn
21
21
  @io = io || $stdout
22
22
  @trace = opts[:trace]
23
23
  @natural = opts[:natural]
24
+ @verbose = opts[:verbose]
25
+ @mark = opts[:mark].to_i
24
26
  end
25
27
 
26
28
  # These methods are called in the process of running the tests.
@@ -105,12 +107,12 @@ module Turn
105
107
  @trace ? backtrace[0, @trace.to_i] : backtrace
106
108
  end
107
109
 
108
- #
110
+ # Returns a more readable test name with spaces instead of underscores
109
111
  def naturalized_name(test)
110
112
  if @natural
111
- " #{test.name.gsub("test_", "").gsub(/_/, " ")}"
113
+ test.name.gsub("test_", "").gsub(/_/, " ")
112
114
  else
113
- " #{test.name}"
115
+ test.name
114
116
  end
115
117
  end
116
118
 
@@ -27,7 +27,8 @@ module Turn
27
27
  # @file = test.file
28
28
  # io.puts(test.file)
29
29
  #end
30
- io.print Colorize.blue(" %-69s" % test.name)
30
+ name = naturalized_name(test)
31
+ io.print Colorize.blue(" %-69s" % name)
31
32
  $stdout = @stdout
32
33
  $stderr = @stderr
33
34
  $stdout.rewind
@@ -49,7 +49,7 @@ module Turn
49
49
  # @FIXME: Should we move naturalized_name to test itself?
50
50
  name = naturalized_name(test)
51
51
 
52
- io.print " %-57s" % name
52
+ io.print " %-57s" % name
53
53
 
54
54
  @stdout.rewind
55
55
  @stderr.rewind
@@ -165,11 +165,7 @@ module Turn
165
165
  skips = suite.count_skips
166
166
 
167
167
  bar = '=' * 78
168
- # @FIXME: Remove this, since Colorize already take care of colorize?
169
- if colorize?
170
- bar = if pass == total then Colorize.green(bar)
171
- else Colorize.red(bar) end
172
- end
168
+ bar = passes == total ? Colorize.green(bar) : Colorize.red(bar)
173
169
 
174
170
  # @FIXME: Should we add suite.runtime, instead if this lame time calculations?
175
171
  tally = [total, assertions, (Time.new - @time)]
@@ -182,4 +178,4 @@ module Turn
182
178
 
183
179
  end
184
180
 
185
- end
181
+ end
@@ -62,21 +62,21 @@ module Turn
62
62
  def fail(assertion, message=nil)
63
63
  banner FAIL
64
64
 
65
- prettify(message, assertion)
65
+ prettify(assertion, message)
66
66
  end
67
67
 
68
68
  # Invoked when a test raises an exception.
69
69
  def error(exception, message=nil)
70
70
  banner ERROR
71
71
 
72
- prettify(message, exception)
72
+ prettify(exception, message)
73
73
  end
74
74
 
75
75
  # Invoked when a test is skipped.
76
76
  def skip(exception, message=nil)
77
77
  banner SKIP
78
78
 
79
- prettify(message, exception)
79
+ prettify(exception, message)
80
80
  end
81
81
 
82
82
  # Invoked after all tests in a testcase have ben run.
@@ -117,12 +117,25 @@ module Turn
117
117
  str
118
118
  end
119
119
 
120
+ # TODO: Could also provide % done with time info. But it's already taking up
121
+ # a lot of screen realestate. Maybe use --verbose flag to offer two forms.
122
+
120
123
  # Outputs test case header for given event (error, fail & etc)
121
124
  #
122
125
  # Example:
123
- # PASS test: Test decription. (0:00:02:059)
126
+ # PASS test: Test decription. (0.15s 0:00:02:059)
124
127
  def banner(event)
125
- io.puts "%18s %s (%s)" % [event, @test, ticktock]
128
+ name = naturalized_name(@test)
129
+ delta = Time.now - @test_time # test runtime
130
+ if @verbose
131
+ out = "%18s (%0.5fs) (%s) %s" % [event, delta, ticktock, name]
132
+ else
133
+ out = "%18s (%s) %s" % [event, ticktock, name]
134
+ end
135
+ if @mark > 0 && delta > @mark
136
+ out[1] = Colorize.mark('*')
137
+ end
138
+ io.puts out
126
139
  end
127
140
 
128
141
  # Cleanups and prints test payload
@@ -131,7 +144,7 @@ module Turn
131
144
  # fail is not 1
132
145
  # @ test/test_runners.rb:46:in `test_autorun_with_trace'
133
146
  # bin/turn:4:in `<main>'
134
- def prettify(message=nil, raised)
147
+ def prettify(raised, message=nil)
135
148
  # Get message from raised, if not given
136
149
  message ||= raised.message
137
150
 
@@ -1,6 +1,6 @@
1
1
  require 'stringio'
2
2
 
3
- # Becuase of some wierdness in MiniTest
3
+ # Because of some wierdness in MiniTest
4
4
  #debug, $DEBUG = $DEBUG, false
5
5
  #require 'minitest/unit'
6
6
  #$DEBUG = debug
data/lib/turn/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Turn
2
- VERSION = "0.9.4"
2
+ VERSION = "0.9.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: turn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.4
4
+ version: 0.9.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-03-16 00:00:00.000000000 Z
13
+ date: 2012-04-16 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: ansi
17
- requirement: &21312540 !ruby/object:Gem::Requirement
17
+ requirement: &13272920 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: '0'
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *21312540
25
+ version_requirements: *13272920
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: minitest
28
- requirement: &21308780 !ruby/object:Gem::Requirement
28
+ requirement: &13268840 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
- version_requirements: *21308780
36
+ version_requirements: *13268840
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: rake
39
- requirement: &21307780 !ruby/object:Gem::Requirement
39
+ requirement: &13301200 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ! '>='
@@ -44,7 +44,7 @@ dependencies:
44
44
  version: '0'
45
45
  type: :development
46
46
  prerelease: false
47
- version_requirements: *21307780
47
+ version_requirements: *13301200
48
48
  description: Turn provides a set of alternative runners for MiniTest, both colorful
49
49
  and informative.
50
50
  email: