turn 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,3 @@
1
+ coverage
2
+ doc
3
+ pkg
@@ -0,0 +1,20 @@
1
+ == 0.4.0 / 2008-09-18
2
+ * add solo and cross runners
3
+ * move Colorize into separate file
4
+ * use ::ANSICode instead of ::Console::ANSICode
5
+
6
+ == 0.3.0 / 2007-12-11
7
+ * color highlighting now works (need facets-2.0 library)
8
+
9
+ == 0.2.0 / 2006-11-26
10
+ * add the "turn" executable
11
+ * fixed warnings
12
+
13
+ == 0.1.2 / 2006-11-13
14
+ * added some instructions for using the package
15
+
16
+ == 0.1.1 / 2006-11-10
17
+ * removed explicit dependency on the 'hoe' gem
18
+
19
+ == 0.1.0 / 2006-11-10
20
+ * initial release
@@ -0,0 +1,29 @@
1
+ .gitignore
2
+ History.txt
3
+ Manifest.txt
4
+ README.txt
5
+ Rakefile
6
+ Release.txt
7
+ VERSION
8
+ bin/turn
9
+ lib/turn.rb
10
+ lib/turn/colorize.rb
11
+ lib/turn/command.rb
12
+ lib/turn/components/case.rb
13
+ lib/turn/components/method.rb
14
+ lib/turn/components/suite.rb
15
+ lib/turn/controller.rb
16
+ lib/turn/reporter.rb
17
+ lib/turn/reporters/dot_reporter.rb
18
+ lib/turn/reporters/marshal_reporter.rb
19
+ lib/turn/reporters/outline_reporter.rb
20
+ lib/turn/reporters/progress_reporter.rb
21
+ lib/turn/runners/crossrunner.rb
22
+ lib/turn/runners/isorunner.rb
23
+ lib/turn/runners/loadrunner.rb
24
+ lib/turn/runners/solorunner.rb
25
+ lib/turn/runners/testrunner.rb
26
+ test/test_example.rb
27
+ test/test_sample.rb
28
+ work/quicktest.rb
29
+ work/turn.rb
data/README.txt CHANGED
@@ -1,45 +1,117 @@
1
+ = TURN - Test::Unit Reporter (New)
2
+ by Tim Pease
3
+ http://codeforpeople.rubyforge.org/turn
1
4
 
2
- = TURN -- Test::Unit Reporter (New)
5
+ == DESCRIPTION:
3
6
 
4
- TURN is a new way to view Test::Unit results. With longer running tests, it
5
- can be very frustrating to see a failure (....F...) and then have to wait till
6
- all the tests finish before you can see what the exact failure was. TURN
7
- displays each test on a separate line with failures being displayed
8
- immediately instead of at the end of the tests.
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.
9
16
 
10
- If you have the 'facets' gem installed, then TURN output will be displayed in
11
- wonderful technicolor (but only if your terminal supports ANSI color codes).
12
- Well, the only colors are green and red, but that is still color.
17
+ == FEATURES:
13
18
 
14
- == Usage
19
+ General usage provides better test output. Here is some sample output:
15
20
 
16
- === Command Line
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
+ ============================================================================
17
37
 
18
- You can use the *turn* executable in place of the *ruby* interpreter.
38
+ Turn also provides solo and cross test modes when run from the *turn* commandline
39
+ application.
19
40
 
20
- turn -Ilib test/test_all.rb
41
+ == SYNOPSIS:
21
42
 
22
- This will invoke the ruby interpreter and automatically require the turn
23
- formatting library. All command line arguments are passed "as is" to the
24
- ruby interpreter.
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.
25
46
 
26
- === Require
47
+ === Command Line
27
48
 
28
- Simply require the TURN package from within your test suite.
49
+ You can use the *turn* executable in place of the *ruby* interpreter.
29
50
 
30
- require 'turn'
51
+ turn -Ilib test/test_all.rb
31
52
 
32
- This will configure Test::Unit to use TURN formatting for displaying test
33
- restuls. A better line to use, though, is the following:
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.
34
56
 
35
- begin; require 'turn'; rescue LoadError; end
57
+ To use the solo runner.
36
58
 
37
- When you distribute your code, the test suite can be run without requiring
38
- the end user to install the TURN package.
59
+ turn --solo -Ilib test/
39
60
 
40
- For a Rails application, put the require line into the 'test/test_helper.rb'
41
- scipt. Now your Rails tests will use TURN formatting.
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.
42
117
 
