turn 0.8.2 → 0.9.7

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.
Files changed (52) hide show
  1. data/CONTRIBUTING.md +40 -0
  2. data/History.txt +81 -1
  3. data/Index.rb +34 -0
  4. data/LICENSE.txt +21 -0
  5. data/NOTICE.md +12 -0
  6. data/README.md +176 -0
  7. data/Release.txt +21 -1
  8. data/Version.txt +1 -1
  9. data/bin/turn +8 -2
  10. data/lib/turn/autoload.rb +6 -0
  11. data/lib/turn/autorun.rb +4 -0
  12. data/lib/turn/bin.rb +8 -2
  13. data/lib/turn/colorize.rb +50 -19
  14. data/lib/turn/command.rb +102 -39
  15. data/lib/turn/components/case.rb +7 -2
  16. data/lib/turn/components/method.rb +13 -2
  17. data/lib/turn/components/suite.rb +15 -6
  18. data/lib/turn/components.rb +4 -0
  19. data/lib/turn/configuration.rb +271 -0
  20. data/lib/turn/controller.rb +18 -176
  21. data/lib/turn/decorators/topten_decorator.rb +67 -0
  22. data/lib/turn/minitest.rb +25 -0
  23. data/lib/turn/reporter.rb +75 -13
  24. data/lib/turn/reporters/cue_reporter.rb +27 -11
  25. data/lib/turn/reporters/dot_reporter.rb +24 -28
  26. data/lib/turn/reporters/outline_reporter.rb +76 -39
  27. data/lib/turn/reporters/pretty_reporter.rb +110 -129
  28. data/lib/turn/reporters/progress_reporter.rb +70 -33
  29. data/lib/turn/runners/crossrunner.rb +2 -2
  30. data/lib/turn/runners/isorunner.rb +12 -10
  31. data/lib/turn/runners/minirunner.rb +51 -81
  32. data/lib/turn/runners/solorunner.rb +0 -1
  33. data/lib/turn/runners/testrunner.rb +12 -15
  34. data/lib/turn/testunit.rb +24 -0
  35. data/lib/turn/version.rb +1 -1
  36. data/lib/turn.rb +10 -15
  37. data/test/helper.rb +81 -5
  38. data/test/reporter_test.rb +35 -0
  39. data/test/test_framework.rb +81 -38
  40. data/test/test_reporters.rb +14 -14
  41. data/test/test_runners.rb +57 -19
  42. data/{demo → try}/test_autorun_minitest.rb +5 -4
  43. data/{demo → try}/test_autorun_testunit.rb +1 -2
  44. metadata +135 -112
  45. data/README.txt +0 -116
  46. data/Rakefile +0 -39
  47. data/lib/turn/autorun/minitest.rb +0 -173
  48. data/lib/turn/autorun/testunit.rb +0 -116
  49. data/turn.gemspec +0 -49
  50. /data/{demo → try}/test_counts.rb +0 -0
  51. /data/{demo → try}/test_sample.rb +0 -0
  52. /data/{demo → try}/test_sample2.rb +0 -0
