test_bench-bootstrap 2.0.0 → 2.1.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/bootstrap.rb +35 -22
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1b400c74d1b0dfc2f2ce3332d525109cb9a1643ddeba0f65e440eba9acd6b84a
|
4
|
+
data.tar.gz: 45ee30ba63adf373048a53d40d2e956fef6fc1bbaf3392cce964bcd7d3136325
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be4671d8025e1be20ebe53d926d5e3e1919a00c54f23f2743ad00df0cc3dcb7422651bb499fc43a7c4bae2be8eb281d48a4d2d25568d0bd0c9f3ecc474951e56
|
7
|
+
data.tar.gz: c6bfab181eabcc5d608f17f688f3d7150b0d6cbae5c2604a36e6636a7cdd576f0a381953634fa5a9b13d544da6c358e64863d89bc1f4a9134a0c6e7f26a799b3
|
data/lib/test_bench/bootstrap.rb
CHANGED
@@ -9,7 +9,7 @@ module TestBench
|
|
9
9
|
module Fixture
|
10
10
|
def assert(value)
|
11
11
|
unless value
|
12
|
-
raise AssertionFailure.build(
|
12
|
+
raise AssertionFailure.build(caller.first)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
@@ -27,12 +27,12 @@ module TestBench
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
raise AssertionFailure.build(
|
30
|
+
raise AssertionFailure.build(caller.first)
|
31
31
|
end
|
32
32
|
|
33
33
|
def refute(value)
|
34
34
|
if value
|
35
|
-
raise AssertionFailure.build(
|
35
|
+
raise AssertionFailure.build(caller.first)
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
@@ -44,7 +44,7 @@ module TestBench
|
|
44
44
|
raise error
|
45
45
|
end
|
46
46
|
|
47
|
-
raise AssertionFailure.build(
|
47
|
+
raise AssertionFailure.build(caller.first)
|
48
48
|
end
|
49
49
|
|
50
50
|
def context(prose=nil, &block)
|
@@ -116,42 +116,55 @@ module TestBench
|
|
116
116
|
|
117
117
|
omitting = false
|
118
118
|
|
119
|
-
|
119
|
+
Output.write("\e[1mTraceback\e[22m (most recent call last):", sgr_code: 0x31)
|
120
|
+
|
121
|
+
rjust_length = error.backtrace.length.to_s.length
|
122
|
+
|
123
|
+
error.backtrace[1..-1].reverse_each.with_index do |line, index|
|
124
|
+
line = line.dup
|
120
125
|
|
121
|
-
error_message.each_line.with_index do |line, index|
|
122
126
|
line.chomp!
|
123
127
|
|
124
|
-
if
|
128
|
+
if omit_backtrace_pattern.match?(line)
|
125
129
|
if omitting
|
126
130
|
next
|
127
131
|
else
|
128
132
|
omitting = true
|
129
133
|
|
130
|
-
|
131
|
-
|
132
|
-
line.slice!(indentation..-1)
|
133
|
-
line.gsub!(%r{[[:digit:]]}, '?')
|
134
|
-
line.concat("*omitted*")
|
134
|
+
header = index.to_s.gsub(/./, '?').rjust(rjust_length, ' ')
|
135
135
|
|
136
|
-
Output.write(
|
136
|
+
Output.write("#{header}: *omitted*", sgr_codes: [0x2, 0x3, 0x31], tab_indent: true)
|
137
137
|
end
|
138
138
|
else
|
139
139
|
omitting = false
|
140
140
|
|
141
|
-
|
141
|
+
header = index.to_s.rjust(rjust_length, ' ')
|
142
|
+
|
143
|
+
Output.write("#{header}: #{line}", sgr_code: 0x31, tab_indent: true)
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
if error.message.empty?
|
148
|
+
if error.instance_of?(RuntimeError)
|
149
|
+
Output.write("#{error.backtrace[0]}: \e[1;4munhandled exception\e[24;22m", sgr_code: 0x31)
|
150
|
+
return
|
142
151
|
end
|
152
|
+
|
153
|
+
error.message = error.class
|
143
154
|
end
|
155
|
+
|
156
|
+
Output.write("#{error.backtrace[0]} \e[1m#{error} (\e[4m#{error.class}\e[24m)\e[22m", sgr_code: 0x31)
|
144
157
|
end
|
145
158
|
end
|
146
159
|
|
147
160
|
module Output
|
148
161
|
extend self
|
149
162
|
|
150
|
-
def write(text, device: nil, sgr_code: nil, sgr_codes: nil)
|
151
|
-
indent(text, device: device, sgr_code: sgr_code, sgr_codes: sgr_codes)
|
163
|
+
def write(text, device: nil, sgr_code: nil, sgr_codes: nil, tab_indent: nil)
|
164
|
+
indent(text, device: device, sgr_code: sgr_code, sgr_codes: sgr_codes, tab_indent: tab_indent)
|
152
165
|
end
|
153
166
|
|
154
|
-
def indent(text, device: nil, sgr_code: nil, sgr_codes: nil, &block)
|
167
|
+
def indent(text, device: nil, sgr_code: nil, sgr_codes: nil, tab_indent: nil, &block)
|
155
168
|
device ||= $stdout
|
156
169
|
|
157
170
|
unless text.nil?
|
@@ -165,10 +178,10 @@ module TestBench
|
|
165
178
|
sgr_code.to_s(16)
|
166
179
|
end
|
167
180
|
|
168
|
-
text = "\e[#{sgr_codes
|
181
|
+
text = "\e[#{sgr_codes.join(';')}m#{text}\e[0m"
|
169
182
|
end
|
170
183
|
|
171
|
-
text = "#{' ' * indentation}#{text}"
|
184
|
+
text = "#{"\t" if tab_indent}#{' ' * indentation}#{text}"
|
172
185
|
|
173
186
|
device.puts(text)
|
174
187
|
end
|
@@ -192,10 +205,10 @@ module TestBench
|
|
192
205
|
|
193
206
|
class AssertionFailure < RuntimeError
|
194
207
|
def self.build(caller_location=nil)
|
195
|
-
caller_location ||=
|
208
|
+
caller_location ||= caller(0)
|
196
209
|
|
197
210
|
instance = new
|
198
|
-
instance.set_backtrace([caller_location
|
211
|
+
instance.set_backtrace([caller_location])
|
199
212
|
instance
|
200
213
|
end
|
201
214
|
|
@@ -206,7 +219,7 @@ module TestBench
|
|
206
219
|
|
207
220
|
class Failure < SystemExit
|
208
221
|
def self.build
|
209
|
-
new(
|
222
|
+
new(1, "TestBench::Bootstrap is aborting")
|
210
223
|
end
|
211
224
|
end
|
212
225
|
|
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: test_bench-bootstrap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Ladd
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description:
|
13
|
+
description:
|
14
14
|
email: nathanladd+github@gmail.com
|
15
15
|
executables: []
|
16
16
|
extensions: []
|
@@ -21,7 +21,7 @@ homepage: https://github.com/test-bench/test-bench-bootstrap
|
|
21
21
|
licenses:
|
22
22
|
- MIT
|
23
23
|
metadata: {}
|
24
|
-
post_install_message:
|
24
|
+
post_install_message:
|
25
25
|
rdoc_options: []
|
26
26
|
require_paths:
|
27
27
|
- lib
|
@@ -36,8 +36,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
36
36
|
- !ruby/object:Gem::Version
|
37
37
|
version: '0'
|
38
38
|
requirements: []
|
39
|
-
rubygems_version: 3.
|
40
|
-
signing_key:
|
39
|
+
rubygems_version: 3.1.4
|
40
|
+
signing_key:
|
41
41
|
specification_version: 4
|
42
42
|
summary: A minimal test framework for testing TestBench
|
43
43
|
test_files: []
|