minitap 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.index +2 -2
- data/HISTORY.md +12 -1
- data/README.md +1 -1
- data/lib/minitap.rb +0 -660
- metadata +2 -4
- data/lib/minitap/tapj.rb +0 -5
- data/lib/minitap/tapy.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a1aac6d60ba24d1f8587c4697194bb57f3babb1
|
4
|
+
data.tar.gz: 7c697b1e323b760f78d257714b6d0b619b7150d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c8433a7a7e624f2f6b96e18edff3bd6dc7a0a8ad725983d61a859d0379e85360c4363adf7dcb86b93bfb98daae3d95f20a05d9f200328e77a68a4d401e04af5
|
7
|
+
data.tar.gz: daeac831863b03bb58500d18a1d0d52c6aded6ab6e27d55c887bbc6801b3da0ca315e96d0e39df82643022188a52b8df1ee5a587643573129d8a846b73c5ef07
|
data/.index
CHANGED
data/HISTORY.md
CHANGED
@@ -1,12 +1,23 @@
|
|
1
1
|
# RELEASE HISTORY
|
2
2
|
|
3
|
+
## 0.5.1 | 2013-11-16
|
4
|
+
|
5
|
+
This release simply removes all the remaing v4 code that
|
6
|
+
is no longer needed to work with Minitest 5. This also
|
7
|
+
fixes an issue Minitap has with working with Rails 4.
|
8
|
+
|
9
|
+
Changes:
|
10
|
+
|
11
|
+
* Remove all vestigial v4 code.
|
12
|
+
|
13
|
+
|
3
14
|
## 0.5.0 | 2013-11-15
|
4
15
|
|
5
16
|
The release adds support for MiniTest 5. Minitest completely
|
6
17
|
changes the way custom reporters are handled so this release
|
7
18
|
includes extensive new code. Note that this version is also
|
8
19
|
no longer intended for use with Minitest 4 or older. If you
|
9
|
-
are using Minitest 4, please use Minitap 4.x as well.
|
20
|
+
are using Minitest 4, please use Minitap 0.4.x as well.
|
10
21
|
|
11
22
|
Changes:
|
12
23
|
|
data/README.md
CHANGED
@@ -58,7 +58,7 @@ If you are still using MiniTest 4.x you will need to use Minitap version 4.x
|
|
58
58
|
as well. In your dependencies be sure to specify this version. For example in
|
59
59
|
your Gemfile:
|
60
60
|
|
61
|
-
gem "minitap", "~> 4.0"
|
61
|
+
gem "minitap", "~> 0.4.0"
|
62
62
|
|
63
63
|
For Minitest 4 and and older, custom report formats are set by assigning
|
64
64
|
the `MiniTest::Unit.runner` to an instance of a custom runner class.
|
data/lib/minitap.rb
CHANGED
@@ -1,660 +0,0 @@
|
|
1
|
-
# MiniTest adaptor for tapout.
|
2
|
-
|
3
|
-
# Have to make sure the latest version of minitest is used.
|
4
|
-
begin; gem 'minitest'; rescue; end
|
5
|
-
|
6
|
-
require 'minitest/unit'
|
7
|
-
require 'minitap/ignore_callers'
|
8
|
-
require 'stringio'
|
9
|
-
|
10
|
-
# Becuase of some wierdness in MiniTest
|
11
|
-
#debug, $DEBUG = $DEBUG, false
|
12
|
-
#require 'minitest/unit'
|
13
|
-
#$DEBUG = debug
|
14
|
-
|
15
|
-
module MiniTest
|
16
|
-
|
17
|
-
##
|
18
|
-
# Base class for TapY and TapJ runners.
|
19
|
-
#
|
20
|
-
# Based upon Alexander Kern's MiniTest-Reporters (MIT License).
|
21
|
-
# @see https://github.com/CapnKernul/minitest-reporters
|
22
|
-
#
|
23
|
-
class MiniTap < ::MiniTest::Unit
|
24
|
-
|
25
|
-
# TAP-Y/J Revision
|
26
|
-
REVISION = 4
|
27
|
-
|
28
|
-
# Backtrace patterns to be omitted.
|
29
|
-
IGNORE_CALLERS = $RUBY_IGNORE_CALLERS
|
30
|
-
|
31
|
-
# Test results.
|
32
|
-
attr_reader :test_results
|
33
|
-
|
34
|
-
attr_accessor :suites_start_time
|
35
|
-
attr_accessor :suite_start_time
|
36
|
-
attr_accessor :test_start_time
|
37
|
-
|
38
|
-
# Initialize new MiniTap MiniTest runner.
|
39
|
-
def initialize
|
40
|
-
super
|
41
|
-
|
42
|
-
@_stdout = ''
|
43
|
-
@_stderr = ''
|
44
|
-
|
45
|
-
@test_results = {}
|
46
|
-
#self.assertion_count = 0
|
47
|
-
@_source_cache = {}
|
48
|
-
end
|
49
|
-
|
50
|
-
def _run_suites(suites, type)
|
51
|
-
#output.puts "# Run options: #{@help}"
|
52
|
-
|
53
|
-
@suites_start_time = Time.now
|
54
|
-
count_tests!(suites, type)
|
55
|
-
trigger_callback(:before_suites, suites, type)
|
56
|
-
super(suites, type)
|
57
|
-
ensure
|
58
|
-
trigger_callback(:after_suites, suites, type)
|
59
|
-
end
|
60
|
-
|
61
|
-
def _run_suite(suite, type)
|
62
|
-
# The only reason this is here is b/c MiniTest wil try to run
|
63
|
-
# base classes like `MiniTest::Spec`. So to prevent that,
|
64
|
-
# if there are no tests to run, we don't bother to process
|
65
|
-
# the "suite" at all.
|
66
|
-
@_suite_tests = suite.send("#{type}_methods")
|
67
|
-
return [0,0] if @_suite_tests.empty?
|
68
|
-
|
69
|
-
begin
|
70
|
-
@suite_start_time = Time.now
|
71
|
-
trigger_callback(:before_suite, suite)
|
72
|
-
|
73
|
-
super_result = nil
|
74
|
-
@_stdout, @_stderr = capture_io do
|
75
|
-
super_result = super(suite, type)
|
76
|
-
end
|
77
|
-
super_result
|
78
|
-
ensure
|
79
|
-
trigger_callback(:after_suite, suite)
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
def before_test(suite, test)
|
84
|
-
@test_start_time = Time.now
|
85
|
-
trigger_callback(:before_test, suite, test)
|
86
|
-
end
|
87
|
-
|
88
|
-
def record(suite, test, assertions, time, exception)
|
89
|
-
record = TestRecord.new(suite, test.to_sym, assertions, time, exception)
|
90
|
-
|
91
|
-
#if exception #&& ENV['minitap_debug']
|
92
|
-
# STDERR.puts exception
|
93
|
-
# STDERR.puts exception.backtrace.join("\n")
|
94
|
-
#end
|
95
|
-
|
96
|
-
@test_results[suite] ||= {}
|
97
|
-
@test_results[suite][test.to_sym] = record
|
98
|
-
#@test_recorder.record(runner)
|
99
|
-
|
100
|
-
# MiniTest < 4.1.0 sends #record after all teardown hooks, so explicitly
|
101
|
-
# call #after_test here after recording.
|
102
|
-
after_test(suite, test) if Unit::VERSION <= "4.1.0"
|
103
|
-
end
|
104
|
-
|
105
|
-
def after_test(suite, test)
|
106
|
-
#runners = @test_recorder[suite, test.to_sym]
|
107
|
-
#records = @test_results[suite][test.to_sym]
|
108
|
-
record = @test_results[suite][test.to_sym]
|
109
|
-
|
110
|
-
#records.each do |record|
|
111
|
-
# trigger_callback(record.result, suite, test.to_sym, record)
|
112
|
-
#end
|
113
|
-
|
114
|
-
trigger_callback(record.result, suite, test.to_sym, record)
|
115
|
-
|
116
|
-
#trigger_callback(:after_test, suite, test.to_sym)
|
117
|
-
end
|
118
|
-
|
119
|
-
# Trigger the tapout callback.
|
120
|
-
def trigger_callback(callback, *args)
|
121
|
-
send("tapout_#{callback}", *args)
|
122
|
-
end
|
123
|
-
|
124
|
-
# Stub out the three IO methods used by the built-in reporter.
|
125
|
-
def puts(*args); end
|
126
|
-
def print(*args); end
|
127
|
-
def status(io = output); end
|
128
|
-
|
129
|
-
private
|
130
|
-
|
131
|
-
#
|
132
|
-
def filtered_tests(suite, type)
|
133
|
-
filter = options[:filter] || '/./'
|
134
|
-
filter = Regexp.new($1) if filter =~ /\/(.*)\//
|
135
|
-
suite.send("#{type}_methods").grep(filter)
|
136
|
-
end
|
137
|
-
|
138
|
-
#
|
139
|
-
#def suites_of_type(type)
|
140
|
-
# TestCase.send("#{type}_suites")
|
141
|
-
#end
|
142
|
-
|
143
|
-
=begin
|
144
|
-
#
|
145
|
-
def add_test_result(suite, test, test_runner)
|
146
|
-
self.report[suite] ||= {}
|
147
|
-
self.report[suite][test.to_sym] = test_runner
|
148
|
-
|
149
|
-
self.assertion_count += test_runner.assertions
|
150
|
-
|
151
|
-
case test_runner.result
|
152
|
-
when :skip then self.skips += 1
|
153
|
-
when :failure then self.failures += 1
|
154
|
-
when :error then self.errors += 1
|
155
|
-
end
|
156
|
-
end
|
157
|
-
=end
|
158
|
-
|
159
|
-
def count_tests!(suites, type)
|
160
|
-
filter = options[:filter] || '/./'
|
161
|
-
filter = Regexp.new $1 if filter =~ /\/(.*)\//
|
162
|
-
|
163
|
-
@test_count = suites.inject(0) do |acc, suite|
|
164
|
-
acc + suite.send("#{type}_methods").grep(filter).length
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
|
-
#
|
169
|
-
def tapout_before_suites(suites, type)
|
170
|
-
doc = {
|
171
|
-
'type' => 'suite',
|
172
|
-
'start' => self.suites_start_time.strftime('%Y-%m-%d %H:%M:%S'),
|
173
|
-
'count' => self.test_count,
|
174
|
-
'seed' => self.options[:seed],
|
175
|
-
'rev' => REVISION
|
176
|
-
}
|
177
|
-
return doc
|
178
|
-
end
|
179
|
-
|
180
|
-
#
|
181
|
-
def tapout_after_suites(suites, type)
|
182
|
-
doc = {
|
183
|
-
'type' => 'final',
|
184
|
-
'time' => Time.now - self.suites_start_time,
|
185
|
-
'counts' => {
|
186
|
-
'total' => self.test_count,
|
187
|
-
'pass' => self.test_count - self.failures - self.errors - self.skips,
|
188
|
-
'fail' => self.failures,
|
189
|
-
'error' => self.errors,
|
190
|
-
'omit' => self.skips,
|
191
|
-
'todo' => 0 # TODO: does minitest support pending tests?
|
192
|
-
}
|
193
|
-
}
|
194
|
-
return doc
|
195
|
-
end
|
196
|
-
|
197
|
-
#
|
198
|
-
def tapout_before_suite(suite)
|
199
|
-
doc = {
|
200
|
-
'type' => 'case',
|
201
|
-
'subtype' => '',
|
202
|
-
'label' => "#{suite}",
|
203
|
-
'level' => 0
|
204
|
-
}
|
205
|
-
return doc
|
206
|
-
end
|
207
|
-
|
208
|
-
#
|
209
|
-
def tapout_after_suite(suite)
|
210
|
-
end
|
211
|
-
|
212
|
-
#
|
213
|
-
def tapout_before_test(suite, test)
|
214
|
-
end
|
215
|
-
|
216
|
-
#
|
217
|
-
def tapout_after_test(suite, test)
|
218
|
-
end
|
219
|
-
|
220
|
-
#
|
221
|
-
def tapout_pass(suite, test, test_runner)
|
222
|
-
doc = {
|
223
|
-
'type' => 'test',
|
224
|
-
'subtype' => '',
|
225
|
-
'status' => 'pass',
|
226
|
-
#'setup': foo instance
|
227
|
-
'label' => "#{test}",
|
228
|
-
#'expected' => 2
|
229
|
-
#'returned' => 2
|
230
|
-
#'file' => 'test/test_foo.rb'
|
231
|
-
#'line': 45
|
232
|
-
#'source': ok 1, 2
|
233
|
-
#'snippet':
|
234
|
-
# - 44: ok 0,0
|
235
|
-
# - 45: ok 1,2
|
236
|
-
# - 46: ok 2,4
|
237
|
-
#'coverage':
|
238
|
-
# file: lib/foo.rb
|
239
|
-
# line: 11..13
|
240
|
-
# code: Foo#*
|
241
|
-
'time' => Time.now - self.suite_start_time
|
242
|
-
}
|
243
|
-
|
244
|
-
stdout, stderr = @_stdout, @_stderr
|
245
|
-
doc['stdout'] = stdout unless stdout.empty?
|
246
|
-
doc['stderr'] = stderr unless stderr.empty?
|
247
|
-
|
248
|
-
return doc
|
249
|
-
end
|
250
|
-
|
251
|
-
#
|
252
|
-
def tapout_skip(suite, test, test_runner)
|
253
|
-
e = test_runner.exception
|
254
|
-
e_file, e_line = location(test_runner.exception)
|
255
|
-
r_file = e_file.sub(Dir.pwd+'/', '')
|
256
|
-
|
257
|
-
doc = {
|
258
|
-
'type' => 'test',
|
259
|
-
'subtype' => '',
|
260
|
-
'status' => 'skip',
|
261
|
-
'label' => "#{test}",
|
262
|
-
#'setup' => "foo instance",
|
263
|
-
#'expected' => 2,
|
264
|
-
#'returned' => 1,
|
265
|
-
#'file' => test/test_foo.rb
|
266
|
-
#'line' => 45
|
267
|
-
#'source' => ok 1, 2
|
268
|
-
#'snippet' =>
|
269
|
-
# - 44: ok 0,0
|
270
|
-
# - 45: ok 1,2
|
271
|
-
# - 46: ok 2,4
|
272
|
-
#'coverage' =>
|
273
|
-
# 'file' => lib/foo.rb
|
274
|
-
# 'line' => 11..13
|
275
|
-
# 'code' => Foo#*
|
276
|
-
'exception' => {
|
277
|
-
'message' => clean_message(e.message),
|
278
|
-
'class' => e.class.name,
|
279
|
-
'file' => r_file,
|
280
|
-
'line' => e_line,
|
281
|
-
'source' => source(e_file)[e_line-1].strip,
|
282
|
-
'snippet' => code_snippet(e_file, e_line),
|
283
|
-
'backtrace' => filter_backtrace(e.backtrace)
|
284
|
-
},
|
285
|
-
'time' => Time.now - self.suite_start_time
|
286
|
-
}
|
287
|
-
return doc
|
288
|
-
end
|
289
|
-
|
290
|
-
#
|
291
|
-
def tapout_failure(suite, test, test_runner)
|
292
|
-
e = test_runner.exception
|
293
|
-
e_file, e_line = location(test_runner.exception)
|
294
|
-
r_file = e_file.sub(Dir.pwd+'/', '')
|
295
|
-
|
296
|
-
doc = {
|
297
|
-
'type' => 'test',
|
298
|
-
'subtype' => '',
|
299
|
-
'status' => 'fail',
|
300
|
-
'label' => "#{test}",
|
301
|
-
#'setup' => "foo instance",
|
302
|
-
#'expected' => 2,
|
303
|
-
#'returned' => 1,
|
304
|
-
#'file' => test/test_foo.rb
|
305
|
-
#'line' => 45
|
306
|
-
#'source' => ok 1, 2
|
307
|
-
#'snippet' =>
|
308
|
-
# - 44: ok 0,0
|
309
|
-
# - 45: ok 1,2
|
310
|
-
# - 46: ok 2,4
|
311
|
-
#'coverage' =>
|
312
|
-
# 'file' => lib/foo.rb
|
313
|
-
# 'line' => 11..13
|
314
|
-
# 'code' => Foo#*
|
315
|
-
'exception' => {
|
316
|
-
'message' => clean_message(e.message),
|
317
|
-
'class' => e.class.name,
|
318
|
-
'file' => r_file,
|
319
|
-
'line' => e_line,
|
320
|
-
'source' => source(e_file)[e_line-1].strip,
|
321
|
-
'snippet' => code_snippet(e_file, e_line),
|
322
|
-
'backtrace' => filter_backtrace(e.backtrace)
|
323
|
-
},
|
324
|
-
'time' => Time.now - self.suite_start_time
|
325
|
-
}
|
326
|
-
|
327
|
-
stdout, stderr = @_stdout, @_stderr
|
328
|
-
doc['stdout'] = stdout unless stdout.empty?
|
329
|
-
doc['stderr'] = stderr unless stderr.empty?
|
330
|
-
|
331
|
-
return doc
|
332
|
-
end
|
333
|
-
|
334
|
-
#
|
335
|
-
def tapout_error(suite, test, test_runner)
|
336
|
-
e = test_runner.exception
|
337
|
-
e_file, e_line = location(test_runner.exception)
|
338
|
-
r_file = e_file.sub(Dir.pwd+'/', '')
|
339
|
-
|
340
|
-
doc = {
|
341
|
-
'type' => 'test',
|
342
|
-
'subtype' => '',
|
343
|
-
'status' => 'error',
|
344
|
-
'label' => "#{test}",
|
345
|
-
#'setup' => "foo instance",
|
346
|
-
#'expected' => 2,
|
347
|
-
#'returned' => 1,
|
348
|
-
#'file' => test/test_foo.rb
|
349
|
-
#'line' => 45
|
350
|
-
#'source' => ok 1, 2
|
351
|
-
#'snippet' =>
|
352
|
-
# - 44: ok 0,0
|
353
|
-
# - 45: ok 1,2
|
354
|
-
# - 46: ok 2,4
|
355
|
-
#'coverage' =>
|
356
|
-
# 'file' => lib/foo.rb
|
357
|
-
# 'line' => 11..13
|
358
|
-
# 'code' => Foo#*
|
359
|
-
'exception' => {
|
360
|
-
'message' => clean_message(e.message),
|
361
|
-
'class' => e.class.name,
|
362
|
-
'file' => r_file,
|
363
|
-
'line' => e_line,
|
364
|
-
'source' => source(e_file)[e_line-1].strip,
|
365
|
-
'snippet' => code_snippet(e_file, e_line),
|
366
|
-
'backtrace' => filter_backtrace(e.backtrace)
|
367
|
-
},
|
368
|
-
'time' => Time.now - self.suite_start_time
|
369
|
-
}
|
370
|
-
|
371
|
-
stdout, stderr = @_stdout, @_stderr
|
372
|
-
doc['stdout'] = stdout unless stdout.empty?
|
373
|
-
doc['stderr'] = stderr unless stderr.empty?
|
374
|
-
|
375
|
-
return doc
|
376
|
-
end
|
377
|
-
|
378
|
-
#
|
379
|
-
#def filter_backtrace(backtrace)
|
380
|
-
# trace = backtrace
|
381
|
-
# trace = clean_backtrace(trace)
|
382
|
-
# trace = MiniTest::filter_backtrace(trace)
|
383
|
-
# trace
|
384
|
-
#end
|
385
|
-
|
386
|
-
# Clean the backtrace of any reference to test framework itself.
|
387
|
-
def filter_backtrace(backtrace)
|
388
|
-
## remove backtraces that match any pattern in IGNORE_CALLERS
|
389
|
-
trace = backtrace.reject{|b| IGNORE_CALLERS.any?{|i| i=~b}}
|
390
|
-
## remove `:in ...` portion of backtraces
|
391
|
-
trace = trace.map do |bt|
|
392
|
-
i = bt.index(':in')
|
393
|
-
i ? bt[0...i] : bt
|
394
|
-
end
|
395
|
-
## now apply MiniTest's own filter (note: doesn't work if done first, why?)
|
396
|
-
trace = MiniTest::filter_backtrace(trace)
|
397
|
-
## if the backtrace is empty now then revert to the original
|
398
|
-
trace = backtrace if trace.empty?
|
399
|
-
## simplify paths to be relative to current workding diectory
|
400
|
-
trace = trace.map{ |bt| bt.sub(Dir.pwd+File::SEPARATOR,'') }
|
401
|
-
return trace
|
402
|
-
end
|
403
|
-
|
404
|
-
# Returns a String of source code.
|
405
|
-
def code_snippet(file, line)
|
406
|
-
s = []
|
407
|
-
if File.file?(file)
|
408
|
-
source = source(file)
|
409
|
-
radius = 2 # TODO: make customizable (number of surrounding lines to show)
|
410
|
-
region = [line - radius, 1].max ..
|
411
|
-
[line + radius, source.length].min
|
412
|
-
|
413
|
-
s = region.map do |n|
|
414
|
-
{n => source[n-1].chomp}
|
415
|
-
end
|
416
|
-
end
|
417
|
-
return s
|
418
|
-
end
|
419
|
-
|
420
|
-
# Cache source file text. This is only used if the TAP-Y stream
|
421
|
-
# doesn not provide a snippet and the test file is locatable.
|
422
|
-
def source(file)
|
423
|
-
@_source_cache[file] ||= (
|
424
|
-
File.readlines(file)
|
425
|
-
)
|
426
|
-
end
|
427
|
-
|
428
|
-
# Parse source location from caller, caller[0] or an Exception object.
|
429
|
-
def parse_source_location(caller)
|
430
|
-
case caller
|
431
|
-
when Exception
|
432
|
-
trace = caller.backtrace.reject{ |bt| bt =~ INTERNALS }
|
433
|
-
caller = trace.first
|
434
|
-
when Array
|
435
|
-
caller = caller.first
|
436
|
-
end
|
437
|
-
caller =~ /(.+?):(\d+(?=:|\z))/ or return ""
|
438
|
-
source_file, source_line = $1, $2.to_i
|
439
|
-
return source_file, source_line
|
440
|
-
end
|
441
|
-
|
442
|
-
# Get location of exception.
|
443
|
-
def location e # :nodoc:
|
444
|
-
last_before_assertion = ""
|
445
|
-
e.backtrace.reverse_each do |s|
|
446
|
-
break if s =~ /in .(assert|refute|flunk|pass|fail|raise|must|wont)/
|
447
|
-
last_before_assertion = s
|
448
|
-
end
|
449
|
-
file, line = last_before_assertion.sub(/:in .*$/, '').split(':')
|
450
|
-
line = line.to_i if line
|
451
|
-
return file, line
|
452
|
-
end
|
453
|
-
|
454
|
-
#
|
455
|
-
def clean_message(message)
|
456
|
-
message.strip #.gsub(/\s*\n\s*/, "\n")
|
457
|
-
end
|
458
|
-
|
459
|
-
#
|
460
|
-
def capture_io
|
461
|
-
ostdout, ostderr = $stdout, $stderr
|
462
|
-
cstdout, cstderr = StringIO.new, StringIO.new
|
463
|
-
$stdout, $stderr = cstdout, cstderr
|
464
|
-
|
465
|
-
yield
|
466
|
-
|
467
|
-
return cstdout.string.chomp("\n"), cstderr.string.chomp("\n")
|
468
|
-
ensure
|
469
|
-
$stdout = ostdout
|
470
|
-
$stderr = ostderr
|
471
|
-
end
|
472
|
-
|
473
|
-
end
|
474
|
-
|
475
|
-
##
|
476
|
-
# Used to keep a record of each test and it's result.
|
477
|
-
#
|
478
|
-
class TestRecord < Struct.new(:suite, :test, :assertions, :time, :exception)
|
479
|
-
def result
|
480
|
-
case exception
|
481
|
-
when nil then :pass
|
482
|
-
when Skip then :skip
|
483
|
-
when Assertion then :failure
|
484
|
-
else :error
|
485
|
-
end
|
486
|
-
end
|
487
|
-
end
|
488
|
-
|
489
|
-
=begin
|
490
|
-
# Runner for individual MiniTest tests.
|
491
|
-
#
|
492
|
-
# You *should not* create instances of this class directly. Instances of
|
493
|
-
# {SuiteRunner} will create these and send them to the reporters.
|
494
|
-
#
|
495
|
-
# Based upon Ryan Davis of Seattle.rb's MiniTest (MIT License).
|
496
|
-
#
|
497
|
-
# @see https://github.com/seattlerb/minitest MiniTest
|
498
|
-
class TestRunner
|
499
|
-
attr_reader :suite, :test, :assertions, :result, :exception
|
500
|
-
attr_reader :stdout, :stderr
|
501
|
-
|
502
|
-
def initialize(suite, test)
|
503
|
-
@suite = suite
|
504
|
-
@test = test
|
505
|
-
@assertions = 0
|
506
|
-
end
|
507
|
-
|
508
|
-
def run
|
509
|
-
suite_instance = suite.new(test)
|
510
|
-
test_result = nil
|
511
|
-
@stdout, @stderr = capture_io do
|
512
|
-
test_result = suite_instance.run(self)
|
513
|
-
end
|
514
|
-
@result, @exception = fix_result(test_result)
|
515
|
-
@assertions = suite_instance._assertions
|
516
|
-
end
|
517
|
-
|
518
|
-
def puke(suite, test, exception)
|
519
|
-
case exception
|
520
|
-
when MiniTest::Skip then [:skip, exception]
|
521
|
-
when MiniTest::Assertion then [:failure, exception]
|
522
|
-
else [:error, exception]
|
523
|
-
end
|
524
|
-
end
|
525
|
-
|
526
|
-
def record(suite, method, assertions, time, error)
|
527
|
-
end
|
528
|
-
|
529
|
-
private
|
530
|
-
|
531
|
-
#
|
532
|
-
def fix_result(result)
|
533
|
-
result == '.' ? [:pass, nil] : result
|
534
|
-
end
|
535
|
-
|
536
|
-
#
|
537
|
-
def capture_io
|
538
|
-
ostdout, ostderr = $stdout, $stderr
|
539
|
-
cstdout, cstderr = StringIO.new, StringIO.new
|
540
|
-
$stdout, $stderr = cstdout, cstderr
|
541
|
-
|
542
|
-
yield
|
543
|
-
|
544
|
-
return cstdout.string.chomp("\n"), cstderr.string.chomp("\n")
|
545
|
-
ensure
|
546
|
-
$stdout = ostdout
|
547
|
-
$stderr = ostderr
|
548
|
-
end
|
549
|
-
end
|
550
|
-
=end
|
551
|
-
|
552
|
-
##
|
553
|
-
# Around advice.
|
554
|
-
#
|
555
|
-
module AroundTestHooks
|
556
|
-
def self.before_test(instance)
|
557
|
-
if before_test = (MiniTest::Unit.runner.method(:before_test) rescue nil)
|
558
|
-
before_test.call(instance.class, instance.__name__)
|
559
|
-
end
|
560
|
-
end
|
561
|
-
|
562
|
-
def self.after_test(instance)
|
563
|
-
# MiniTest < 4.1.0 sends #record after all teardown hooks, so don't call
|
564
|
-
# #after_test here.
|
565
|
-
if MiniTest::Unit::VERSION > "4.1.0"
|
566
|
-
if after_test = (MiniTest::Unit.runner.method(:after_test) rescue nil)
|
567
|
-
after_test.call(instance.class, instance.__name__)
|
568
|
-
end
|
569
|
-
end
|
570
|
-
end
|
571
|
-
|
572
|
-
def before_setup
|
573
|
-
AroundTestHooks.before_test(self)
|
574
|
-
super
|
575
|
-
end
|
576
|
-
|
577
|
-
def after_teardown
|
578
|
-
super
|
579
|
-
AroundTestHooks.after_test(self)
|
580
|
-
end
|
581
|
-
end
|
582
|
-
|
583
|
-
class Unit::TestCase
|
584
|
-
include AroundTestHooks
|
585
|
-
end
|
586
|
-
|
587
|
-
##
|
588
|
-
# TAP-Y adapater.
|
589
|
-
#
|
590
|
-
class TapY < MiniTap
|
591
|
-
def initialize
|
592
|
-
require 'yaml' unless respond_to?(:to_yaml)
|
593
|
-
super
|
594
|
-
end
|
595
|
-
|
596
|
-
def tapout_before_suites(suites, type)
|
597
|
-
wp super(suites, type).to_yaml
|
598
|
-
end
|
599
|
-
def tapout_before_suite(suite)
|
600
|
-
wp super(suite).to_yaml
|
601
|
-
end
|
602
|
-
def tapout_pass(suite, test, test_runner)
|
603
|
-
wp super(suite, test, test_runner).to_yaml
|
604
|
-
end
|
605
|
-
def tapout_skip(suite, test, test_runner)
|
606
|
-
wp super(suite, test, test_runner).to_yaml
|
607
|
-
end
|
608
|
-
def tapout_failure(suite, test, test_runner)
|
609
|
-
wp super(suite, test, test_runner).to_yaml
|
610
|
-
end
|
611
|
-
def tapout_error(suite, test, test_runner)
|
612
|
-
wp super(suite, test, test_runner).to_yaml
|
613
|
-
end
|
614
|
-
def tapout_after_suites(suites, type)
|
615
|
-
wp super(suites, type).to_yaml
|
616
|
-
wp "..."
|
617
|
-
end
|
618
|
-
|
619
|
-
def wp(str)
|
620
|
-
STDOUT.puts(str)
|
621
|
-
end
|
622
|
-
end
|
623
|
-
|
624
|
-
##
|
625
|
-
# TAP-J adapater.
|
626
|
-
#
|
627
|
-
class TapJ < MiniTap
|
628
|
-
def initialize
|
629
|
-
require 'json' unless respond_to?(:to_json)
|
630
|
-
super
|
631
|
-
end
|
632
|
-
|
633
|
-
def tapout_before_suites(suites, type)
|
634
|
-
wp super(suites, type).to_json
|
635
|
-
end
|
636
|
-
def tapout_before_suite(suite)
|
637
|
-
wp super(suite).to_json
|
638
|
-
end
|
639
|
-
def tapout_pass(suite, test, test_runner)
|
640
|
-
wp super(suite, test, test_runner).to_json
|
641
|
-
end
|
642
|
-
def tapout_skip(suite, test, test_runner)
|
643
|
-
wp super(suite, test, test_runner).to_json
|
644
|
-
end
|
645
|
-
def tapout_failure(suite, test, test_runner)
|
646
|
-
wp super(suite, test, test_runner).to_json
|
647
|
-
end
|
648
|
-
def tapout_error(suite, test, test_runner)
|
649
|
-
wp super(suite, test, test_runner).to_json
|
650
|
-
end
|
651
|
-
def tapout_after_suites(suites, type)
|
652
|
-
wp super(suites, type).to_json
|
653
|
-
end
|
654
|
-
|
655
|
-
def wp(str)
|
656
|
-
STDOUT.puts(str)
|
657
|
-
end
|
658
|
-
end
|
659
|
-
|
660
|
-
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minitap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- trans
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-11-
|
11
|
+
date: 2013-11-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tapout
|
@@ -97,8 +97,6 @@ files:
|
|
97
97
|
- .yardopts
|
98
98
|
- lib/minitap/ignore_callers.rb
|
99
99
|
- lib/minitap/minitest5.rb
|
100
|
-
- lib/minitap/tapj.rb
|
101
|
-
- lib/minitap/tapy.rb
|
102
100
|
- lib/minitap.rb
|
103
101
|
- lib/minitest/minitap_plugin.rb
|
104
102
|
- NOTICE.md
|
data/lib/minitap/tapj.rb
DELETED