data/README.txt DELETED
@@ -1,116 +0,0 @@
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 'ansi' 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
- Turn can be using from the command-line or via require. The command-line tool
44
- offers additional options for how one runs tests.
45
-
46
- === Command Line
47
-
48
- You can use the *turn* executable in place of the *ruby* interpreter.
49
-
50
- turn -Ilib test/test_all.rb
51
-
52
- This will invoke the ruby interpreter and automatically require the turn
53
- formatting library. All command line arguments are passed "as is" to the
54
- ruby interpreter.
55
-
56
- To use the solo runner.
57
-
58
- turn --solo -Ilib test/
59
-
60
- This will run all tests in the test/ directory in a separate process.
61
- Likewise for the cross runner.
62
-
63
- turn --cross -Ilib test/
64
-
65
- This will run every pairing of tests in a separate process.
66
-
67
- === Require
68
-
69
- Simply require the TURN package from within your test suite.
70
-
71
- require 'turn'
72
-
73
- This will configure Test::Unit to use TURN formatting for displaying test
74
- restuls. A better line to use, though, is the following:
75
-
76
- begin; require 'turn'; rescue LoadError; end
77
-
78
- When you distribute your code, the test suite can be run without requiring
79
- the end user to install the TURN package.
80
-
81
- For a Rails application, put the require line into the 'test/test_helper.rb'
82
- scipt. Now your Rails tests will use TURN formatting.
83
-
84
- == REQUIREMENTS:
85
-
86
- * ansi 1.1+ (for colorized output and progressbar output mode)
87
-
88
- == INSTALL:
89
-
90
- * sudo gem install turn
91
-
92
- == LICENSE:
93
-
94
- MIT License
95
-
96
- Copyright (c) 2006-2008
97
-
98
- Permission is hereby granted, free of charge, to any person obtaining
99
- a copy of this software and associated documentation files (the
100
- 'Software'), to deal in the Software without restriction, including
101
- without limitation the rights to use, copy, modify, merge, publish,
102
- distribute, sublicense, and/or sell copies of the Software, and to
103
- permit persons to whom the Software is furnished to do so, subject to
104
- the following conditions:
105
-
106
- The above copyright notice and this permission notice shall be
107
- included in all copies or substantial portions of the Software.
108
-
109
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
110
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
111
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
112
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
113
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
114
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
115
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
116
-
data/Rakefile DELETED
@@ -1,39 +0,0 @@
1
- begin
2
- require 'bones'
3
- rescue LoadError
4
- abort '### please install the "bones" gem ###'
5
- end
6
-
7
- task :default => 'test'
8
-
9
- Bones {
10
- name 'turn'
11
- summary 'Test::Unit Reporter (New) -- new output format for Test::Unit'
12
- authors 'Tim Pease'
13
- email 'tim.pease@gmail.com'
14
- url 'http://gemcutter.org/gems/turn'
15
- version File.read('Version.txt').strip
16
- ignore_file '.gitignore'
17
-
18
- exclude << '^work'
19
- rdoc.exclude << '^lib'
20
-
21
- use_gmail
22
-
23
- depend_on 'ansi'
24
- depend_on 'bones-git', :development => true
25
- }
26
-
27
- # Might be useful one day, so we'll leave it here.
28
- #
29
- # Rake::TaskManager.class_eval do
30
- # def remove_task(task_name)
31
- # @tasks.delete(task_name.to_s)
32
- # end
33
- # end
34
- #
35
- # def remove_task(task_name)
36
- # Rake.application.remove_task(task_name)
37
- # end
38
-
39
- # EOF
@@ -1,173 +0,0 @@
1
- require 'minitest/unit'
2
- require 'minitest/spec'
3
- #require 'rubygems'
4
- require 'ansi'
5
-
6
- class MiniTest::Unit
7
- include ANSI::Code
8
-
9
- PADDING_SIZE = 4
10
-
11
- @@use_natural_language_case_names = false
12
- def self.use_natural_language_case_names=(boolean)
13
- @use_natural_language_case_names = boolean
14
- end
15
-
16
- def self.use_natural_language_case_names?
17
- @use_natural_language_case_names
18
- end
19
-
20
-
21
- def run(args = [])
22
- @verbose = true
23
-
24
- filter = if args.first =~ /^(-n|--name)$/ then
25
- args.shift
26
- arg = args.shift
27
- if arg =~ /\/(.*)\//
28
- Regexp.new($1)
29
- elsif MiniTest::Unit.use_natural_language_case_names?
30
- # Turn 'sample error1' into 'test_sample_error1'
31
- arg[0..4] == "test_" ? arg.gsub(" ", "_") : "test_" + arg.gsub(" ", "_")
32
- else
33
- arg
34
- end
35
- else
36
- /./ # anything - ^test_ already filtered by #tests
37
- end
38
-
39
- @@out.puts "Loaded suite #{$0.sub(/\.rb$/, '')}\nStarted"
40
-
41
- start = Time.now
42
- run_test_suites filter
43
-
44
- @@out.puts
45
- @@out.puts "Finished in #{'%.6f' % (Time.now - start)} seconds."
46
-
47
- @@out.puts
48
-
49
- @@out.print "%d tests, " % test_count
50
- @@out.print "%d assertions, " % assertion_count
51
- @@out.print red { "%d failures, " % failures }
52
- @@out.print yellow { "%d errors, " % errors }
53
- @@out.puts cyan { "%d skips" % skips}
54
-
55
- return failures + errors if @test_count > 0 # or return nil...
56
- end
57
-
58
- # Overwrite #run_test_suites so that it prints out reports
59
- # as errors are generated.
60
- def run_test_suites(filter = /./)
61
- @test_count, @assertion_count = 0, 0
62
- old_sync, @@out.sync = @@out.sync, true if @@out.respond_to? :sync=
63
- TestCase.test_suites.each do |suite|
64
- test_cases = suite.test_methods.grep(filter)
65
- if test_cases.size > 0
66
- @@out.print "\n#{suite}:\n"
67
- end
68
-
69
- test_cases.each do |test|
70
- inst = suite.new test
71
- inst._assertions = 0
72
-
73
- t = Time.now
74
-
75
- @broken = nil
76
-
77
- @@out.print(case inst.run(self)
78
- when :pass
79
- @broken = false
80
- green { pad_with_size "PASS" }
81
- when :error
82
- @broken = true
83
- yellow { pad_with_size "ERROR" }
84
- when :fail
85
- @broken = true
86
- red { pad_with_size "FAIL" }
87
- when :skip
88
- @broken = false
89
- cyan { pad_with_size "SKIP" }
90
- end)
91
-
92
-
93
- @@out.print MiniTest::Unit.use_natural_language_case_names? ?
94
- " #{test.gsub("test_", "").gsub(/_/, " ")}" : " #{test}"
95
- @@out.print " (%.2fs) " % (Time.now - t)
96
-
97
- if @broken
98
- @@out.puts
99
-
100
- report = @report.last
101
- @@out.puts pad(report[:message], 10)
102
- trace = MiniTest::filter_backtrace(report[:exception].backtrace).first
103
- @@out.print pad(trace, 10)
104
-
105
- @@out.puts
106
- end
107
-
108
- @@out.puts
109
- @test_count += 1
110
- @assertion_count += inst._assertions
111
- end
112
- end
113
- @@out.sync = old_sync if @@out.respond_to? :sync=
114
- [@test_count, @assertion_count]
115
- end
116
-
117
- def pad(str, size=PADDING_SIZE)
118
- " " * size + str
119
- end
120
-
121
- def pad_with_size(str)
122
- pad("%5s" % str)
123
- end
124
-
125
- # Overwrite #puke method so that is stores a hash
126
- # with :message and :exception keys.
127
- def puke(klass, meth, e)
128
- result = nil
129
- msg = case e
130
- when MiniTest::Skip
131
- @skips += 1
132
- result = :skip
133
- e.message
134
- when MiniTest::Assertion
135
- @failures += 1
136
- result = :fail
137
- e.message
138
- else
139
- @errors += 1
140
- result = :error
141
- "#{e.class}: #{e.message}\n"
142
- end
143
-
144
- @report << {:message => msg, :exception => e}
145
- result
146
- end
147
-
148
-
149
- class TestCase
150
- # Overwrite #run method so that is uses symbols
151
- # as return values rather than characters.
152
- def run(runner)
153
- result = :pass
154
- begin
155
- @passed = nil
156
- self.setup
157
- self.__send__ self.__name__
158
- @passed = true
159
- rescue Exception => e
160
- @passed = false
161
- result = runner.puke(self.class, self.__name__, e)
162
- ensure
163
- begin
164
- self.teardown
165
- rescue Exception => e
166
- result = runner.puke(self.class, self.__name__, e)
167
- end
168
- end
169
- result
170
- end
171
- end
172
- end
173
-
@@ -1,116 +0,0 @@
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
- # 1.x of test/unut used @io, where as 2.x uses @output.
11
- def turn_out
12
- @turn_out ||= (@io || @output)
13
- end
14
-
15
- alias :t_attach_to_mediator :attach_to_mediator
16
- def attach_to_mediator
17
- @mediator.add_listener(TestRunnerMediator::STARTED, &method(:t_started))
18
- @mediator.add_listener(TestRunnerMediator::FINISHED, &method(:t_finished))
19
- @mediator.add_listener(TestCase::STARTED, &method(:t_test_started))
20
- @mediator.add_listener(TestCase::FINISHED, &method(:t_test_finished))
21
- @mediator.add_listener(TestResult::FAULT, &method(:t_fault))
22
- turn_out.sync = true
23
- @t_cur_file, @t_fault = nil
24
- end
25
-
26
- def t_started( result )
27
- @t_result = result
28
- end
29
-
30
- def t_finished( elapsed_time )
31
- failure = @t_result.failure_count
32
- error = @t_result.error_count
33
- total = @t_result.run_count
34
- pass = total - failure - error
35
-
36
- bar = '=' * 78
37
- if COLORIZE
38
- bar = if pass == total then ::ANSI::Code.green{bar}
39
- else ::ANSI::Code.red{bar} end
40
- end
41
-
42
- turn_out.puts bar
43
- turn_out.puts " pass: %d, fail: %d, error: %d" % [pass, failure, error]
44
- turn_out.puts " total: %d tests with %d assertions in #{elapsed_time} seconds" % [total, @t_result.assertion_count]
45
- turn_out.puts bar
46
- end
47
-
48
- def t_test_started( name )
49
- method, file = name.scan(%r/^([^\(]+)\(([^\)]+)\)/o).flatten!
50
- if @t_cur_file != file
51
- @t_cur_file = file
52
- file = COLORIZE ? ::ANSI::Code.yellow{file} : file
53
- turn_out.puts file
54
- end
55
- turn_out.print " %-69s" % method
56
- end
57
-
58
- def t_test_finished( name )
59
- turn_out.puts " #{PASS}" unless @t_fault
60
- @t_fault = false
61
- end
62
-
63
- def t_fault( fault )
64
- @t_fault = true
65
- msg = "\t"
66
-
67
- case fault
68
- when ::Test::Unit::Error
69
- turn_out.puts ERROR
70
- msg << fault.to_s.split("\n")[2..-1].join("\n\t")
71
- when ::Test::Unit::Failure
72
- test_name = underscore(fault.test_name.match(/\((.*)\)/)[1])
73
- better_location = fault.location.detect{|line|line.include?(test_name)} || fault.location[0]
74
- turn_out.puts " #{FAIL}"
75
- msg << better_location.to_s << "\n\t"
76
- msg << fault.message.gsub("\n","\n\t")
77
- end
78
-
79
- msg = ::ANSI::Code.magenta{msg} if COLORIZE
80
- turn_out.puts msg
81
- end
82
-
83
- private
84
-
85
- # Taken from ActiveSupport::Inflector
86
- def underscore(camel_cased_word)
87
- word = camel_cased_word.to_s.dup
88
- word.gsub!(/::/, '/')
89
- word.gsub!(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
90
- word.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
91
- word.tr!("-", "_")
92
- word.downcase!
93
- word
94
- end
95
-
96
- def setup_mediator
97
- @mediator = create_mediator(@suite)
98
- suite_name = @suite.to_s
99
- if ( @suite.kind_of?(Module) )
100
- suite_name = @suite.name
101
- end
102
- msg = rails? ? "\n" : "Loaded suite #{suite_name}" #always same in rails so scrap it
103
- output(msg)
104
- end
105
-
106
- def rails?
107
- $:.to_s.include? "rails"
108
- end
109
-
110
-
111
- end
112
- end
113
- end
114
- end
115
-
116
- # EOF
data/turn.gemspec DELETED
@@ -1,49 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
-
3
- Gem::Specification.new do |s|
4
- s.name = %q{turn}
5
- s.version = "0.8.1"
6
-
7
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
- s.authors = ["Tim Pease"]
9
- s.date = %q{2010-09-09}
10
- s.default_executable = %q{turn}
11
- s.description = %q{TURN is a new way to view Test::Unit results. With longer running tests, it
12
- can be very frustrating to see a failure (....F...) and then have to wait till
13
- all the tests finish before you can see what the exact failure was. TURN
14
- displays each test on a separate line with failures being displayed
15
- immediately instead of at the end of the tests.
16
-
17
- If you have the 'ansi' gem installed, then TURN output will be displayed in
18
- wonderful technicolor (but only if your terminal supports ANSI color codes).
19
- Well, the only colors are green and red, but that is still color.}
20
- s.email = %q{tim.pease@gmail.com}
21
- s.executables = ["turn"]
22
- s.extra_rdoc_files = ["History.txt", "README.txt", "Release.txt", "Version.txt", "bin/turn"]
23
- s.files = ["History.txt", "README.txt", "Rakefile", "Release.txt", "Version.txt", "bin/turn", "demo/test_autorun_minitest.rb", "demo/test_autorun_testunit.rb", "demo/test_sample.rb", "demo/test_sample2.rb", "lib/turn.rb", "lib/turn/autorun/minitest.rb", "lib/turn/autorun/testunit.rb", "lib/turn/bin.rb", "lib/turn/colorize.rb", "lib/turn/command.rb", "lib/turn/components/case.rb", "lib/turn/components/method.rb", "lib/turn/components/suite.rb", "lib/turn/controller.rb", "lib/turn/core_ext.rb", "lib/turn/reporter.rb", "lib/turn/reporters/cue_reporter.rb", "lib/turn/reporters/dot_reporter.rb", "lib/turn/reporters/marshal_reporter.rb", "lib/turn/reporters/outline_reporter.rb", "lib/turn/reporters/pretty_reporter.rb", "lib/turn/reporters/progress_reporter.rb", "lib/turn/runners/crossrunner.rb", "lib/turn/runners/isorunner.rb", "lib/turn/runners/loadrunner.rb", "lib/turn/runners/minirunner.rb", "lib/turn/runners/solorunner.rb", "lib/turn/runners/testrunner.rb", "test/helper.rb", "test/runner", "test/test_framework.rb", "test/test_reporters.rb", "test/test_runners.rb"]
24
- s.homepage = %q{http://gemcutter.org/gems/turn}
25
- s.rdoc_options = ["--main", "README.txt"]
26
- s.require_paths = ["lib"]
27
- s.rubyforge_project = %q{codeforpeople}
28
- s.rubygems_version = %q{1.5.2}
29
- s.summary = %q{Test::Unit Reporter (New) -- new output format for Test::Unit}
30
- s.test_files = ["test/test_framework.rb", "test/test_reporters.rb", "test/test_runners.rb"]
31
-
32
- if s.respond_to? :specification_version then
33
- s.specification_version = 3
34
-
35
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
36
- s.add_runtime_dependency(%q<ansi>, [">= 1.2.2"])
37
- s.add_development_dependency(%q<bones-git>, [">= 1.2.0"])
38
- s.add_development_dependency(%q<bones>, [">= 3.4.7"])
39
- else
40
- s.add_dependency(%q<ansi>, [">= 1.2.2"])
41
- s.add_dependency(%q<bones-git>, [">= 1.2.0"])
42
- s.add_dependency(%q<bones>, [">= 3.4.7"])
43
- end
44
- else
45
- s.add_dependency(%q<ansi>, [">= 1.2.2"])
46
- s.add_dependency(%q<bones-git>, [">= 1.2.0"])
47
- s.add_dependency(%q<bones>, [">= 3.4.7"])
48
- end
49
- end
File without changes
File without changes
File without changes