turn 0.9.2 → 0.9.3
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +8 -0
- data/README.md +38 -25
- data/Version.txt +1 -1
- data/bin/turn +1 -1
- data/lib/turn.rb +1 -0
- data/lib/turn/bin.rb +1 -1
- data/lib/turn/command.rb +6 -4
- data/lib/turn/components/case.rb +6 -1
- data/lib/turn/components/suite.rb +6 -3
- data/lib/turn/configuration.rb +14 -6
- data/lib/turn/reporter.rb +5 -5
- data/lib/turn/reporters/cue_reporter.rb +11 -7
- data/lib/turn/reporters/dot_reporter.rb +15 -24
- data/lib/turn/reporters/outline_reporter.rb +18 -10
- data/lib/turn/reporters/pretty_reporter.rb +89 -147
- data/lib/turn/reporters/progress_reporter.rb +9 -10
- data/lib/turn/runners/isorunner.rb +2 -1
- data/lib/turn/version.rb +1 -1
- data/test/test_runners.rb +12 -12
- data/try/test_autorun_minitest.rb +1 -2
- data/try/test_autorun_testunit.rb +1 -2
- metadata +8 -8
data/History.txt
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
== 0.9.3 / 2012-02-09
|
2
|
+
* Default to pretty reporter.
|
3
|
+
* Can set reporter via `rpt` environment variable.
|
4
|
+
* Fix backtrace filter.
|
5
|
+
* Fix require warning when using cli.
|
6
|
+
* Add skip counts to reporter tallies. (t8)
|
7
|
+
* Improve Pretty reporter output. (t8)
|
8
|
+
|
1
9
|
== 0.9.2 / 2012-02-08
|
2
10
|
* Fix colorization config issue.
|
3
11
|
* Switch to simple dotruby build system.
|
data/README.md
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
by Tim Pease
|
3
3
|
http://codeforpeople.rubyforge.org/turn
|
4
4
|
|
5
|
+
|
5
6
|
## DESCRIPTION:
|
6
7
|
|
7
8
|
TURN is a new way to view test results. With longer running tests, it
|
@@ -9,12 +10,13 @@ can be very frustrating to see a failure (....F...) and then have to wait till
|
|
9
10
|
all the tests finish before you can see what the exact failure was. TURN
|
10
11
|
displays each test on a separate line with failures being displayed
|
11
12
|
immediately instead of at the end of the tests.
|
12
|
-
|
13
|
+
|
13
14
|
If you have the 'ansi' gem installed, then TURN output will be displayed in
|
14
15
|
wonderful technicolor (but only if your terminal supports ANSI color codes).
|
15
16
|
Well, the only colors are green and red, but that is still color.
|
16
17
|
|
17
|
-
<b>Interested in improving Turn?</b> Please read this
|
18
|
+
<b>Interested in improving Turn?</b> [Please read this](https://github.com/TwP/turn/wiki/Implementation).
|
19
|
+
|
18
20
|
|
19
21
|
## FEATURES:
|
20
22
|
|
@@ -42,7 +44,7 @@ General usage provides better test output. Here is some sample output:
|
|
42
44
|
Turn also provides solo and cross test modes when run from the *turn* commandline
|
43
45
|
application.
|
44
46
|
|
45
|
-
##
|
47
|
+
## INSTRUCTION:
|
46
48
|
|
47
49
|
Turn can be using from the command-line or via require. The command-line tool
|
48
50
|
offers additional options for how one runs tests.
|
@@ -72,12 +74,12 @@ This will run every pairing of tests in a separate process.
|
|
72
74
|
|
73
75
|
Simply require the TURN package from within your test suite.
|
74
76
|
|
75
|
-
$ require 'turn'
|
77
|
+
$ require 'turn/autorun'
|
76
78
|
|
77
79
|
This will configure MiniTest to use TURN formatting for displaying test
|
78
|
-
|
80
|
+
results. A better line to use, though, is the following:
|
79
81
|
|
80
|
-
begin; require 'turn'; rescue LoadError; end
|
82
|
+
begin; require 'turn/autorun'; rescue LoadError; end
|
81
83
|
|
82
84
|
When you distribute your code, the test suite can be run without requiring
|
83
85
|
the end user to install the TURN package.
|
@@ -85,39 +87,50 @@ the end user to install the TURN package.
|
|
85
87
|
For a Rails application, put the require line into the 'test/test_helper.rb'
|
86
88
|
script. Now your Rails tests will use TURN formatting.
|
87
89
|
|
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
|
92
|
+
file.
|
93
|
+
|
94
|
+
### Configuration
|
88
95
|
|
89
|
-
|
96
|
+
You can use `Turn.config` to adjust turn configuration.
|
90
97
|
|
91
|
-
|
92
|
-
when using `bundle exec`. This means `turn` will get automatically
|
93
|
-
required too, which in turn means the Turn's test autorunner is doing
|
94
|
-
to kick in. Obviously we don't want that to happen unless we are actually
|
95
|
-
running tests.
|
98
|
+
Options are following:
|
96
99
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
100
|
+
tests List of file names or glob patterns of tests to run. Default: ["test/**/{test,}*{,test}.rb"]
|
101
|
+
exclude List of file names or globs to exclude from tests list. Default: []
|
102
|
+
pattern Regexp pattern that all test names must match to be eligible to run. Default: /.*/ (all)
|
103
|
+
matchcase Regexp pattern that all test cases must match to be eligible to run. Default: nil (all)
|
104
|
+
loadpath Add these folders to the $LOAD_PATH. Default: ['lib']
|
105
|
+
requires Libs to require when running tests. Default: []
|
106
|
+
format Reporter type (:pretty, :dot, :cue, :marshal, :outline, :progress). Default: :pretty
|
107
|
+
live Test against live install (i.e. Don't use loadpath option). Default: false
|
108
|
+
verbose Verbose output? Default: false
|
109
|
+
trace Number of backtrace lines to display. Default: set from ENV or nil (all)
|
110
|
+
natural Use natural language case names. Default: false
|
111
|
+
ansi Force colorized output (requires 'ansi' gem). Default: set from ENV or nil (auto)
|
101
112
|
|
102
|
-
|
113
|
+
To set option just call the desired method:
|
103
114
|
|
104
|
-
|
115
|
+
Turn.config.format = :progress
|
105
116
|
|
106
|
-
|
117
|
+
Also, you can use following environment variables to adjust settings:
|
107
118
|
|
108
|
-
|
109
|
-
|
110
|
-
something to do lightly. Full change over will wait until the 1.0 release.
|
111
|
-
In the mean time Turn will just put out a warning.
|
119
|
+
backtrace Number of backtrace lines to display. Default: set from ENV or nil
|
120
|
+
ansi Force colorize output (requires 'ansi' gem).
|
112
121
|
|
113
122
|
|
114
123
|
## REQUIREMENTS:
|
115
124
|
|
116
125
|
* ansi 1.1+ (for colorized output and progress bar output mode)
|
117
126
|
|
118
|
-
## INSTALL:
|
119
127
|
|
120
|
-
|
128
|
+
## INSTALLATION:
|
129
|
+
|
130
|
+
Follow the ususal procedure:
|
131
|
+
|
132
|
+
$ sudo gem install turn
|
133
|
+
|
121
134
|
|
122
135
|
## LICENSE:
|
123
136
|
|
data/Version.txt
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.9.
|
1
|
+
0.9.3
|
data/bin/turn
CHANGED
data/lib/turn.rb
CHANGED
data/lib/turn/bin.rb
CHANGED
data/lib/turn/command.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'optparse'
|
2
|
-
require 'turn'
|
3
2
|
|
4
3
|
module Turn
|
5
4
|
|
@@ -207,10 +206,13 @@ module Turn
|
|
207
206
|
opts.separator "COMMAND OPTIONS"
|
208
207
|
|
209
208
|
opts.on('--debug', "turn debug mode on") do
|
210
|
-
$VERBOSE = true
|
211
209
|
$DEBUG = true
|
212
210
|
end
|
213
211
|
|
212
|
+
opts.on('--warn', "turn warnings on") do
|
213
|
+
$VERBOSE = true
|
214
|
+
end
|
215
|
+
|
214
216
|
opts.on_tail('--version', "display version") do
|
215
217
|
puts VERSION
|
216
218
|
exit
|
@@ -252,9 +254,9 @@ module Turn
|
|
252
254
|
result = controller.start
|
253
255
|
|
254
256
|
if result
|
255
|
-
exit result.passed?
|
257
|
+
exit (result.passed? ? 0 : -1)
|
256
258
|
else # no tests
|
257
|
-
exit
|
259
|
+
exit -1
|
258
260
|
end
|
259
261
|
end
|
260
262
|
|
data/lib/turn/components/case.rb
CHANGED
@@ -86,9 +86,14 @@ module Turn
|
|
86
86
|
sum = 0; tests.each{ |t| sum += 1 if t.pass? }; sum
|
87
87
|
end
|
88
88
|
|
89
|
+
def count_skips
|
90
|
+
# Why not use tests.select(&:skip?).size ?
|
91
|
+
sum = 0; tests.each{ |t| sum += 1 if t.skip? }; sum
|
92
|
+
end
|
93
|
+
|
89
94
|
#
|
90
95
|
def counts
|
91
|
-
return count_tests, count_assertions, count_failures, count_errors
|
96
|
+
return count_tests, count_assertions, count_failures, count_errors, count_skips
|
92
97
|
end
|
93
98
|
|
94
99
|
def message
|
@@ -64,9 +64,13 @@ module Turn
|
|
64
64
|
#)
|
65
65
|
end
|
66
66
|
|
67
|
+
def count_skips
|
68
|
+
sum = 0; each{ |c| sum += c.count_skips }; sum
|
69
|
+
end
|
70
|
+
|
67
71
|
# Convenience methods --this is what is typcially wanted.
|
68
72
|
def counts
|
69
|
-
return count_tests, count_assertions, count_failures, count_errors
|
73
|
+
return count_tests, count_assertions, count_failures, count_errors ,count_skips
|
70
74
|
end
|
71
75
|
|
72
76
|
def each(&block)
|
@@ -87,5 +91,4 @@ module Turn
|
|
87
91
|
end
|
88
92
|
end
|
89
93
|
|
90
|
-
end
|
91
|
-
|
94
|
+
end
|
data/lib/turn/configuration.rb
CHANGED
@@ -89,11 +89,11 @@ module Turn
|
|
89
89
|
@requires ||= []
|
90
90
|
@live ||= false
|
91
91
|
@log ||= true
|
92
|
-
#@format ||= nil
|
93
92
|
#@runner ||= RUBY_VERSION >= "1.9" ? MiniRunner : TestRunner
|
94
93
|
@matchcase ||= nil
|
95
94
|
@pattern ||= /.*/
|
96
95
|
@natural ||= false
|
96
|
+
@format ||= environment_format
|
97
97
|
@trace ||= environment_trace
|
98
98
|
@ansi ||= environment_ansi
|
99
99
|
|
@@ -186,19 +186,27 @@ module Turn
|
|
186
186
|
when :dotted, :dot
|
187
187
|
require 'turn/reporters/dot_reporter'
|
188
188
|
Turn::DotReporter.new($stdout, opts)
|
189
|
-
when :
|
190
|
-
require 'turn/reporters/
|
191
|
-
Turn::
|
189
|
+
when :outline
|
190
|
+
require 'turn/reporters/outline_reporter'
|
191
|
+
Turn::OutlineReporter.new($stdout, opts)
|
192
192
|
when :cue
|
193
193
|
require 'turn/reporters/cue_reporter'
|
194
194
|
Turn::CueReporter.new($stdout, opts)
|
195
|
+
when :pretty
|
196
|
+
require 'turn/reporters/pretty_reporter'
|
197
|
+
Turn::PrettyReporter.new($stdout, opts)
|
195
198
|
else
|
196
|
-
require 'turn/reporters/
|
197
|
-
Turn::
|
199
|
+
require 'turn/reporters/pretty_reporter'
|
200
|
+
Turn::PrettyReporter.new($stdout, opts)
|
198
201
|
end
|
199
202
|
)
|
200
203
|
end
|
201
204
|
|
205
|
+
#
|
206
|
+
def environment_format
|
207
|
+
ENV['rpt']
|
208
|
+
end
|
209
|
+
|
202
210
|
#
|
203
211
|
def environment_trace
|
204
212
|
(ENV['backtrace'] ? ENV['backtrace'].to_i : nil)
|
data/lib/turn/reporter.rb
CHANGED
@@ -74,9 +74,9 @@ module Turn
|
|
74
74
|
|
75
75
|
$RUBY_IGNORE_CALLERS ||= []
|
76
76
|
$RUBY_IGNORE_CALLERS.concat([
|
77
|
-
/\/turn.*\.rb/,
|
77
|
+
/\/lib\/turn.*\.rb/,
|
78
78
|
/\/bin\/turn/,
|
79
|
-
/\/minitest.*\.rb/,
|
79
|
+
/\/lib\/minitest.*\.rb/,
|
80
80
|
/\/test\/unit.*\.rb/
|
81
81
|
])
|
82
82
|
|
@@ -87,7 +87,7 @@ module Turn
|
|
87
87
|
def filter_backtrace(backtrace)
|
88
88
|
return [] unless backtrace
|
89
89
|
bt = backtrace.dup
|
90
|
-
bt.reject
|
90
|
+
bt = bt.reject{ |line| $RUBY_IGNORE_CALLERS.any?{ |re| re =~ line } } unless $DEBUG
|
91
91
|
#bt.reject!{ |line| line.rindex('minitest') }
|
92
92
|
#bt.reject!{ |line| line.rindex('test/unit') }
|
93
93
|
#bt.reject!{ |line| line.rindex('lib/turn') }
|
@@ -105,7 +105,7 @@ module Turn
|
|
105
105
|
#
|
106
106
|
def naturalized_name(test)
|
107
107
|
if @natural
|
108
|
-
" #{test.name.gsub("test_", "").gsub(/_/, " ")}"
|
108
|
+
" #{test.name.gsub("test_", "").gsub(/_/, " ")}"
|
109
109
|
else
|
110
110
|
" #{test.name}"
|
111
111
|
end
|
@@ -119,7 +119,7 @@ module Turn
|
|
119
119
|
s = t.truncate
|
120
120
|
f = ((t - s) * 1000).to_i
|
121
121
|
|
122
|
-
"%01d:%02d:%02d
|
122
|
+
"%01d:%02d:%02d.%03d" % [h,m,s,f]
|
123
123
|
end
|
124
124
|
end
|
125
125
|
|
@@ -108,22 +108,26 @@ module Turn
|
|
108
108
|
#end
|
109
109
|
|
110
110
|
def finish_suite(suite)
|
111
|
-
total
|
112
|
-
|
113
|
-
|
114
|
-
|
111
|
+
total = suite.count_tests
|
112
|
+
passes = suite.count_passes
|
113
|
+
assertions = suite.count_assertions
|
114
|
+
failures = suite.count_failures
|
115
|
+
errors = suite.count_errors
|
116
|
+
skips = suite.count_skips
|
115
117
|
|
116
118
|
bar = '=' * 78
|
119
|
+
# @FIXME: Remove this, since Colorize already take care of colorize?
|
117
120
|
if colorize?
|
118
121
|
bar = if pass == total then Colorize.green(bar)
|
119
122
|
else Colorize.red(bar) end
|
120
123
|
end
|
121
124
|
|
122
|
-
|
125
|
+
# @FIXME: Should we add suite.runtime, instead if this lame time calculations?
|
126
|
+
tally = [total, assertions, (Time.new - @time)]
|
123
127
|
|
124
128
|
io.puts bar
|
125
|
-
io.puts " pass: %d, fail: %d, error: %d" % [
|
126
|
-
io.puts " total: %d tests with %d assertions in
|
129
|
+
io.puts " pass: %d, fail: %d, error: %d, skip: %d" % [passes, failures, errors, skips]
|
130
|
+
io.puts " total: %d tests with %d assertions in %f seconds" % tally
|
127
131
|
io.puts bar
|
128
132
|
end
|
129
133
|
|
@@ -68,31 +68,22 @@ module Turn
|
|
68
68
|
|
69
69
|
io.puts report
|
70
70
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
def test_tally(suite)
|
87
|
-
counts = suite.collect{ |tr| tr.counts }
|
88
|
-
tally = [0,0,0,0]
|
89
|
-
counts.each do |count|
|
90
|
-
4.times{ |i| tally[i] += count[i] }
|
91
|
-
end
|
92
|
-
return tally
|
71
|
+
# @TODO: Add something like suite.count(:tests, :passes) or
|
72
|
+
# suite.count(tests: "%d tests", passes: "%d passes")
|
73
|
+
# to cleanup, which will return something handy
|
74
|
+
# (suite.count(:test, :passes).test proxy maybe?)
|
75
|
+
total = "%d tests" % suite.count_tests
|
76
|
+
passes = "%d passed" % suite.count_passes
|
77
|
+
assertions = "%d assertions" % suite.count_assertions
|
78
|
+
failures = "%s failures" % suite.count_failures
|
79
|
+
errors = "%s errors" % suite.count_errors
|
80
|
+
skips = "%s skips" % suite.count_skips
|
81
|
+
|
82
|
+
tally = [total, passes, assertions, failures, errors, skips].join(", ")
|
83
|
+
|
84
|
+
io.puts suite.passed? ? Colorize.green(tally) : Colorize.red(tally)
|
93
85
|
end
|
94
86
|
|
95
87
|
end
|
96
88
|
|
97
|
-
end
|
98
|
-
|
89
|
+
end
|
@@ -7,7 +7,10 @@ module Turn
|
|
7
7
|
#
|
8
8
|
#--
|
9
9
|
# TODO: Should we fit reporter output to width of console?
|
10
|
+
# y8: Yes. we should, but it's a kinda tricky, if you want to make it
|
11
|
+
# cross-platform. (See https://github.com/cldwalker/hirb/blob/master/lib/hirb/util.rb#L61)
|
10
12
|
# TODO: Running percentages?
|
13
|
+
# TODO: Cleanup me!
|
11
14
|
#++
|
12
15
|
class OutlineReporter < Reporter
|
13
16
|
|
@@ -18,6 +21,7 @@ module Turn
|
|
18
21
|
def start_suite(suite)
|
19
22
|
@suite = suite
|
20
23
|
@time = Time.now
|
24
|
+
# @FIXME (y8): Why we need to capture stdout and stderr?
|
21
25
|
@stdout = StringIO.new
|
22
26
|
@stderr = StringIO.new
|
23
27
|
#files = suite.collect{ |s| s.file }.join(' ')
|
@@ -32,7 +36,7 @@ module Turn
|
|
32
36
|
|
33
37
|
#
|
34
38
|
def start_case(kase)
|
35
|
-
io.puts(Colorize.bold("#{kase.name}"))
|
39
|
+
io.puts(Colorize.bold("#{kase.name}")) if kase.size > 0
|
36
40
|
end
|
37
41
|
|
38
42
|
#
|
@@ -42,6 +46,7 @@ module Turn
|
|
42
46
|
# io.puts(test.file)
|
43
47
|
#end
|
44
48
|
|
49
|
+
# @FIXME: Should we move naturalized_name to test itself?
|
45
50
|
name = naturalized_name(test)
|
46
51
|
|
47
52
|
io.print " %-57s" % name
|
@@ -152,26 +157,29 @@ module Turn
|
|
152
157
|
|
153
158
|
# TODO: pending (skip) counts
|
154
159
|
def finish_suite(suite)
|
155
|
-
total
|
156
|
-
|
157
|
-
|
158
|
-
|
160
|
+
total = suite.count_tests
|
161
|
+
passes = suite.count_passes
|
162
|
+
assertions = suite.count_assertions
|
163
|
+
failures = suite.count_failures
|
164
|
+
errors = suite.count_errors
|
165
|
+
skips = suite.count_skips
|
159
166
|
|
160
167
|
bar = '=' * 78
|
168
|
+
# @FIXME: Remove this, since Colorize already take care of colorize?
|
161
169
|
if colorize?
|
162
170
|
bar = if pass == total then Colorize.green(bar)
|
163
171
|
else Colorize.red(bar) end
|
164
172
|
end
|
165
173
|
|
166
|
-
|
174
|
+
# @FIXME: Should we add suite.runtime, instead if this lame time calculations?
|
175
|
+
tally = [total, assertions, (Time.new - @time)]
|
167
176
|
|
168
177
|
io.puts bar
|
169
|
-
io.puts " pass: %d, fail: %d, error: %d" % [
|
170
|
-
io.puts " total: %d tests with %d assertions in
|
178
|
+
io.puts " pass: %d, fail: %d, error: %d, skip: %d" % [passes, failures, errors, skips]
|
179
|
+
io.puts " total: %d tests with %d assertions in %f seconds" % tally
|
171
180
|
io.puts bar
|
172
181
|
end
|
173
182
|
|
174
183
|
end
|
175
184
|
|
176
|
-
end
|
177
|
-
|
185
|
+
end
|
@@ -1,204 +1,146 @@
|
|
1
1
|
require 'turn/reporter'
|
2
2
|
|
3
3
|
module Turn
|
4
|
-
|
5
4
|
# = Pretty Reporter (by Paydro)
|
6
5
|
#
|
6
|
+
# Example output:
|
7
|
+
# TestCaseName:
|
8
|
+
# PASS test: Succesful test case. (0:00:02:059)
|
9
|
+
# ERROR test: Bogus test case. (0:00:02:059)
|
10
|
+
# FAIL test: Failed test case. (0:00:02:059)
|
11
|
+
#
|
7
12
|
class PrettyReporter < Reporter
|
8
|
-
#
|
9
|
-
PADDING_SIZE = 4
|
10
|
-
|
11
|
-
#
|
13
|
+
# Second column left padding in chars.
|
12
14
|
TAB_SIZE = 10
|
13
15
|
|
14
|
-
#
|
16
|
+
# Character to put in front of backtrace.
|
17
|
+
TRACE_MARK = '@ '
|
18
|
+
|
19
|
+
# TODO: solo and cross runners do not have name or seed, need to fix.
|
20
|
+
|
21
|
+
# At the very start, before any testcases are run, this is called.
|
15
22
|
def start_suite(suite)
|
16
|
-
#old_sync, @@out.sync = @@out.sync, true if io.respond_to? :sync=
|
17
23
|
@suite = suite
|
18
24
|
@time = Time.now
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
+
|
26
|
+
io.puts Colorize.bold("Loaded Suite #{suite.name}")
|
27
|
+
io.puts
|
28
|
+
if suite.seed
|
29
|
+
io.puts "Started at #{Time.now} w/ seed #{suite.seed}."
|
30
|
+
else
|
31
|
+
io.puts "Started at #{Time.now}."
|
32
|
+
end
|
33
|
+
io.puts
|
25
34
|
end
|
26
35
|
|
27
|
-
#
|
36
|
+
# Invoked before a testcase is run.
|
28
37
|
def start_case(kase)
|
29
|
-
#
|
30
|
-
|
31
|
-
|
38
|
+
# Print case name if there any tests in suite
|
39
|
+
# TODO: Add option which will show all test cases, even without tests?
|
40
|
+
io.puts kase.name if kase.size > 0
|
32
41
|
end
|
33
42
|
|
34
|
-
#
|
43
|
+
# Invoked before a test is run.
|
35
44
|
def start_test(test)
|
36
45
|
@test_time = Time.now
|
37
46
|
@test = test
|
38
|
-
#if @file != test.file
|
39
|
-
# @file = test.file
|
40
|
-
# io.puts(test.file)
|
41
|
-
#end
|
42
|
-
#io.print " %-69s" % test.name
|
43
|
-
#$stdout = @stdout
|
44
|
-
#$stderr = @stderr
|
45
|
-
#$stdout.rewind
|
46
|
-
#$stderr.rewind
|
47
47
|
end
|
48
48
|
|
49
|
-
#
|
49
|
+
# Invoked when a test passes.
|
50
50
|
def pass(message=nil)
|
51
|
-
|
52
|
-
|
53
|
-
io.print " (%.2fs) " % (Time.now - @test_time)
|
51
|
+
banner PASS
|
52
|
+
|
54
53
|
if message
|
55
54
|
message = Colorize.magenta(message)
|
56
|
-
message = message.to_s.tabto(
|
55
|
+
message = message.to_s.tabto(TAB_SIZE)
|
56
|
+
|
57
57
|
io.puts(message)
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
-
#
|
61
|
+
# Invoked when a test raises an assertion.
|
62
62
|
def fail(assertion, message=nil)
|
63
|
-
|
64
|
-
io.print " #{@test}"
|
65
|
-
io.print " (%.2fs) " % (Time.now - @test_time)
|
66
|
-
|
67
|
-
#message = assertion.location[0] + "\n" + assertion.message #.gsub("\n","\n")
|
68
|
-
#trace = MiniTest::filter_backtrace(report[:exception].backtrace).first
|
69
|
-
|
70
|
-
message ||= assertion.message
|
71
|
-
|
72
|
-
_trace = if assertion.respond_to?(:backtrace)
|
73
|
-
filter_backtrace(assertion.backtrace)
|
74
|
-
else
|
75
|
-
filter_backtrace(assertion.location).first
|
76
|
-
end
|
77
|
-
|
78
|
-
io.puts
|
79
|
-
#io.puts pad(message, tabsize)
|
80
|
-
io.puts message.tabto(TAB_SIZE)
|
81
|
-
|
82
|
-
cnt = @trace ? @trace.to_i : _trace.size
|
83
|
-
io.puts _trace[0, cnt].map{|l| l.tabto(TAB_SIZE) }.join("\n")
|
63
|
+
banner FAIL
|
84
64
|
|
85
|
-
|
65
|
+
prettify(message, assertion)
|
86
66
|
end
|
87
67
|
|
88
|
-
#
|
68
|
+
# Invoked when a test raises an exception.
|
89
69
|
def error(exception, message=nil)
|
90
|
-
|
91
|
-
io.print " #{@test}"
|
92
|
-
io.print " (%.2fs) " % (Time.now - @test_time)
|
93
|
-
|
94
|
-
#message = exception.to_s.split("\n")[2..-1].join("\n")
|
70
|
+
banner ERROR
|
95
71
|
|
96
|
-
message
|
97
|
-
|
98
|
-
_trace = if exception.respond_to?(:backtrace)
|
99
|
-
clean_backtrace(exception.backtrace)
|
100
|
-
else
|
101
|
-
clean_backtrace(exception.location)
|
102
|
-
end
|
103
|
-
|
104
|
-
io.puts
|
105
|
-
io.puts message.tabto(TAB_SIZE)
|
106
|
-
io.puts _trace.map{|l| l.tabto(TAB_SIZE) }.join("\n")
|
72
|
+
prettify(message, exception)
|
107
73
|
end
|
108
74
|
|
109
|
-
#
|
75
|
+
# Invoked when a test is skipped.
|
110
76
|
def skip(exception, message=nil)
|
111
|
-
|
112
|
-
io.print " #{@test}"
|
113
|
-
io.print " (%.2fs) " % (Time.now - @test_time)
|
114
|
-
|
115
|
-
message ||= exception.message
|
116
|
-
|
117
|
-
_trace = if exception.respond_to?(:backtrace)
|
118
|
-
clean_backtrace(exception.backtrace)
|
119
|
-
else
|
120
|
-
clean_backtrace(exception.location)
|
121
|
-
end
|
122
|
-
|
123
|
-
io.puts
|
124
|
-
io.puts message.tabto(TAB_SIZE)
|
125
|
-
io.puts _trace.map{|l| l.tabto(TAB_SIZE) }.join("\n")
|
126
|
-
end
|
77
|
+
banner SKIP
|
127
78
|
|
128
|
-
|
129
|
-
def finish_test(test)
|
130
|
-
io.puts
|
131
|
-
#@test_count += 1
|
132
|
-
#@assertion_count += inst._assertions
|
133
|
-
#$stdout = STDOUT
|
134
|
-
#$stderr = STDERR
|
79
|
+
prettify(message, exception)
|
135
80
|
end
|
136
81
|
|
137
|
-
|
138
|
-
def show_captured_output
|
139
|
-
show_captured_stdout
|
140
|
-
show_captured_stderr
|
141
|
-
end
|
142
|
-
|
143
|
-
def show_captured_stdout
|
144
|
-
@stdout.rewind
|
145
|
-
return if @stdout.eof?
|
146
|
-
STDOUT.puts(<<-output.tabto(8))
|
147
|
-
\nSTDOUT:
|
148
|
-
#{@stdout.read}
|
149
|
-
output
|
150
|
-
end
|
151
|
-
|
152
|
-
def show_captured_stderr
|
153
|
-
@stderr.rewind
|
154
|
-
return if @stderr.eof?
|
155
|
-
STDOUT.puts(<<-output.tabto(8))
|
156
|
-
\nSTDERR:
|
157
|
-
#{@stderr.read}
|
158
|
-
output
|
159
|
-
end
|
160
|
-
=end
|
161
|
-
|
82
|
+
# Invoked after all tests in a testcase have ben run.
|
162
83
|
def finish_case(kase)
|
163
|
-
|
164
|
-
|
165
|
-
end
|
84
|
+
# Print newline is there any tests in suite
|
85
|
+
io.puts if kase.size > 0
|
166
86
|
end
|
167
87
|
|
168
|
-
#
|
88
|
+
# After all tests are run, this is the last observable action.
|
169
89
|
def finish_suite(suite)
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
io.puts
|
178
|
-
io.puts "Finished in #{'%.6f' % (Time.now - @time)} seconds."
|
90
|
+
total = "%d tests" % suite.count_tests
|
91
|
+
passes = "%d passed" % suite.count_passes
|
92
|
+
assertions = "%d assertions" % suite.count_assertions
|
93
|
+
failures = "%d failures" % suite.count_failures
|
94
|
+
errors = "%d errors" % suite.count_errors
|
95
|
+
skips = "%d skips" % suite.count_skips
|
96
|
+
|
97
|
+
io.puts "Finished in %.6f seconds." % (Time.now - @time)
|
179
98
|
io.puts
|
180
99
|
|
181
|
-
io.
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
100
|
+
io.puts [ Colorize.bold(total),
|
101
|
+
Colorize.pass(passes),
|
102
|
+
Colorize.fail(failures),
|
103
|
+
Colorize.error(errors),
|
104
|
+
Colorize.skip(skips),
|
105
|
+
assertions
|
106
|
+
].join(", ")
|
107
|
+
|
108
|
+
# Please keep this newline, since it will be useful when after test case
|
109
|
+
# there will be other lines. For example "rake aborted!" or kind of.
|
186
110
|
io.puts
|
187
111
|
end
|
188
112
|
|
189
113
|
private
|
190
|
-
|
114
|
+
# Outputs test case header for given event (error, fail & etc)
|
191
115
|
#
|
192
|
-
|
193
|
-
|
116
|
+
# Example:
|
117
|
+
# PASS test: Test decription. (0:00:02:059)
|
118
|
+
def banner(event)
|
119
|
+
io.puts "%18s %s (%s)" % [event, @test, ticktock]
|
194
120
|
end
|
195
121
|
|
122
|
+
# Cleanups and prints test payload
|
196
123
|
#
|
197
|
-
|
198
|
-
|
199
|
-
|
124
|
+
# Example:
|
125
|
+
# fail is not 1
|
126
|
+
# @ test/test_runners.rb:46:in `test_autorun_with_trace'
|
127
|
+
# bin/turn:4:in `<main>'
|
128
|
+
def prettify(message=nil, raised)
|
129
|
+
# Get message from raised, if not given
|
130
|
+
message ||= raised.message
|
200
131
|
|
201
|
-
|
132
|
+
backtrace = raised.respond_to?(:backtrace) ? raised.backtrace : raised.location
|
202
133
|
|
203
|
-
|
134
|
+
# Filter and clean backtrace
|
135
|
+
backtrace = clean_backtrace(backtrace)
|
204
136
|
|
137
|
+
# Add trace mark to first line.
|
138
|
+
backtrace.first.insert(0, TRACE_MARK)
|
139
|
+
|
140
|
+
io.puts Colorize.bold(message.tabto(TAB_SIZE))
|
141
|
+
io.puts backtrace.shift.tabto(TAB_SIZE - TRACE_MARK.length)
|
142
|
+
io.puts backtrace.join("\n").tabto(TAB_SIZE)
|
143
|
+
io.puts
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
@@ -55,10 +55,10 @@ module Turn
|
|
55
55
|
|
56
56
|
width = suite.collect{ |tr| tr.name.to_s.size }.max
|
57
57
|
|
58
|
-
headers = [ 'TESTCASE ', ' TESTS ', 'ASSERTIONS', ' FAILURES ', ' ERRORS ' ]
|
59
|
-
io.puts "\n\n%-#{width}s %10s %10s %10s %10s\n" % headers
|
58
|
+
headers = [ 'TESTCASE ', ' TESTS ', 'ASSERTIONS', ' FAILURES ', ' ERRORS ', 'SKIPS ' ]
|
59
|
+
io.puts "\n\n%-#{width}s %10s %10s %10s %10s %10s\n" % headers
|
60
60
|
|
61
|
-
io.puts ("-" * (width +
|
61
|
+
io.puts ("-" * (width + 60))
|
62
62
|
|
63
63
|
files = nil
|
64
64
|
suite.each do |testrun|
|
@@ -73,9 +73,9 @@ module Turn
|
|
73
73
|
|
74
74
|
#puts("\n%i tests, %i assertions, %i failures, %i errors\n\n" % tally)
|
75
75
|
|
76
|
-
tally_line = ("-" * (width +
|
76
|
+
tally_line = ("-" * (width + 60))
|
77
77
|
tally_line << "\n%-#{width}s " % "TOTAL"
|
78
|
-
tally_line << "%10s %10s %10s %10s" % tally
|
78
|
+
tally_line << "%10s %10s %10s %10s %10s" % tally
|
79
79
|
|
80
80
|
io.puts(tally_line + "\n\n\n")
|
81
81
|
|
@@ -127,7 +127,7 @@ module Turn
|
|
127
127
|
def paint_line(testrun, width)
|
128
128
|
line = ''
|
129
129
|
line << "%-#{width}s " % [testrun.name]
|
130
|
-
line << "%10s %10s %10s %10s" % testrun.counts
|
130
|
+
line << "%10s %10s %10s %10s %10s" % testrun.counts
|
131
131
|
line << " " * 8
|
132
132
|
if testrun.fail?
|
133
133
|
line << "[#{FAIL}]"
|
@@ -141,14 +141,13 @@ module Turn
|
|
141
141
|
|
142
142
|
def test_tally(suite)
|
143
143
|
counts = suite.collect{ |tr| tr.counts }
|
144
|
-
tally = [0,0,0,0]
|
144
|
+
tally = [0,0,0,0,0]
|
145
145
|
counts.each do |count|
|
146
|
-
|
146
|
+
5.times{ |i| tally[i] += count[i] }
|
147
147
|
end
|
148
148
|
return tally
|
149
149
|
end
|
150
150
|
|
151
151
|
end
|
152
152
|
|
153
|
-
end
|
154
|
-
|
153
|
+
end
|
@@ -80,6 +80,7 @@ module Turn
|
|
80
80
|
#err = ''
|
81
81
|
|
82
82
|
out, err = nil, nil
|
83
|
+
p cmd
|
83
84
|
Open3.popen3(cmd) do |stdin, stdout, stderr|
|
84
85
|
stdin.close
|
85
86
|
out = stdout.read.chomp
|
@@ -96,7 +97,7 @@ module Turn
|
|
96
97
|
files = kase.files
|
97
98
|
|
98
99
|
# remove any unexpected output injected at the beginning
|
99
|
-
b = out.index(/^---/)
|
100
|
+
b = out.index(/^---/m)
|
100
101
|
yaml = out[b..-1]
|
101
102
|
sub_suite = YAML.load(yaml)
|
102
103
|
|
data/lib/turn/version.rb
CHANGED
data/test/test_runners.rb
CHANGED
@@ -5,17 +5,17 @@ class TestRunners < Test::Unit::TestCase
|
|
5
5
|
def test_solo
|
6
6
|
file = setup_testunit(false, 'test_solo.rb')
|
7
7
|
result = turn2 '--solo', file
|
8
|
-
assert result.index('
|
9
|
-
assert result.index('
|
10
|
-
assert result.index('
|
8
|
+
assert result.index('1 passed'), "ACTUAL RESULT:\n #{result}"
|
9
|
+
assert result.index('0 failures'), "ACTUAL RESULT:\n #{result}"
|
10
|
+
assert result.index('0 errors'), "ACTUAL RESULT:\n #{result}"
|
11
11
|
end
|
12
12
|
|
13
13
|
def test_cross
|
14
14
|
file1 = setup_testunit(false, 'test1.rb')
|
15
15
|
file2 = setup_testunit(false, 'test2.rb')
|
16
16
|
result = turn2 '--cross', file1, file2
|
17
|
-
assert result.index('
|
18
|
-
assert result.index('
|
17
|
+
assert result.index('2 passed'), "ACTUAL RESULT:\n #{result}"
|
18
|
+
assert result.index('0 errors'), "ACTUAL RESULT:\n #{result}"
|
19
19
|
end
|
20
20
|
|
21
21
|
# autorun
|
@@ -25,9 +25,9 @@ class TestRunners < Test::Unit::TestCase
|
|
25
25
|
def test_autorun_testunit
|
26
26
|
file = setup_testunit('turn/autorun', 'test_autorun.rb')
|
27
27
|
result = `ruby -Ilib #{file} 2>&1`
|
28
|
-
assert(result.index('
|
29
|
-
assert(result.index('
|
30
|
-
assert(result.index('
|
28
|
+
assert(result.index('1 passed'), "ACTUAL RESULT:\n #{result}")
|
29
|
+
assert(result.index('0 failures'), "ACTUAL RESULT:\n #{result}")
|
30
|
+
assert(result.index('0 errors'), "ACTUAL RESULT:\n #{result}")
|
31
31
|
end
|
32
32
|
|
33
33
|
#else
|
@@ -35,16 +35,16 @@ class TestRunners < Test::Unit::TestCase
|
|
35
35
|
def test_autorun
|
36
36
|
file = setup_minitest_autorun
|
37
37
|
result = `ruby -Ilib #{file} 2>&1`
|
38
|
-
assert result.index('
|
39
|
-
assert result.index('
|
38
|
+
assert result.index('0 failures'), "ACTUAL RESULT:\n #{result}"
|
39
|
+
assert result.index('0 errors'), "ACTUAL RESULT:\n #{result}"
|
40
40
|
end
|
41
41
|
|
42
42
|
def test_autorun_with_trace
|
43
43
|
file = setup_minitest_autorun_with_trace
|
44
44
|
|
45
45
|
result = `ruby -Ilib #{file} 2>&1`
|
46
|
-
assert result.index('
|
47
|
-
assert result.index('
|
46
|
+
assert result.index('1 failures'), 'fail is not 1'
|
47
|
+
assert result.index('0 errors'), 'error is not 0'
|
48
48
|
|
49
49
|
# TODO: the backtrace is empty, why?
|
50
50
|
#assert result.scan(/\.rb:\d+:in/).length > 1
|
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
|
+
version: 0.9.3
|
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-02-
|
13
|
+
date: 2012-02-17 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: ansi
|
17
|
-
requirement: &
|
17
|
+
requirement: &7615200 !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: *
|
25
|
+
version_requirements: *7615200
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: minitest
|
28
|
-
requirement: &
|
28
|
+
requirement: &7613840 !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: *
|
36
|
+
version_requirements: *7613840
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: rake
|
39
|
-
requirement: &
|
39
|
+
requirement: &7566920 !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: *
|
47
|
+
version_requirements: *7566920
|
48
48
|
description: Turn provides a set of alternative runners for MiniTest, both colorful
|
49
49
|
and informative.
|
50
50
|
email:
|