43
- === Author
44
-
45
- Tim Pease
@@ -0,0 +1,24 @@
1
+
2
+ begin
3
+ require 'bones'
4
+ Bones.setup
5
+ rescue LoadError
6
+ load 'tasks/setup.rb'
7
+ end
8
+
9
+ task :default => 'test'
10
+
11
+ PROJ.name = 'turn'
12
+ PROJ.summary = 'Test::Unit Reporter (New) -- new output format for Test::Unit'
13
+ PROJ.authors = 'Tim Pease'
14
+ PROJ.email = 'tim.pease@gmail.com'
15
+ PROJ.url = 'http://codeforpeople.rubyforge.org/turn'
16
+ PROJ.description = paragraphs_of('README.txt', 1).join("\n\n")
17
+ PROJ.version = '0.4.0'
18
+
19
+ PROJ.rubyforge.name = 'codeforpeople'
20
+
21
+ PROJ.rdoc.exclude << '^lib/'
22
+ PROJ.rdoc.remote_dir = PROJ.name
23
+
24
+ # EOF
@@ -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.0 stable (2008-10-13)
data/bin/turn CHANGED
@@ -1,14 +1,4 @@
1
1
  #!/usr/bin/ruby
2
2
 
3
- RUBY = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
3
+ load 'turn/command.rb'
4
4
 
5
- begin
6
- require 'turn'
7
- Kernel.exec(RUBY, '-r', 'turn', *ARGV)
8
- rescue LoadError
9
- require 'rubygems'
10
- require 'turn'
11
- Kernel.exec(RUBY, '-rubygems', '-r', 'turn', *ARGV)
12
- end
13
-
14
- # EOF
@@ -1,21 +1,11 @@
1
- # $Id: turn.rb 55 2006-11-19 20:37:40Z tpease $
2
-
3
1
  require 'test/unit/ui/console/testrunner'
4
- begin
5
- require 'facets/ansicode'
6
- rescue LoadError
7
- begin
8
- require 'rubygems'
9
- require 'facets/ansicode'
10
- rescue LoadError
11
- end
12
- end
13
-
2
+ require 'turn/colorize'
14
3
 
15
4
  module ::Test::Unit
16
5
  module UI
17
6
  module Console
18
7
  class TestRunner
8
+ include Turn::Colorize
19
9
 
20
10
  alias :t_attach_to_mediator :attach_to_mediator
21
11
  def attach_to_mediator
@@ -40,8 +30,8 @@ module Console
40
30
 
41
31
  bar = '=' * 78
42
32
  if COLORIZE
43
- bar = if pass == total then ::Console::ANSICode.green bar
44
- else ::Console::ANSICode.red bar end
33
+ bar = if pass == total then ::ANSICode.green bar
34
+ else ::ANSICode.red bar end
45
35
  end
46
36
 
47
37
  @io.puts bar
@@ -60,7 +50,7 @@ module Console
60
50
  end
61
51
 
62
52
  def t_test_finished( name )
63
- @io.puts PASS unless @t_fault
53
+ @io.puts " #{PASS}" unless @t_fault
64
54
  @t_fault = false
65
55
  end
66
56
 
@@ -73,26 +63,15 @@ module Console
73
63
  @io.puts ERROR
74
64
  msg << fault.to_s.split("\n")[2..-1].join("\n\t")
75
65
  when ::Test::Unit::Failure
76
- @io.puts FAIL
66
+ @io.puts " #{FAIL}"
77
67
  msg << fault.location[0] << "\n\t"
78
68
  msg << fault.message.gsub("\n","\n\t")
79
69
  end
80
70
 
81
- msg = ::Console::ANSICode.magenta msg if COLORIZE
71
+ msg = ::ANSICode.magenta msg if COLORIZE
82
72
  @io.puts msg
83
73
  end
84
74
 
85
- COLORIZE = defined?(::Console::ANSICode) && ENV.has_key?('TERM')
86
- if COLORIZE
87
- PASS = ::Console::ANSICode.green ' PASS'
88
- FAIL = ::Console::ANSICode.red ' FAIL'
89
- ERROR = ::Console::ANSICode.white(
90
- ::Console::ANSICode.on_red('ERROR'))
91
- else
92
- PASS = " PASS"
93
- FAIL = " FAIL"
94
- ERROR = "ERROR"
95
- end
96
75
  end
97
76
  end
98
77
  end
@@ -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
@@ -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
+