turn 0.8.3 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +1 -8
- data/History.txt +16 -0
- data/{license/GPLv2.txt → LICENSE-GPL2.txt} +0 -0
- data/{license/MIT-LICENSE.txt → LICENSE-MIT.txt} +0 -0
- data/{license/RUBY-LICENSE.txt → LICENSE-RUBY.txt} +0 -0
- data/{NOTICE.txt → LICENSE.txt} +1 -1
- data/README.md +26 -0
- data/Rakefile +1 -0
- data/Version.txt +1 -1
- data/bin/turn +7 -1
- data/lib/turn.rb +20 -11
- data/lib/turn/autoload.rb +1 -1
- data/lib/turn/autorun.rb +8 -0
- data/lib/turn/bin.rb +7 -1
- data/lib/turn/colorize.rb +26 -10
- data/lib/turn/command.rb +32 -13
- data/lib/turn/components.rb +4 -0
- data/lib/turn/components/case.rb +1 -1
- data/lib/turn/components/suite.rb +9 -3
- data/lib/turn/configuration.rb +197 -0
- data/lib/turn/controller.rb +15 -206
- data/lib/turn/{autorun/minitest.rb → minitest.rb} +7 -3
- data/lib/turn/reporter.rb +65 -10
- data/lib/turn/reporters/cue_reporter.rb +13 -2
- data/lib/turn/reporters/dot_reporter.rb +12 -11
- data/lib/turn/reporters/outline_reporter.rb +57 -36
- data/lib/turn/reporters/pretty_reporter.rb +37 -24
- data/lib/turn/reporters/progress_reporter.rb +64 -26
- data/lib/turn/runners/minirunner.rb +7 -32
- data/lib/turn/testunit.rb +5 -0
- data/test/helper.rb +11 -2
- data/test/test_framework.rb +39 -30
- data/test/test_runners.rb +9 -7
- data/{demo → try}/test_autorun_minitest.rb +0 -0
- data/{demo → try}/test_autorun_testunit.rb +0 -0
- data/{demo → try}/test_counts.rb +0 -0
- data/{demo → try}/test_sample.rb +0 -0
- data/{demo → try}/test_sample2.rb +0 -0
- data/turn.gemspec +2 -2
- metadata +42 -29
- data/lib/turn/autorun/minitest0.rb +0 -163
- data/lib/turn/autorun/testunit.rb +0 -9
- data/lib/turn/autorun/testunit0.rb +0 -116
@@ -3,7 +3,7 @@ require 'stringio'
|
|
3
3
|
|
4
4
|
module Turn
|
5
5
|
|
6
|
-
#
|
6
|
+
# Outline Reporter is Turn's Original.
|
7
7
|
#
|
8
8
|
#--
|
9
9
|
# TODO: Should we fit reporter output to width of console?
|
@@ -11,15 +11,23 @@ module Turn
|
|
11
11
|
#++
|
12
12
|
class OutlineReporter < Reporter
|
13
13
|
|
14
|
+
#
|
15
|
+
TAB_SIZE = 8
|
16
|
+
|
14
17
|
#
|
15
18
|
def start_suite(suite)
|
16
|
-
@suite
|
17
|
-
@time
|
19
|
+
@suite = suite
|
20
|
+
@time = Time.now
|
18
21
|
@stdout = StringIO.new
|
19
22
|
@stderr = StringIO.new
|
20
|
-
#files
|
21
|
-
|
22
|
-
|
23
|
+
#files = suite.collect{ |s| s.file }.join(' ')
|
24
|
+
puts '=' * 78
|
25
|
+
if suite.seed
|
26
|
+
io.puts "SUITE #{suite.name} (SEED #{suite.seed})"
|
27
|
+
else
|
28
|
+
io.puts "SUITE #{suite.name}"
|
29
|
+
end
|
30
|
+
puts '=' * 78
|
23
31
|
end
|
24
32
|
|
25
33
|
#
|
@@ -34,13 +42,9 @@ module Turn
|
|
34
42
|
# io.puts(test.file)
|
35
43
|
#end
|
36
44
|
|
37
|
-
name =
|
38
|
-
" #{test.name.gsub("test_", "").gsub(/_/, " ")}"
|
39
|
-
else
|
40
|
-
" #{test.name}"
|
41
|
-
end
|
45
|
+
name = naturalized_name(test)
|
42
46
|
|
43
|
-
io.print " %-
|
47
|
+
io.print " %-57s" % name
|
44
48
|
|
45
49
|
@stdout.rewind
|
46
50
|
@stderr.rewind
|
@@ -51,43 +55,60 @@ module Turn
|
|
51
55
|
|
52
56
|
#
|
53
57
|
def pass(message=nil)
|
54
|
-
io.puts "
|
58
|
+
io.puts " %s %s" % [ticktock, PASS]
|
59
|
+
|
55
60
|
if message
|
56
61
|
message = Colorize.magenta(message)
|
57
|
-
message = message.to_s.tabto(
|
62
|
+
message = message.to_s.tabto(TAB_SIZE)
|
58
63
|
io.puts(message)
|
59
64
|
end
|
60
65
|
end
|
61
66
|
|
62
67
|
#
|
63
68
|
def fail(assertion)
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
69
|
+
io.puts " %s %s" % [ticktock, FAIL]
|
70
|
+
|
71
|
+
message = []
|
72
|
+
message << Colorize.bold(assertion.message.to_s)
|
73
|
+
message << "Assertion at:"
|
74
|
+
message << clean_backtrace(assertion.backtrace).join("\n")
|
75
|
+
message = message.join("\n")
|
76
|
+
|
77
|
+
io.puts(message.tabto(TAB_SIZE))
|
78
|
+
|
79
|
+
#unless backtrace.empty?
|
80
|
+
# io.puts "Assertion at".tabto(TAB_SIZE)
|
81
|
+
# io.puts backtrace.map{|l| l.tabto(TAB_SIZE)}.join("\n")
|
82
|
+
#end
|
83
|
+
|
84
|
+
#io.puts "STDERR:".tabto(TAB_SIZE)
|
79
85
|
show_captured_output
|
80
86
|
end
|
81
87
|
|
82
88
|
#
|
83
89
|
def error(exception)
|
84
|
-
|
85
|
-
|
86
|
-
message =
|
87
|
-
|
90
|
+
io.puts " %s %s" % [ticktock, ERROR]
|
91
|
+
|
92
|
+
message = []
|
93
|
+
message << Colorize.bold(exception.message)
|
94
|
+
message << "Exception `#{exception.class}' at:"
|
95
|
+
message << clean_backtrace(exception.backtrace).join("\n")
|
96
|
+
message = message.join("\n")
|
97
|
+
|
98
|
+
io.puts(message.tabto(TAB_SIZE))
|
99
|
+
|
100
|
+
#io.puts "STDERR:".tabto(TAB_SIZE)
|
101
|
+
show_captured_output
|
102
|
+
end
|
103
|
+
|
104
|
+
#
|
105
|
+
def skip(exception)
|
106
|
+
io.puts " %s %s" % [ticktock, SKIP]
|
107
|
+
|
108
|
+
message = exception.message
|
109
|
+
|
88
110
|
io.puts(message.tabto(8))
|
89
|
-
|
90
|
-
io.puts(backtrace.tabto(8))
|
111
|
+
|
91
112
|
show_captured_output
|
92
113
|
end
|
93
114
|
|
@@ -129,7 +150,7 @@ module Turn
|
|
129
150
|
#def finish_case(kase)
|
130
151
|
#end
|
131
152
|
|
132
|
-
#
|
153
|
+
# TODO: pending (skip) counts
|
133
154
|
def finish_suite(suite)
|
134
155
|
total = suite.count_tests
|
135
156
|
failure = suite.count_failures
|
@@ -8,6 +8,9 @@ module Turn
|
|
8
8
|
#
|
9
9
|
PADDING_SIZE = 4
|
10
10
|
|
11
|
+
#
|
12
|
+
TAB_SIZE = 10
|
13
|
+
|
11
14
|
#
|
12
15
|
def start_suite(suite)
|
13
16
|
#old_sync, @@out.sync = @@out.sync, true if io.respond_to? :sync=
|
@@ -18,7 +21,7 @@ module Turn
|
|
18
21
|
#files = suite.collect{ |s| s.file }.join(' ')
|
19
22
|
io.puts "Loaded suite #{suite.name}"
|
20
23
|
#io.puts "Loaded suite #{$0.sub(/\.rb$/, '')}\nStarted"
|
21
|
-
io.puts "Started"
|
24
|
+
io.puts "Started (#{suite.seed})"
|
22
25
|
end
|
23
26
|
|
24
27
|
#
|
@@ -56,7 +59,7 @@ module Turn
|
|
56
59
|
end
|
57
60
|
|
58
61
|
#
|
59
|
-
def fail(assertion)
|
62
|
+
def fail(assertion, message=nil)
|
60
63
|
io.print pad_with_size("#{FAIL}")
|
61
64
|
io.print " #{@test}"
|
62
65
|
io.print " (%.2fs) " % (Time.now - @test_time)
|
@@ -64,53 +67,63 @@ module Turn
|
|
64
67
|
#message = assertion.location[0] + "\n" + assertion.message #.gsub("\n","\n")
|
65
68
|
#trace = MiniTest::filter_backtrace(report[:exception].backtrace).first
|
66
69
|
|
67
|
-
message
|
70
|
+
message ||= assertion.message
|
68
71
|
|
69
72
|
_trace = if assertion.respond_to?(:backtrace)
|
70
73
|
filter_backtrace(assertion.backtrace)
|
71
74
|
else
|
72
75
|
filter_backtrace(assertion.location).first
|
73
76
|
end
|
77
|
+
|
74
78
|
io.puts
|
75
|
-
tabsize = 10
|
76
79
|
#io.puts pad(message, tabsize)
|
77
|
-
io.puts message.tabto(
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
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")
|
84
|
+
|
82
85
|
#show_captured_output
|
83
86
|
end
|
84
87
|
|
85
88
|
#
|
86
|
-
def error(exception)
|
89
|
+
def error(exception, message=nil)
|
87
90
|
io.print pad_with_size("#{ERROR}")
|
88
91
|
io.print " #{@test}"
|
89
92
|
io.print " (%.2fs) " % (Time.now - @test_time)
|
90
93
|
|
91
94
|
#message = exception.to_s.split("\n")[2..-1].join("\n")
|
92
95
|
|
93
|
-
message
|
96
|
+
message ||= exception.message
|
94
97
|
|
95
98
|
_trace = if exception.respond_to?(:backtrace)
|
96
|
-
|
99
|
+
clean_backtrace(exception.backtrace)
|
97
100
|
else
|
98
|
-
|
101
|
+
clean_backtrace(exception.location)
|
99
102
|
end
|
100
|
-
|
103
|
+
|
101
104
|
io.puts
|
102
|
-
|
103
|
-
io.puts
|
104
|
-
io.puts trace.tabto(tabsize)
|
105
|
-
if @trace
|
106
|
-
io.puts _trace.map{|l| l.tabto(tabsize) }.join("\n")
|
107
|
-
end
|
105
|
+
io.puts message.tabto(TAB_SIZE)
|
106
|
+
io.puts _trace.map{|l| l.tabto(TAB_SIZE) }.join("\n")
|
108
107
|
end
|
109
108
|
|
110
|
-
#
|
111
|
-
|
112
|
-
|
113
|
-
|
109
|
+
#
|
110
|
+
def skip(exception, message=nil)
|
111
|
+
io.print pad_with_size("#{SKIP}")
|
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
|
114
127
|
|
115
128
|
#
|
116
129
|
def finish_test(test)
|
@@ -6,28 +6,39 @@ module Turn
|
|
6
6
|
#
|
7
7
|
class ProgressReporter < Reporter
|
8
8
|
|
9
|
+
def initialize(io, opts={})
|
10
|
+
super(io, opts)
|
11
|
+
@fails = Hash.new{|h,k|h[k]=[]}
|
12
|
+
@errors = Hash.new{|h,k|h[k]=[]}
|
13
|
+
@skips = Hash.new{|h,k|h[k]=[]}
|
14
|
+
end
|
15
|
+
|
9
16
|
def start_suite(suite)
|
10
17
|
@pbar = ::ANSI::Progressbar.new('Testing', suite.size)
|
11
18
|
@pbar.inc
|
12
19
|
end
|
13
20
|
|
14
|
-
|
15
|
-
|
21
|
+
def start_case(testcase)
|
22
|
+
@_current_case = testcase
|
23
|
+
end
|
16
24
|
|
17
25
|
#def start_test(test)
|
18
26
|
#end
|
19
27
|
|
20
28
|
#def pass(message=nil)
|
21
|
-
# #@pbar.inc
|
22
29
|
#end
|
23
30
|
|
24
|
-
|
25
|
-
|
26
|
-
|
31
|
+
def fail(assertion, message=nil)
|
32
|
+
@fails[@_current_case] << assertion
|
33
|
+
end
|
27
34
|
|
28
|
-
|
29
|
-
|
30
|
-
|
35
|
+
def error(exception, message=nil)
|
36
|
+
@errors[@_current_case] << exception
|
37
|
+
end
|
38
|
+
|
39
|
+
def skip(exception, message=nil)
|
40
|
+
@skips[@_current_case] << exception
|
41
|
+
end
|
31
42
|
|
32
43
|
def finish_case(kase)
|
33
44
|
@pbar.inc
|
@@ -42,13 +53,14 @@ module Turn
|
|
42
53
|
def post_report(suite)
|
43
54
|
tally = test_tally(suite)
|
44
55
|
|
45
|
-
width = suite.collect{ |tr| tr.name.size }.max
|
56
|
+
width = suite.collect{ |tr| tr.name.to_s.size }.max
|
46
57
|
|
47
58
|
headers = [ 'TESTCASE ', ' TESTS ', 'ASSERTIONS', ' FAILURES ', ' ERRORS ' ]
|
48
|
-
io.puts "\n%-#{width}s %10s %10s %10s %10s\n" % headers
|
59
|
+
io.puts "\n\n%-#{width}s %10s %10s %10s %10s\n" % headers
|
49
60
|
|
50
|
-
|
61
|
+
io.puts ("-" * (width + 50))
|
51
62
|
|
63
|
+
files = nil
|
52
64
|
suite.each do |testrun|
|
53
65
|
if testrun.files != [testrun.name] && testrun.files != files
|
54
66
|
label = testrun.files.join(' ')
|
@@ -61,27 +73,53 @@ module Turn
|
|
61
73
|
|
62
74
|
#puts("\n%i tests, %i assertions, %i failures, %i errors\n\n" % tally)
|
63
75
|
|
64
|
-
tally_line = "
|
65
|
-
tally_line << "%-#{width}s " % "TOTAL"
|
76
|
+
tally_line = ("-" * (width + 50))
|
77
|
+
tally_line << "\n%-#{width}s " % "TOTAL"
|
66
78
|
tally_line << "%10s %10s %10s %10s" % tally
|
67
79
|
|
68
|
-
io.puts(tally_line + "\n")
|
80
|
+
io.puts(tally_line + "\n\n\n")
|
69
81
|
|
70
|
-
|
71
|
-
|
82
|
+
io.puts "-- Failures --\n\n" unless @fails.empty?
|
83
|
+
|
84
|
+
@fails.each do |tc, cc|
|
85
|
+
cc.each do |e|
|
86
|
+
message = e.message.tabto(0).strip
|
87
|
+
message = Colorize.red(message)
|
88
|
+
message += "\n" + clean_backtrace(e.backtrace).join("\n")
|
89
|
+
io.puts(message+"\n\n")
|
90
|
+
end
|
91
|
+
io.puts
|
72
92
|
end
|
73
93
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
io.puts
|
94
|
+
io.puts "-- Errors --\n\n" unless @errors.empty?
|
95
|
+
|
96
|
+
@errors.each do |tc, cc|
|
97
|
+
cc.each do |e|
|
98
|
+
message = e.message.tabto(0).strip
|
99
|
+
message = Colorize.red(message)
|
100
|
+
message += "\n" + clean_backtrace(e.backtrace).join("\n")
|
101
|
+
io.puts(message+"\n\n")
|
83
102
|
end
|
103
|
+
io.puts
|
104
|
+
end
|
105
|
+
|
106
|
+
#fails = suite.select do |testrun|
|
107
|
+
# testrun.fail? || testrun.error?
|
84
108
|
#end
|
109
|
+
|
110
|
+
##if tally[2] != 0 or tally[3] != 0
|
111
|
+
# unless fails.empty? # or verbose?
|
112
|
+
# io.puts "\n\n-- Failures and Errors --\n\n"
|
113
|
+
# fails.uniq.each do |testrun|
|
114
|
+
# message = testrun.message.tabto(0).strip
|
115
|
+
# message = Colorize.red(message)
|
116
|
+
# # backtrace ?
|
117
|
+
# #message += clean_backtrace(testrun.exception.backtrace).join("\n")
|
118
|
+
# io.puts(message+"\n\n")
|
119
|
+
# end
|
120
|
+
# io.puts
|
121
|
+
# end
|
122
|
+
##end
|
85
123
|
end
|
86
124
|
|
87
125
|
private
|
@@ -40,8 +40,12 @@ module Turn
|
|
40
40
|
|
41
41
|
# Override #_run_suite to setup Turn.
|
42
42
|
def _run_suites suites, type
|
43
|
+
# Someone want to explain to me why these are fucking here?
|
44
|
+
suites = suites - [MiniTest::Spec, Test::Unit::TestCase]
|
45
|
+
|
43
46
|
@turn_suite = Turn::TestSuite.new(@turn_config.suite_name)
|
44
|
-
@turn_suite.size =
|
47
|
+
@turn_suite.size = suites.size #::MiniTest::Unit::TestCase.test_suites.size
|
48
|
+
@turn_suite.seed = ::MiniTest::Unit.runner.options[:seed]
|
45
49
|
|
46
50
|
turn_reporter.start_suite(@turn_suite)
|
47
51
|
|
@@ -101,8 +105,8 @@ module Turn
|
|
101
105
|
def puke(klass, meth, err)
|
102
106
|
case err
|
103
107
|
when MiniTest::Skip
|
104
|
-
@turn_test.skip!
|
105
|
-
turn_reporter.skip
|
108
|
+
@turn_test.skip!(err)
|
109
|
+
turn_reporter.skip(err)
|
106
110
|
when MiniTest::Assertion
|
107
111
|
@turn_test.fail!(err)
|
108
112
|
turn_reporter.fail(err)
|
@@ -113,35 +117,6 @@ module Turn
|
|
113
117
|
super(klass, meth, err)
|
114
118
|
end
|
115
119
|
|
116
|
-
# To maintain compatibility with old versions of MiniTest.
|
117
|
-
#
|
118
|
-
# Hey, Ryan Davis wrote this code!
|
119
|
-
if ::MiniTest::Unit::VERSION < '2.0'
|
120
|
-
#attr_accessor :options
|
121
|
-
|
122
|
-
#
|
123
|
-
def run(args=[])
|
124
|
-
suites = ::MiniTest::Unit::TestCase.test_suites
|
125
|
-
return if suites.empty?
|
126
|
-
|
127
|
-
@test_count, @assertion_count = 0, 0
|
128
|
-
sync = @@out.respond_to? :"sync=" # stupid emacs
|
129
|
-
old_sync, @@out.sync = @@out.sync, true if sync
|
130
|
-
|
131
|
-
results = _run_suites suites, :test #type
|
132
|
-
|
133
|
-
@test_count = results.inject(0) { |sum, (tc, _)| sum + tc }
|
134
|
-
@assertion_count = results.inject(0) { |sum, (_, ac)| sum + ac }
|
135
|
-
|
136
|
-
@@out.sync = old_sync if sync
|
137
|
-
|
138
|
-
return failures + errors if @test_count > 0 # or return nil...
|
139
|
-
rescue Interrupt
|
140
|
-
abort 'Interrupted'
|
141
|
-
end
|
142
|
-
|
143
|
-
end
|
144
|
-
|
145
120
|
end
|
146
121
|
|
147
122
|
end
|