TwP-turn 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +23 -0
- data/README.txt +117 -0
- data/Rakefile +32 -0
- data/Release.txt +29 -0
- data/VERSION +1 -0
- data/bin/turn +4 -0
- data/lib/turn.rb +80 -0
- data/lib/turn/colorize.rb +29 -0
- data/lib/turn/command.rb +159 -0
- data/lib/turn/components/case.rb +98 -0
- data/lib/turn/components/method.rb +32 -0
- data/lib/turn/components/suite.rb +82 -0
- data/lib/turn/controller.rb +146 -0
- data/lib/turn/reporter.rb +56 -0
- data/lib/turn/reporters/dot_reporter.rb +78 -0
- data/lib/turn/reporters/marshal_reporter.rb +64 -0
- data/lib/turn/reporters/outline_reporter.rb +85 -0
- data/lib/turn/reporters/progress_reporter.rb +117 -0
- data/lib/turn/runners/crossrunner.rb +40 -0
- data/lib/turn/runners/isorunner.rb +129 -0
- data/lib/turn/runners/loadrunner.rb +48 -0
- data/lib/turn/runners/solorunner.rb +8 -0
- data/lib/turn/runners/testrunner.rb +154 -0
- data/test/test_example.rb +15 -0
- data/test/test_sample.rb +15 -0
- data/turn.gemspec +37 -0
- data/work/quicktest.rb +42 -0
- data/work/turn.rb +119 -0
- metadata +94 -0
data/History.txt
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
== 0.5.1 / 2009-03-25
|
2
|
+
* fixed a "convert nil into String" error
|
3
|
+
|
4
|
+
== 0.4.0 / 2008-09-18
|
5
|
+
* add solo and cross runners
|
6
|
+
* move Colorize into separate file
|
7
|
+
* use ::ANSICode instead of ::Console::ANSICode
|
8
|
+
|
9
|
+
== 0.3.0 / 2007-12-11
|
10
|
+
* color highlighting now works (need facets-2.0 library)
|
11
|
+
|
12
|
+
== 0.2.0 / 2006-11-26
|
13
|
+
* add the "turn" executable
|
14
|
+
* fixed warnings
|
15
|
+
|
16
|
+
== 0.1.2 / 2006-11-13
|
17
|
+
* added some instructions for using the package
|
18
|
+
|
19
|
+
== 0.1.1 / 2006-11-10
|
20
|
+
* removed explicit dependency on the 'hoe' gem
|
21
|
+
|
22
|
+
== 0.1.0 / 2006-11-10
|
23
|
+
* initial release
|
data/README.txt
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
= TURN - Test::Unit Reporter (New)
|
2
|
+
by Tim Pease
|
3
|
+
http://codeforpeople.rubyforge.org/turn
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
TURN is a new way to view Test::Unit results. With longer running tests, it
|
8
|
+
can be very frustrating to see a failure (....F...) and then have to wait till
|
9
|
+
all the tests finish before you can see what the exact failure was. TURN
|
10
|
+
displays each test on a separate line with failures being displayed
|
11
|
+
immediately instead of at the end of the tests.
|
12
|
+
|
13
|
+
If you have the 'facets' gem installed, then TURN output will be displayed in
|
14
|
+
wonderful technicolor (but only if your terminal supports ANSI color codes).
|
15
|
+
Well, the only colors are green and red, but that is still color.
|
16
|
+
|
17
|
+
== FEATURES:
|
18
|
+
|
19
|
+
General usage provides better test output. Here is some sample output:
|
20
|
+
|
21
|
+
TestMyClass
|
22
|
+
test_alt PASS
|
23
|
+
test_alt_eq PASS
|
24
|
+
test_bad FAIL
|
25
|
+
./test/test_my_class.rb:64:in `test_bad'
|
26
|
+
<false> is not true.
|
27
|
+
test_foo PASS
|
28
|
+
test_foo_eq PASS
|
29
|
+
TestYourClass
|
30
|
+
test_method_a PASS
|
31
|
+
test_method_b PASS
|
32
|
+
test_method_c PASS
|
33
|
+
============================================================================
|
34
|
+
pass: 7, fail: 1, error: 0
|
35
|
+
total: 15 tests with 42 assertions in 0.018 seconds
|
36
|
+
============================================================================
|
37
|
+
|
38
|
+
Turn also provides solo and cross test modes when run from the *turn* commandline
|
39
|
+
application.
|
40
|
+
|
41
|
+
== SYNOPSIS:
|
42
|
+
|
43
|
+
If you have the 'facets' gem installed, then TURN output will be displayed in
|
44
|
+
wonderful technicolor (but only if your terminal supports ANSI color codes).
|
45
|
+
Well, the only colors are green and red, but that is still color.
|
46
|
+
|
47
|
+
=== Command Line
|
48
|
+
|
49
|
+
You can use the *turn* executable in place of the *ruby* interpreter.
|
50
|
+
|
51
|
+
turn -Ilib test/test_all.rb
|
52
|
+
|
53
|
+
This will invoke the ruby interpreter and automatically require the turn
|
54
|
+
formatting library. All command line arguments are passed "as is" to the
|
55
|
+
ruby interpreter.
|
56
|
+
|
57
|
+
To use the solo runner.
|
58
|
+
|
59
|
+
turn --solo -Ilib test/
|
60
|
+
|
61
|
+
This will run all tests in the test/ directory in a separate process.
|
62
|
+
Likewise for the cross runner.
|
63
|
+
|
64
|
+
turn --cross -Ilib test/
|
65
|
+
|
66
|
+
This will run every pairing of tests in a separate process.
|
67
|
+
|
68
|
+
=== Require
|
69
|
+
|
70
|
+
Simply require the TURN package from within your test suite.
|
71
|
+
|
72
|
+
require 'turn'
|
73
|
+
|
74
|
+
This will configure Test::Unit to use TURN formatting for displaying test
|
75
|
+
restuls. A better line to use, though, is the following:
|
76
|
+
|
77
|
+
begin; require 'turn'; rescue LoadError; end
|
78
|
+
|
79
|
+
When you distribute your code, the test suite can be run without requiring
|
80
|
+
the end user to install the TURN package.
|
81
|
+
|
82
|
+
For a Rails application, put the require line into the 'test/test_helper.rb'
|
83
|
+
scipt. Now your Rails tests will use TURN formatting.
|
84
|
+
|
85
|
+
== REQUIREMENTS:
|
86
|
+
|
87
|
+
* facets 2.0+
|
88
|
+
|
89
|
+
== INSTALL:
|
90
|
+
|
91
|
+
* sudo gem install turn
|
92
|
+
|
93
|
+
== LICENSE:
|
94
|
+
|
95
|
+
MIT License
|
96
|
+
|
97
|
+
Copyright (c) 2006-2008
|
98
|
+
|
99
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
100
|
+
a copy of this software and associated documentation files (the
|
101
|
+
'Software'), to deal in the Software without restriction, including
|
102
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
103
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
104
|
+
permit persons to whom the Software is furnished to do so, subject to
|
105
|
+
the following conditions:
|
106
|
+
|
107
|
+
The above copyright notice and this permission notice shall be
|
108
|
+
included in all copies or substantial portions of the Software.
|
109
|
+
|
110
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
111
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
112
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
113
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
114
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
115
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
116
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
117
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
|
2
|
+
begin
|
3
|
+
require 'bones'
|
4
|
+
Bones.setup
|
5
|
+
rescue LoadError
|
6
|
+
begin
|
7
|
+
load 'tasks/setup.rb'
|
8
|
+
rescue LoadError
|
9
|
+
raise RuntimeError, '### please install the "bones" gem ###'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
task :default => 'test'
|
14
|
+
|
15
|
+
PROJ.name = 'turn'
|
16
|
+
PROJ.summary = 'Test::Unit Reporter (New) -- new output format for Test::Unit'
|
17
|
+
PROJ.authors = 'Tim Pease'
|
18
|
+
PROJ.email = 'tim.pease@gmail.com'
|
19
|
+
PROJ.url = 'http://codeforpeople.rubyforge.org/turn'
|
20
|
+
PROJ.version = '0.5.1'
|
21
|
+
PROJ.ignore_file = '.gitignore'
|
22
|
+
|
23
|
+
PROJ.rubyforge.name = 'codeforpeople'
|
24
|
+
|
25
|
+
PROJ.rdoc.exclude << '^lib/'
|
26
|
+
PROJ.rdoc.remote_dir = PROJ.name
|
27
|
+
|
28
|
+
PROJ.ann.email[:server] = 'smtp.gmail.com'
|
29
|
+
PROJ.ann.email[:port] = 587
|
30
|
+
PROJ.ann.email[:from] = 'Tim Pease'
|
31
|
+
|
32
|
+
# EOF
|
data/Release.txt
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
= Turn 0.5
|
2
|
+
|
3
|
+
Turn has turned 0.5 with some signifficant new features.
|
4
|
+
|
5
|
+
While Turn still provides the exact same functionality for running
|
6
|
+
tests via ruby or testrb as previous versions. The turn commandline
|
7
|
+
utility has been completely rewritten with expanded capabilites.
|
8
|
+
|
9
|
+
The turn command now features three run modes:
|
10
|
+
|
11
|
+
* Solo runner for running each test file in a separate process.
|
12
|
+
* Cross runner for running test file pairs in separate processes.
|
13
|
+
* Normal runner, which of course runs all test in a single process.
|
14
|
+
|
15
|
+
It also support three report modes:
|
16
|
+
|
17
|
+
* Progress reporter which uses a progress bar.
|
18
|
+
* Minimal reporter which provides traditional "dot" progress.
|
19
|
+
* Outline reporter populaized by turn.
|
20
|
+
|
21
|
+
The is also a special Marshal Mode which dumps test results as YAML.
|
22
|
+
And the underlying API makes it easy create new reporters.
|
23
|
+
|
24
|
+
To get a quick rundown on how to use the new commandline:
|
25
|
+
|
26
|
+
$ turn --help
|
27
|
+
|
28
|
+
Enjoy!
|
29
|
+
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
turn 0.5.1 stable (2009-03-25)
|
data/bin/turn
ADDED
data/lib/turn.rb
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'test/unit/ui/console/testrunner'
|
2
|
+
require 'turn/colorize'
|
3
|
+
|
4
|
+
module ::Test::Unit
|
5
|
+
module UI
|
6
|
+
module Console
|
7
|
+
class TestRunner
|
8
|
+
include Turn::Colorize
|
9
|
+
|
10
|
+
alias :t_attach_to_mediator :attach_to_mediator
|
11
|
+
def attach_to_mediator
|
12
|
+
@mediator.add_listener(TestRunnerMediator::STARTED, &method(:t_started))
|
13
|
+
@mediator.add_listener(TestRunnerMediator::FINISHED, &method(:t_finished))
|
14
|
+
@mediator.add_listener(TestCase::STARTED, &method(:t_test_started))
|
15
|
+
@mediator.add_listener(TestCase::FINISHED, &method(:t_test_finished))
|
16
|
+
@mediator.add_listener(TestResult::FAULT, &method(:t_fault))
|
17
|
+
@io.sync = true
|
18
|
+
@t_cur_file, @t_fault = nil
|
19
|
+
end
|
20
|
+
|
21
|
+
def t_started( result )
|
22
|
+
@t_result = result
|
23
|
+
end
|
24
|
+
|
25
|
+
def t_finished( elapsed_time )
|
26
|
+
failure = @t_result.failure_count
|
27
|
+
error = @t_result.error_count
|
28
|
+
total = @t_result.run_count
|
29
|
+
pass = total - failure - error
|
30
|
+
|
31
|
+
bar = '=' * 78
|
32
|
+
if COLORIZE
|
33
|
+
bar = if pass == total then ::ANSICode.green bar
|
34
|
+
else ::ANSICode.red bar end
|
35
|
+
end
|
36
|
+
|
37
|
+
@io.puts bar
|
38
|
+
@io.puts " pass: %d, fail: %d, error: %d" % [pass, failure, error]
|
39
|
+
@io.puts " total: %d tests with %d assertions in #{elapsed_time} seconds" % [total, @t_result.assertion_count]
|
40
|
+
@io.puts bar
|
41
|
+
end
|
42
|
+
|
43
|
+
def t_test_started( name )
|
44
|
+
method, file = name.scan(%r/^([^\(]+)\(([^\)]+)\)/o).flatten!
|
45
|
+
if @t_cur_file != file
|
46
|
+
@t_cur_file = file
|
47
|
+
@io.puts file
|
48
|
+
end
|
49
|
+
@io.print " %-69s" % method
|
50
|
+
end
|
51
|
+
|
52
|
+
def t_test_finished( name )
|
53
|
+
@io.puts " #{PASS}" unless @t_fault
|
54
|
+
@t_fault = false
|
55
|
+
end
|
56
|
+
|
57
|
+
def t_fault( fault )
|
58
|
+
@t_fault = true
|
59
|
+
msg = "\t"
|
60
|
+
|
61
|
+
case fault
|
62
|
+
when ::Test::Unit::Error
|
63
|
+
@io.puts ERROR
|
64
|
+
msg << fault.to_s.split("\n")[2..-1].join("\n\t")
|
65
|
+
when ::Test::Unit::Failure
|
66
|
+
@io.puts " #{FAIL}"
|
67
|
+
msg << fault.location[0].to_s << "\n\t"
|
68
|
+
msg << fault.message.gsub("\n","\n\t")
|
69
|
+
end
|
70
|
+
|
71
|
+
msg = ::ANSICode.magenta msg if COLORIZE
|
72
|
+
@io.puts msg
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
# EOF
|
@@ -0,0 +1,29 @@
|
|
1
|
+
begin
|
2
|
+
require 'facets/ansicode'
|
3
|
+
rescue LoadError
|
4
|
+
begin
|
5
|
+
require 'rubygems'
|
6
|
+
require 'facets/ansicode'
|
7
|
+
rescue LoadError
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
module Turn
|
12
|
+
|
13
|
+
module Colorize
|
14
|
+
|
15
|
+
COLORIZE = defined?(::ANSICode) && ENV.has_key?('TERM')
|
16
|
+
|
17
|
+
if COLORIZE
|
18
|
+
PASS = ::ANSICode.green('PASS')
|
19
|
+
FAIL = ::ANSICode.red('FAIL')
|
20
|
+
ERROR = ::ANSICode.white(::ANSICode.on_red('ERROR'))
|
21
|
+
else
|
22
|
+
PASS = "PASS"
|
23
|
+
FAIL = "FAIL"
|
24
|
+
ERROR = "ERROR"
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
data/lib/turn/command.rb
ADDED
@@ -0,0 +1,159 @@
|
|
1
|
+
# Turn - Pretty Unit Test Runner for Ruby
|
2
|
+
#
|
3
|
+
# SYNOPSIS
|
4
|
+
# turn [OPTIONS] [RUN MODE] [OUTPUT MODE] [test globs...]
|
5
|
+
#
|
6
|
+
# OPTIONS
|
7
|
+
# -h --help display this help information
|
8
|
+
# --live don't use loadpath
|
9
|
+
# --log log results to a file
|
10
|
+
# -I --loadpath=PATHS add given paths to the $LOAD_PATH
|
11
|
+
# -r --requires=PATHS require given paths before running tests
|
12
|
+
#
|
13
|
+
# RUN MODES
|
14
|
+
# --normal run all tests in a single process [default]
|
15
|
+
# --solo run each test in a separate process
|
16
|
+
# --cross run each pair of test files in a separate process
|
17
|
+
#
|
18
|
+
# OUTPUT MODES
|
19
|
+
# -O --outline turn's original case/test outline mode [default]
|
20
|
+
# -P --progress indicates progress with progress bar
|
21
|
+
# -D --dotted test/unit's traditonal dot-progress mode
|
22
|
+
# -M --marshal dump output as YAML (normal run mode only)
|
23
|
+
|
24
|
+
require 'getoptlong'
|
25
|
+
require 'turn/controller'
|
26
|
+
|
27
|
+
#RUBY = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
|
28
|
+
|
29
|
+
original_argv = ARGV.dup
|
30
|
+
|
31
|
+
opts = GetoptLong.new(
|
32
|
+
[ '--help', '-h', GetoptLong::NO_ARGUMENT ],
|
33
|
+
[ '--live', GetoptLong::NO_ARGUMENT ],
|
34
|
+
[ '--log', GetoptLong::OPTIONAL_ARGUMENT ],
|
35
|
+
[ '--loadpath', '-I', GetoptLong::REQUIRED_ARGUMENT ],
|
36
|
+
[ '--requires', '-r', GetoptLong::REQUIRED_ARGUMENT ],
|
37
|
+
|
38
|
+
# RUN MODES
|
39
|
+
[ '--normal', GetoptLong::NO_ARGUMENT ],
|
40
|
+
[ '--solo', GetoptLong::NO_ARGUMENT ],
|
41
|
+
[ '--cross', GetoptLong::NO_ARGUMENT ],
|
42
|
+
#[ '--load', GetoptLong::NO_ARGUMENT ],
|
43
|
+
|
44
|
+
# OUTPUT MODES
|
45
|
+
[ '--outline', '-O', GetoptLong::NO_ARGUMENT ],
|
46
|
+
[ '--progress', '-P', GetoptLong::NO_ARGUMENT ],
|
47
|
+
[ '--dotted', '-D', GetoptLong::NO_ARGUMENT ],
|
48
|
+
[ '--marshal', '-M', GetoptLong::NO_ARGUMENT ]
|
49
|
+
)
|
50
|
+
|
51
|
+
live = nil
|
52
|
+
log = nil
|
53
|
+
loadpath = []
|
54
|
+
requires = []
|
55
|
+
|
56
|
+
runmode = nil
|
57
|
+
outmode = nil
|
58
|
+
|
59
|
+
opts.each do |opt, arg|
|
60
|
+
case opt
|
61
|
+
when '--help'
|
62
|
+
help, rest = File.read(__FILE__).split(/^\s*$/)
|
63
|
+
puts help.gsub(/^\#[ ]{0,1}/,'')
|
64
|
+
exit
|
65
|
+
|
66
|
+
when '--live'
|
67
|
+
live = true
|
68
|
+
when '--log'
|
69
|
+
log = true
|
70
|
+
when '--loadpath'
|
71
|
+
loadpath << arg
|
72
|
+
when '--requires'
|
73
|
+
requires << arg
|
74
|
+
|
75
|
+
when '--solo'
|
76
|
+
runmode = :solo
|
77
|
+
when '--cross'
|
78
|
+
runmode = :cross
|
79
|
+
when '--marshal'
|
80
|
+
runmode = :marshal
|
81
|
+
outmode = :marshal
|
82
|
+
when '--progress'
|
83
|
+
outmode = :progress
|
84
|
+
when '--outline'
|
85
|
+
outmode = :outline
|
86
|
+
when '--dotted'
|
87
|
+
outmode = :dotted
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
loadpath = ['lib'] if loadpath.empty?
|
92
|
+
|
93
|
+
tests = ARGV.empty? ? nil : ARGV.dup
|
94
|
+
|
95
|
+
case outmode
|
96
|
+
when :marshal
|
97
|
+
reporter = Turn::MarshalReporter.new($stdout)
|
98
|
+
when :progress
|
99
|
+
reporter = Turn::ProgressReporter.new($stdout)
|
100
|
+
when :dotted
|
101
|
+
reporter = Turn::DotReporter.new($stdout)
|
102
|
+
else
|
103
|
+
reporter = Turn::OutlineReporter.new($stdout)
|
104
|
+
end
|
105
|
+
|
106
|
+
case runmode
|
107
|
+
when :marshal
|
108
|
+
require 'turn/runners/testrunner'
|
109
|
+
runner = Turn::TestRunner
|
110
|
+
when :solo
|
111
|
+
require 'turn/runners/solorunner'
|
112
|
+
runner = Turn::SoloRunner
|
113
|
+
when :cross
|
114
|
+
require 'turn/runners/crossrunner'
|
115
|
+
runner = Turn::CrossRunner
|
116
|
+
else
|
117
|
+
require 'turn/runners/testrunner'
|
118
|
+
runner = Turn::TestRunner
|
119
|
+
end
|
120
|
+
|
121
|
+
controller = Turn::Controller.new do |c|
|
122
|
+
c.live = live
|
123
|
+
c.log = log
|
124
|
+
c.loadpath = loadpath
|
125
|
+
c.requires = requires
|
126
|
+
c.tests = tests
|
127
|
+
c.runner = runner
|
128
|
+
c.reporter = reporter
|
129
|
+
end
|
130
|
+
|
131
|
+
controller.start
|
132
|
+
|
133
|
+
=begin
|
134
|
+
else
|
135
|
+
|
136
|
+
begin
|
137
|
+
require 'turn/adapters/testunit' # 'turn'
|
138
|
+
rescue LoadError
|
139
|
+
require 'rubygems'
|
140
|
+
require 'turn/adapters/testunit' # 'turn'
|
141
|
+
end
|
142
|
+
|
143
|
+
ARGV.each{ |a| Dir[a].each{ |f| require f }}
|
144
|
+
Turn::TestRunner.run(TS_MyTests)
|
145
|
+
|
146
|
+
#RUBY = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
|
147
|
+
#
|
148
|
+
#begin
|
149
|
+
# require 'turn'
|
150
|
+
# Kernel.exec(RUBY, '-r', 'turn', *ARGV)
|
151
|
+
#rescue LoadError
|
152
|
+
# require 'rubygems'
|
153
|
+
# require 'turn'
|
154
|
+
# Kernel.exec(RUBY, '-rubygems', '-r', 'turn', *ARGV)
|
155
|
+
#end
|
156
|
+
|
157
|
+
end
|
158
|
+
=end
|
159
|
+
|