test_bench 1.0.0.0 → 1.2.0.0
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.
- checksums.yaml +4 -4
- data/lib/test_bench.rb +9 -9
- data/lib/test_bench/cli.rb +2 -2
- data/lib/test_bench/cli/parse_arguments.rb +33 -20
- data/lib/test_bench/controls.rb +5 -1
- data/lib/test_bench/controls/output/batch_data.rb +52 -0
- data/lib/test_bench/controls/output/detail_setting.rb +29 -0
- data/lib/test_bench/controls/output/exercise.rb +7 -0
- data/lib/test_bench/controls/output/log_level.rb +7 -0
- data/lib/test_bench/controls/output/summary/error.rb +0 -16
- data/lib/test_bench/controls/output/summary/session.rb +20 -0
- data/lib/test_bench/controls/pattern.rb +6 -2
- data/lib/test_bench/controls/time.rb +18 -0
- data/lib/test_bench/deactivation_variants.rb +0 -10
- data/lib/test_bench/output.rb +14 -2
- data/lib/test_bench/output/batch_data.rb +17 -0
- data/lib/test_bench/output/buffer.rb +112 -0
- data/lib/test_bench/output/log.rb +27 -0
- data/lib/test_bench/output/raw.rb +353 -0
- data/lib/test_bench/output/summary.rb +146 -0
- data/lib/test_bench/output/summary/session.rb +94 -0
- data/lib/test_bench/output/writer.rb +2 -2
- data/lib/test_bench/run.rb +9 -9
- data/lib/test_bench/test_bench.rb +31 -3
- metadata +18 -17
- data/lib/test_bench/controls/output/summary/run.rb +0 -59
- data/lib/test_bench/output/build.rb +0 -57
- data/lib/test_bench/output/levels/debug.rb +0 -229
- data/lib/test_bench/output/levels/failure.rb +0 -31
- data/lib/test_bench/output/levels/none.rb +0 -13
- data/lib/test_bench/output/levels/pass.rb +0 -274
- data/lib/test_bench/output/levels/summary.rb +0 -21
- data/lib/test_bench/output/summary/error.rb +0 -77
- data/lib/test_bench/output/summary/run.rb +0 -102
- data/lib/test_bench/output/summary/run/print.rb +0 -98
@@ -1,31 +0,0 @@
|
|
1
|
-
module TestBench
|
2
|
-
module Output
|
3
|
-
module Levels
|
4
|
-
class Failure
|
5
|
-
include TestBench::Fixture::Output
|
6
|
-
|
7
|
-
include Output::PrintError
|
8
|
-
include Output::Summary::Error
|
9
|
-
|
10
|
-
def self.build(omit_backtrace_pattern: nil, reverse_backtraces: nil, writer: nil, styling: nil, device: nil)
|
11
|
-
warn "Warning: #{self} is deprecated. It will remain in the TestBench v2 series, but will be removed from TestBench v3"
|
12
|
-
|
13
|
-
instance = new
|
14
|
-
|
15
|
-
instance.omit_backtrace_pattern = omit_backtrace_pattern unless omit_backtrace_pattern.nil?
|
16
|
-
instance.reverse_backtraces = reverse_backtraces unless reverse_backtraces.nil?
|
17
|
-
|
18
|
-
Writer.configure(instance, writer: writer, styling: styling, device: device)
|
19
|
-
|
20
|
-
instance
|
21
|
-
end
|
22
|
-
|
23
|
-
def error(error)
|
24
|
-
print_error(error)
|
25
|
-
|
26
|
-
writer.newline
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
module TestBench
|
2
|
-
module Output
|
3
|
-
module Levels
|
4
|
-
class None < Fixture::Output::Null
|
5
|
-
def self.build
|
6
|
-
warn "Warning: #{self} is deprecated. It will remain in the TestBench v2 series, but will be removed from TestBench v3"
|
7
|
-
|
8
|
-
new
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
@@ -1,274 +0,0 @@
|
|
1
|
-
module TestBench
|
2
|
-
module Output
|
3
|
-
module Levels
|
4
|
-
class Pass
|
5
|
-
include TestBench::Fixture::Output
|
6
|
-
|
7
|
-
include Writer::Dependency
|
8
|
-
|
9
|
-
include PrintError
|
10
|
-
|
11
|
-
include Output::Summary::Error
|
12
|
-
include Output::Summary::Run
|
13
|
-
|
14
|
-
attr_accessor :previous_error
|
15
|
-
|
16
|
-
def previous_byte_offset
|
17
|
-
@previous_byte_offset ||= 0
|
18
|
-
end
|
19
|
-
attr_writer :previous_byte_offset
|
20
|
-
|
21
|
-
def assert_block_stack
|
22
|
-
@assert_block_stack ||= AssertBlockStack.new(writer)
|
23
|
-
end
|
24
|
-
attr_writer :assert_block_stack
|
25
|
-
|
26
|
-
def test_stack
|
27
|
-
@test_stack ||= []
|
28
|
-
end
|
29
|
-
attr_writer :test_stack
|
30
|
-
|
31
|
-
def self.build(omit_backtrace_pattern: nil, reverse_backtraces: nil, writer: nil, styling: nil, device: nil)
|
32
|
-
instance = new
|
33
|
-
|
34
|
-
instance.omit_backtrace_pattern = omit_backtrace_pattern unless omit_backtrace_pattern.nil?
|
35
|
-
instance.reverse_backtraces = reverse_backtraces unless reverse_backtraces.nil?
|
36
|
-
|
37
|
-
Writer.configure(instance, writer: writer, styling: styling, device: device)
|
38
|
-
Timer.configure(instance)
|
39
|
-
|
40
|
-
instance
|
41
|
-
end
|
42
|
-
|
43
|
-
def comment(text)
|
44
|
-
writer
|
45
|
-
.indent
|
46
|
-
.text(text)
|
47
|
-
.newline
|
48
|
-
end
|
49
|
-
|
50
|
-
def error(error)
|
51
|
-
self.previous_error = error
|
52
|
-
end
|
53
|
-
|
54
|
-
def print_previous_error
|
55
|
-
print_error(previous_error)
|
56
|
-
|
57
|
-
self.previous_error = nil
|
58
|
-
end
|
59
|
-
|
60
|
-
def start_test(_)
|
61
|
-
test_stack.push(true)
|
62
|
-
end
|
63
|
-
|
64
|
-
def finish_test(title, result)
|
65
|
-
test_stack.pop
|
66
|
-
|
67
|
-
unless result && title.nil?
|
68
|
-
writer.indent
|
69
|
-
|
70
|
-
writer.escape_code(:bold) unless result
|
71
|
-
|
72
|
-
fg_color = result ? :green : :red
|
73
|
-
|
74
|
-
writer
|
75
|
-
.escape_code(fg_color)
|
76
|
-
.text(title || 'Test')
|
77
|
-
.escape_code(:reset_fg)
|
78
|
-
|
79
|
-
writer.escape_code(:reset_intensity) unless result
|
80
|
-
|
81
|
-
writer.newline
|
82
|
-
end
|
83
|
-
|
84
|
-
unless previous_error.nil?
|
85
|
-
writer.increase_indentation
|
86
|
-
|
87
|
-
print_previous_error
|
88
|
-
|
89
|
-
writer.decrease_indentation
|
90
|
-
end
|
91
|
-
|
92
|
-
unless result
|
93
|
-
assert_block_stack.print_captured_text
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
def skip_test(title)
|
98
|
-
writer.indent
|
99
|
-
|
100
|
-
writer
|
101
|
-
.escape_code(:yellow)
|
102
|
-
.text(title || 'Test')
|
103
|
-
.escape_code(:reset_fg)
|
104
|
-
|
105
|
-
writer.newline
|
106
|
-
end
|
107
|
-
|
108
|
-
def enter_context(title)
|
109
|
-
test_stack.push(false)
|
110
|
-
|
111
|
-
return if title.nil?
|
112
|
-
|
113
|
-
writer
|
114
|
-
.indent
|
115
|
-
.escape_code(:green)
|
116
|
-
.text(title)
|
117
|
-
.escape_code(:reset_fg)
|
118
|
-
.newline
|
119
|
-
|
120
|
-
writer.increase_indentation
|
121
|
-
end
|
122
|
-
|
123
|
-
def exit_context(title, result)
|
124
|
-
test_stack.pop
|
125
|
-
|
126
|
-
print_previous_error unless previous_error.nil?
|
127
|
-
|
128
|
-
unless result
|
129
|
-
assert_block_stack.print_captured_text
|
130
|
-
end
|
131
|
-
|
132
|
-
return if title.nil?
|
133
|
-
|
134
|
-
writer.decrease_indentation
|
135
|
-
|
136
|
-
writer.newline if writer.indentation_depth.zero?
|
137
|
-
end
|
138
|
-
|
139
|
-
def skip_context(title)
|
140
|
-
return if title.nil?
|
141
|
-
|
142
|
-
writer
|
143
|
-
.indent
|
144
|
-
.escape_code(:yellow)
|
145
|
-
.text(title)
|
146
|
-
.escape_code(:reset_fg)
|
147
|
-
.newline
|
148
|
-
|
149
|
-
writer.newline if writer.indentation_depth.zero?
|
150
|
-
end
|
151
|
-
|
152
|
-
def enter_file(file)
|
153
|
-
text = "Running #{file}"
|
154
|
-
|
155
|
-
writer.text(text).newline
|
156
|
-
|
157
|
-
self.previous_byte_offset = writer.byte_offset
|
158
|
-
end
|
159
|
-
|
160
|
-
def exit_file(file, result)
|
161
|
-
print_previous_error unless previous_error.nil?
|
162
|
-
|
163
|
-
unless result
|
164
|
-
assert_block_stack.print_captured_text
|
165
|
-
end
|
166
|
-
|
167
|
-
unless writer.byte_offset > previous_byte_offset
|
168
|
-
writer
|
169
|
-
.escape_code(:faint)
|
170
|
-
.text("(Nothing written)")
|
171
|
-
.escape_code(:reset_intensity)
|
172
|
-
.newline
|
173
|
-
|
174
|
-
writer.newline
|
175
|
-
end
|
176
|
-
end
|
177
|
-
|
178
|
-
def finish_fixture(_, result)
|
179
|
-
print_previous_error unless previous_error.nil?
|
180
|
-
|
181
|
-
unless result
|
182
|
-
assert_block_stack.print_captured_text
|
183
|
-
end
|
184
|
-
end
|
185
|
-
|
186
|
-
def enter_assert_block(_)
|
187
|
-
inside_test = inside_test?
|
188
|
-
|
189
|
-
test_stack.push(false)
|
190
|
-
|
191
|
-
assert_block_stack.push
|
192
|
-
|
193
|
-
writer.increase_indentation
|
194
|
-
writer.increase_indentation if inside_test
|
195
|
-
end
|
196
|
-
|
197
|
-
def exit_assert_block(_, result)
|
198
|
-
test_stack.pop
|
199
|
-
|
200
|
-
print_previous_error unless previous_error.nil?
|
201
|
-
|
202
|
-
unless result
|
203
|
-
assert_block_stack.print_captured_text
|
204
|
-
end
|
205
|
-
|
206
|
-
discard_captured_text = result
|
207
|
-
|
208
|
-
assert_block_stack.pop(discard_captured_text)
|
209
|
-
|
210
|
-
writer.decrease_indentation if inside_test?
|
211
|
-
writer.decrease_indentation
|
212
|
-
end
|
213
|
-
|
214
|
-
def inside_test?
|
215
|
-
test_stack[-1]
|
216
|
-
end
|
217
|
-
|
218
|
-
class AssertBlockStack
|
219
|
-
def stack
|
220
|
-
@stack ||= []
|
221
|
-
end
|
222
|
-
|
223
|
-
attr_accessor :captured_text
|
224
|
-
|
225
|
-
attr_reader :writer
|
226
|
-
|
227
|
-
def initialize(writer)
|
228
|
-
@writer = writer
|
229
|
-
end
|
230
|
-
|
231
|
-
def push
|
232
|
-
capture_text = String.new
|
233
|
-
|
234
|
-
previous_device = writer.device
|
235
|
-
|
236
|
-
writer.device = StringIO.new(capture_text)
|
237
|
-
|
238
|
-
entry = Entry.new(capture_text, previous_device)
|
239
|
-
|
240
|
-
stack.push(entry)
|
241
|
-
|
242
|
-
entry
|
243
|
-
end
|
244
|
-
|
245
|
-
def pop(discard)
|
246
|
-
entry = stack.pop
|
247
|
-
|
248
|
-
writer.device = entry.previous_device
|
249
|
-
|
250
|
-
unless discard
|
251
|
-
self.captured_text = entry.capture_text
|
252
|
-
end
|
253
|
-
|
254
|
-
entry
|
255
|
-
end
|
256
|
-
|
257
|
-
def print_captured_text
|
258
|
-
return if captured_text.nil?
|
259
|
-
|
260
|
-
writer.text(captured_text)
|
261
|
-
|
262
|
-
self.captured_text = nil
|
263
|
-
end
|
264
|
-
|
265
|
-
def inside_test?
|
266
|
-
test_stack[-1]
|
267
|
-
end
|
268
|
-
|
269
|
-
Entry = Struct.new(:capture_text, :previous_device)
|
270
|
-
end
|
271
|
-
end
|
272
|
-
end
|
273
|
-
end
|
274
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module TestBench
|
2
|
-
module Output
|
3
|
-
module Levels
|
4
|
-
class Summary
|
5
|
-
include TestBench::Fixture::Output
|
6
|
-
|
7
|
-
include Output::Summary::Error
|
8
|
-
include Output::Summary::Run
|
9
|
-
|
10
|
-
def self.build(writer: nil, styling: nil, device: nil)
|
11
|
-
warn "Warning: #{self} is deprecated. It will remain in the TestBench v2 series, but will be removed from TestBench v3"
|
12
|
-
|
13
|
-
instance = new
|
14
|
-
Writer.configure(instance, writer: writer, styling: styling, device: device)
|
15
|
-
Timer.configure(instance)
|
16
|
-
instance
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,77 +0,0 @@
|
|
1
|
-
module TestBench
|
2
|
-
module Output
|
3
|
-
module Summary
|
4
|
-
module Error
|
5
|
-
include Writer::Dependency
|
6
|
-
|
7
|
-
def self.included(cls)
|
8
|
-
cls.prepend(OutputMethods)
|
9
|
-
end
|
10
|
-
|
11
|
-
def error_summary_errors
|
12
|
-
@error_summary_errors ||= Hash.new do |hash, key|
|
13
|
-
hash[key] = []
|
14
|
-
end
|
15
|
-
end
|
16
|
-
attr_writer :error_summary_errors
|
17
|
-
|
18
|
-
attr_accessor :error_summary_current_file
|
19
|
-
|
20
|
-
def error_summary
|
21
|
-
return if error_summary_errors.empty?
|
22
|
-
|
23
|
-
writer
|
24
|
-
.escape_code(:bold)
|
25
|
-
.escape_code(:red)
|
26
|
-
.text('Error Summary:')
|
27
|
-
.escape_code(:reset_intensity)
|
28
|
-
.escape_code(:reset_fg)
|
29
|
-
.newline
|
30
|
-
|
31
|
-
error_summary_errors.each do |file, errors|
|
32
|
-
error_count = errors.count
|
33
|
-
|
34
|
-
writer
|
35
|
-
.text(error_count.to_s.rjust(4, ' '))
|
36
|
-
.text(": #{file}")
|
37
|
-
.newline
|
38
|
-
|
39
|
-
errors.each do |error|
|
40
|
-
writer
|
41
|
-
.text(' ')
|
42
|
-
.escape_code(:red)
|
43
|
-
|
44
|
-
PrintError.error_message(error, writer: writer)
|
45
|
-
|
46
|
-
writer.escape_code(:reset_fg)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
writer.newline
|
51
|
-
end
|
52
|
-
|
53
|
-
module OutputMethods
|
54
|
-
def enter_file(file)
|
55
|
-
super
|
56
|
-
|
57
|
-
self.error_summary_current_file = file
|
58
|
-
end
|
59
|
-
|
60
|
-
def error(error)
|
61
|
-
super
|
62
|
-
|
63
|
-
current_file = error_summary_current_file
|
64
|
-
|
65
|
-
self.error_summary_errors[current_file] << error
|
66
|
-
end
|
67
|
-
|
68
|
-
def finish(_)
|
69
|
-
super
|
70
|
-
|
71
|
-
error_summary
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
@@ -1,102 +0,0 @@
|
|
1
|
-
module TestBench
|
2
|
-
module Output
|
3
|
-
module Summary
|
4
|
-
module Run
|
5
|
-
include Writer::Dependency
|
6
|
-
extend Print
|
7
|
-
|
8
|
-
def self.included(cls)
|
9
|
-
cls.prepend(OutputMethods)
|
10
|
-
end
|
11
|
-
|
12
|
-
def file_count
|
13
|
-
@file_count ||= 0
|
14
|
-
end
|
15
|
-
attr_writer :file_count
|
16
|
-
|
17
|
-
def test_count
|
18
|
-
@test_count ||= 0
|
19
|
-
end
|
20
|
-
attr_writer :test_count
|
21
|
-
|
22
|
-
def pass_count
|
23
|
-
@pass_count ||= 0
|
24
|
-
end
|
25
|
-
attr_writer :pass_count
|
26
|
-
|
27
|
-
def skip_count
|
28
|
-
@skip_count ||= 0
|
29
|
-
end
|
30
|
-
attr_writer :skip_count
|
31
|
-
|
32
|
-
def failure_count
|
33
|
-
@failure_count ||= 0
|
34
|
-
end
|
35
|
-
attr_writer :failure_count
|
36
|
-
|
37
|
-
def error_count
|
38
|
-
@error_count ||= 0
|
39
|
-
end
|
40
|
-
attr_writer :error_count
|
41
|
-
|
42
|
-
def elapsed_time
|
43
|
-
@elapsed_time ||= 0
|
44
|
-
end
|
45
|
-
attr_writer :elapsed_time
|
46
|
-
|
47
|
-
def timer
|
48
|
-
@timer ||= Timer::Substitute.build
|
49
|
-
end
|
50
|
-
attr_writer :timer
|
51
|
-
|
52
|
-
module OutputMethods
|
53
|
-
def enter_file(_)
|
54
|
-
super
|
55
|
-
|
56
|
-
timer.start
|
57
|
-
end
|
58
|
-
|
59
|
-
def exit_file(_, _)
|
60
|
-
super
|
61
|
-
|
62
|
-
elapsed_time = timer.stop
|
63
|
-
|
64
|
-
self.elapsed_time += elapsed_time
|
65
|
-
|
66
|
-
self.file_count += 1
|
67
|
-
end
|
68
|
-
|
69
|
-
def finish_test(_, result)
|
70
|
-
super
|
71
|
-
|
72
|
-
self.test_count += 1
|
73
|
-
|
74
|
-
if result
|
75
|
-
self.pass_count += 1
|
76
|
-
else
|
77
|
-
self.failure_count += 1
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
def skip_test(_)
|
82
|
-
super
|
83
|
-
|
84
|
-
self.skip_count += 1
|
85
|
-
end
|
86
|
-
|
87
|
-
def error(_)
|
88
|
-
super
|
89
|
-
|
90
|
-
self.error_count += 1
|
91
|
-
end
|
92
|
-
|
93
|
-
def finish(_)
|
94
|
-
super
|
95
|
-
|
96
|
-
Print.(file_count: file_count, test_count: test_count, pass_count: pass_count, skip_count: skip_count, failure_count: failure_count, error_count: error_count, elapsed_time: elapsed_time, writer: writer)
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|