test_bench-bootstrap 3.0.0 → 4.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/test_bench/bootstrap.rb +14 -97
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd267192ab849cfd01355201251e06a7a04b967a9738d28b458bb29b99bce080
|
4
|
+
data.tar.gz: b8d64331eda79e450faddfd50b1b80e76b8570e549aa8d32f62b543a16a47532
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d28ec437fbfd2cfe6a02318a8887590400343f3f5589f00001196a312f1577ecf937cbfefb83d297a92f34057882a046f2374e399f2e228aef3306c3742f7f91
|
7
|
+
data.tar.gz: 857c18b0168eda3fd9900931081ec96641d89ff1ea298bd5e4aca1741d2139699c5ba434d70a6ea43618d13bf8e6605fd1ef7ff3861d89e385ffb12a40f9669f
|
data/lib/test_bench/bootstrap.rb
CHANGED
@@ -4,22 +4,6 @@ module TestBench
|
|
4
4
|
Object.include(Fixture)
|
5
5
|
end
|
6
6
|
|
7
|
-
if RUBY_ENGINE != 'mruby'
|
8
|
-
class Abort < SystemExit
|
9
|
-
def self.build
|
10
|
-
new(1)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
class Abort
|
16
|
-
def self.call
|
17
|
-
Output.raw_write("#{Bootstrap} is aborting\n")
|
18
|
-
instance = build
|
19
|
-
raise instance
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
7
|
module Backtrace
|
24
8
|
if RUBY_ENGINE != 'mruby'
|
25
9
|
def self.frame(frame_index)
|
@@ -91,7 +75,6 @@ module TestBench
|
|
91
75
|
|
92
76
|
def assert_raises(error_class=nil, &block)
|
93
77
|
begin
|
94
|
-
Output.raw_write("assert_raises\n")
|
95
78
|
block.()
|
96
79
|
|
97
80
|
rescue (error_class || StandardError) => error
|
@@ -124,55 +107,46 @@ module TestBench
|
|
124
107
|
raise AssertionFailure.build(1)
|
125
108
|
end
|
126
109
|
|
127
|
-
def context(
|
110
|
+
def context(title=nil, &block)
|
128
111
|
if block.nil?
|
129
|
-
Output.write(
|
112
|
+
Output.write(title || 'Context', sgr_code: 0x33)
|
130
113
|
return
|
131
114
|
end
|
132
115
|
|
133
|
-
unless
|
134
|
-
Output.indent(
|
116
|
+
unless title.nil?
|
117
|
+
Output.indent(title, sgr_code: 0x32) do
|
135
118
|
context(&block)
|
136
119
|
end
|
137
120
|
return
|
138
121
|
end
|
139
122
|
|
140
|
-
|
141
|
-
block.()
|
142
|
-
|
143
|
-
rescue => error
|
144
|
-
Output.error(error)
|
145
|
-
|
146
|
-
Abort.()
|
147
|
-
end
|
123
|
+
block.()
|
148
124
|
end
|
149
125
|
|
150
|
-
def _context(
|
151
|
-
context(
|
126
|
+
def _context(title=nil, &block)
|
127
|
+
context(title)
|
152
128
|
end
|
153
129
|
|
154
|
-
def test(
|
130
|
+
def test(title=nil, &block)
|
155
131
|
if block.nil?
|
156
|
-
Output.write(
|
132
|
+
Output.write(title || 'Test', sgr_code: 0x33)
|
157
133
|
return
|
158
134
|
end
|
159
135
|
|
160
136
|
begin
|
161
137
|
block.()
|
162
138
|
|
163
|
-
Output.indent(
|
139
|
+
Output.indent(title, sgr_code: 0x32)
|
164
140
|
|
165
141
|
rescue => error
|
166
|
-
Output.indent(
|
167
|
-
Output.error(error)
|
168
|
-
end
|
142
|
+
Output.indent(title || 'Test', sgr_codes: [0x1, 0x31])
|
169
143
|
|
170
|
-
|
144
|
+
raise error
|
171
145
|
end
|
172
146
|
end
|
173
147
|
|
174
|
-
def _test(
|
175
|
-
test(
|
148
|
+
def _test(title=nil, &block)
|
149
|
+
test(title)
|
176
150
|
end
|
177
151
|
|
178
152
|
def comment(text)
|
@@ -199,63 +173,6 @@ module TestBench
|
|
199
173
|
indent(text, device: device, sgr_code: sgr_code, sgr_codes: sgr_codes, tab_indent: tab_indent)
|
200
174
|
end
|
201
175
|
|
202
|
-
def error(error)
|
203
|
-
omit_backtrace_pattern = Defaults.omit_backtrace_pattern
|
204
|
-
|
205
|
-
omitting = false
|
206
|
-
|
207
|
-
write("\e[1mTraceback\e[22m (most recent call last):", sgr_code: 0x31)
|
208
|
-
|
209
|
-
rjust_length = error.backtrace.length.to_s.length
|
210
|
-
|
211
|
-
reverse_backtrace = error.backtrace[1..-1].reverse
|
212
|
-
|
213
|
-
reverse_backtrace.each_with_index do |frame, index|
|
214
|
-
frame = frame.dup
|
215
|
-
frame.chomp!
|
216
|
-
|
217
|
-
previous_frame = frame
|
218
|
-
|
219
|
-
file, _ = frame.split(':', 2)
|
220
|
-
|
221
|
-
line = ' ' * rjust_length
|
222
|
-
|
223
|
-
index_text = index.to_s
|
224
|
-
index_range = (-index_text.length..-1)
|
225
|
-
|
226
|
-
if Path.match?(omit_backtrace_pattern, file)
|
227
|
-
if omitting
|
228
|
-
next
|
229
|
-
else
|
230
|
-
omitting = true
|
231
|
-
|
232
|
-
line[index_range] = '?' * index_text.length
|
233
|
-
line += ": *omitted*"
|
234
|
-
|
235
|
-
write(line, sgr_codes: [0x2, 0x3, 0x31], tab_indent: true)
|
236
|
-
end
|
237
|
-
else
|
238
|
-
omitting = false
|
239
|
-
|
240
|
-
line[index_range] = index_text
|
241
|
-
line += ": #{frame}"
|
242
|
-
|
243
|
-
write(line, sgr_code: 0x31, tab_indent: true)
|
244
|
-
end
|
245
|
-
end
|
246
|
-
|
247
|
-
if error.message.empty?
|
248
|
-
if error.instance_of?(RuntimeError)
|
249
|
-
write("#{error.backtrace[0]}: \e[1;4munhandled exception\e[24;22m", sgr_code: 0x31)
|
250
|
-
return
|
251
|
-
end
|
252
|
-
|
253
|
-
error.message = error.class
|
254
|
-
end
|
255
|
-
|
256
|
-
write("#{error.backtrace[0]}: \e[1m#{error} (\e[4m#{error.class}\e[24m)\e[22m", sgr_code: 0x31)
|
257
|
-
end
|
258
|
-
|
259
176
|
def newline
|
260
177
|
write('')
|
261
178
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: test_bench-bootstrap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Ladd
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-09-16 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email: nathanladd+github@gmail.com
|