test_bench-bootstrap 3.0.0.0.pre.1 → 3.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/bootstrap.rb +373 -0
- metadata +16 -353
- data/executables/bench-bootstrap +0 -7
- data/lib/test_bench_bootstrap/controls.rb +0 -1
- data/lib/test_bench_bootstrap/test_bench_bootstrap.rb +0 -7
- data/lib/test_bench_bootstrap.rb +0 -4
- data/upstream-lib/test_bench_bootstrap/import_constants/controls/namespace.rb +0 -84
- data/upstream-lib/test_bench_bootstrap/import_constants/controls.rb +0 -1
- data/upstream-lib/test_bench_bootstrap/import_constants/import_constants.rb +0 -46
- data/upstream-lib/test_bench_bootstrap/import_constants/macro.rb +0 -10
- data/upstream-lib/test_bench_bootstrap/import_constants.rb +0 -2
- data/upstream-lib/test_bench_bootstrap/test_bench/controls/telemetry_sink.rb +0 -7
- data/upstream-lib/test_bench_bootstrap/test_bench/controls.rb +0 -3
- data/upstream-lib/test_bench_bootstrap/test_bench/executable/controls/path.rb +0 -9
- data/upstream-lib/test_bench_bootstrap/test_bench/executable/controls/random.rb +0 -9
- data/upstream-lib/test_bench_bootstrap/test_bench/executable/controls/run.rb +0 -12
- data/upstream-lib/test_bench_bootstrap/test_bench/executable/controls/standard_input.rb +0 -31
- data/upstream-lib/test_bench_bootstrap/test_bench/executable/controls.rb +0 -8
- data/upstream-lib/test_bench_bootstrap/test_bench/executable/defaults.rb +0 -15
- data/upstream-lib/test_bench_bootstrap/test_bench/executable/executable.rb +0 -61
- data/upstream-lib/test_bench_bootstrap/test_bench/executable/parse_arguments.rb +0 -271
- data/upstream-lib/test_bench_bootstrap/test_bench/executable.rb +0 -7
- data/upstream-lib/test_bench_bootstrap/test_bench/fixture/build.rb +0 -41
- data/upstream-lib/test_bench_bootstrap/test_bench/fixture/controls/comment_style.rb +0 -9
- data/upstream-lib/test_bench_bootstrap/test_bench/fixture/controls/exception.rb +0 -9
- data/upstream-lib/test_bench_bootstrap/test_bench/fixture/controls/fixture.rb +0 -69
- data/upstream-lib/test_bench_bootstrap/test_bench/fixture/controls/message.rb +0 -9
- data/upstream-lib/test_bench_bootstrap/test_bench/fixture/controls/output.rb +0 -11
- data/upstream-lib/test_bench_bootstrap/test_bench/fixture/controls/path.rb +0 -9
- data/upstream-lib/test_bench_bootstrap/test_bench/fixture/controls/session.rb +0 -21
- data/upstream-lib/test_bench_bootstrap/test_bench/fixture/controls/status.rb +0 -9
- data/upstream-lib/test_bench_bootstrap/test_bench/fixture/controls/text.rb +0 -9
- data/upstream-lib/test_bench_bootstrap/test_bench/fixture/controls/title.rb +0 -9
- data/upstream-lib/test_bench_bootstrap/test_bench/fixture/controls.rb +0 -14
- data/upstream-lib/test_bench_bootstrap/test_bench/fixture/evaluate.rb +0 -37
- data/upstream-lib/test_bench_bootstrap/test_bench/fixture/fixture.rb +0 -213
- data/upstream-lib/test_bench_bootstrap/test_bench/fixture.rb +0 -7
- data/upstream-lib/test_bench_bootstrap/test_bench/output/comment_style.rb +0 -63
- data/upstream-lib/test_bench_bootstrap/test_bench/output/controls/comment_style.rb +0 -23
- data/upstream-lib/test_bench_bootstrap/test_bench/output/controls/event.rb +0 -9
- data/upstream-lib/test_bench_bootstrap/test_bench/output/controls/events/aborted.rb +0 -11
- data/upstream-lib/test_bench_bootstrap/test_bench/output/controls/events/commented.rb +0 -23
- data/upstream-lib/test_bench_bootstrap/test_bench/output/controls/events/context_finished.rb +0 -11
- data/upstream-lib/test_bench_bootstrap/test_bench/output/controls/events/context_started.rb +0 -11
- data/upstream-lib/test_bench_bootstrap/test_bench/output/controls/events/detailed.rb +0 -23
- data/upstream-lib/test_bench_bootstrap/test_bench/output/controls/events/failed.rb +0 -11
- data/upstream-lib/test_bench_bootstrap/test_bench/output/controls/events/file_executed.rb +0 -11
- data/upstream-lib/test_bench_bootstrap/test_bench/output/controls/events/file_not_found.rb +0 -11
- data/upstream-lib/test_bench_bootstrap/test_bench/output/controls/events/file_queued.rb +0 -11
- data/upstream-lib/test_bench_bootstrap/test_bench/output/controls/events/skipped.rb +0 -11
- data/upstream-lib/test_bench_bootstrap/test_bench/output/controls/events/test_finished.rb +0 -11
- data/upstream-lib/test_bench_bootstrap/test_bench/output/controls/events/test_started.rb +0 -11
- data/upstream-lib/test_bench_bootstrap/test_bench/output/controls/random.rb +0 -9
- data/upstream-lib/test_bench_bootstrap/test_bench/output/controls/session.rb +0 -19
- data/upstream-lib/test_bench_bootstrap/test_bench/output/controls/status.rb +0 -9
- data/upstream-lib/test_bench_bootstrap/test_bench/output/controls/style.rb +0 -41
- data/upstream-lib/test_bench_bootstrap/test_bench/output/controls/text.rb +0 -31
- data/upstream-lib/test_bench_bootstrap/test_bench/output/controls.rb +0 -26
- data/upstream-lib/test_bench_bootstrap/test_bench/output/detail_policy.rb +0 -46
- data/upstream-lib/test_bench_bootstrap/test_bench/output/device/null.rb +0 -21
- data/upstream-lib/test_bench_bootstrap/test_bench/output/device/substitute.rb +0 -46
- data/upstream-lib/test_bench_bootstrap/test_bench/output/device.rb +0 -75
- data/upstream-lib/test_bench_bootstrap/test_bench/output/get.rb +0 -32
- data/upstream-lib/test_bench_bootstrap/test_bench/output/level.rb +0 -53
- data/upstream-lib/test_bench_bootstrap/test_bench/output/output.rb +0 -572
- data/upstream-lib/test_bench_bootstrap/test_bench/output/writer/style.rb +0 -54
- data/upstream-lib/test_bench_bootstrap/test_bench/output/writer/substitute.rb +0 -27
- data/upstream-lib/test_bench_bootstrap/test_bench/output/writer.rb +0 -119
- data/upstream-lib/test_bench_bootstrap/test_bench/output.rb +0 -20
- data/upstream-lib/test_bench_bootstrap/test_bench/random/controls/seed.rb +0 -25
- data/upstream-lib/test_bench_bootstrap/test_bench/random/controls/sequence.rb +0 -70
- data/upstream-lib/test_bench_bootstrap/test_bench/random/controls.rb +0 -2
- data/upstream-lib/test_bench_bootstrap/test_bench/random/defaults.rb +0 -13
- data/upstream-lib/test_bench_bootstrap/test_bench/random/generator/substitute.rb +0 -23
- data/upstream-lib/test_bench_bootstrap/test_bench/random/generator.rb +0 -64
- data/upstream-lib/test_bench_bootstrap/test_bench/random/iterator.rb +0 -54
- data/upstream-lib/test_bench_bootstrap/test_bench/random/random.rb +0 -27
- data/upstream-lib/test_bench_bootstrap/test_bench/random.rb +0 -8
- data/upstream-lib/test_bench_bootstrap/test_bench/run/controls/events.rb +0 -9
- data/upstream-lib/test_bench_bootstrap/test_bench/run/controls/message.rb +0 -9
- data/upstream-lib/test_bench_bootstrap/test_bench/run/controls/path.rb +0 -9
- data/upstream-lib/test_bench_bootstrap/test_bench/run/controls/random.rb +0 -9
- data/upstream-lib/test_bench_bootstrap/test_bench/run/controls/session.rb +0 -16
- data/upstream-lib/test_bench_bootstrap/test_bench/run/controls/status.rb +0 -44
- data/upstream-lib/test_bench_bootstrap/test_bench/run/controls/summary/file/info.rb +0 -108
- data/upstream-lib/test_bench_bootstrap/test_bench/run/controls/summary/file/totals.rb +0 -38
- data/upstream-lib/test_bench_bootstrap/test_bench/run/controls/summary/file.rb +0 -44
- data/upstream-lib/test_bench_bootstrap/test_bench/run/controls/summary/run.rb +0 -53
- data/upstream-lib/test_bench_bootstrap/test_bench/run/controls/summary.rb +0 -45
- data/upstream-lib/test_bench_bootstrap/test_bench/run/controls/telemetry.rb +0 -11
- data/upstream-lib/test_bench_bootstrap/test_bench/run/controls/time.rb +0 -9
- data/upstream-lib/test_bench_bootstrap/test_bench/run/controls.rb +0 -20
- data/upstream-lib/test_bench_bootstrap/test_bench/run/run.rb +0 -146
- data/upstream-lib/test_bench_bootstrap/test_bench/run/select_files/substitute.rb +0 -45
- data/upstream-lib/test_bench_bootstrap/test_bench/run/select_files.rb +0 -70
- data/upstream-lib/test_bench_bootstrap/test_bench/run/substitute.rb +0 -42
- data/upstream-lib/test_bench_bootstrap/test_bench/run/summary/substitute.rb +0 -19
- data/upstream-lib/test_bench_bootstrap/test_bench/run/summary.rb +0 -477
- data/upstream-lib/test_bench_bootstrap/test_bench/run.rb +0 -10
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/backtrace/location.rb +0 -48
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/backtrace.rb +0 -83
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/comment_disposition.rb +0 -17
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/event.rb +0 -35
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/events/aborted.rb +0 -51
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/events/commented.rb +0 -62
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/events/context_finished.rb +0 -112
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/events/context_started.rb +0 -51
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/events/detailed.rb +0 -62
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/events/failed.rb +0 -41
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/events/file_executed.rb +0 -101
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/events/file_not_found.rb +0 -41
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/events/file_queued.rb +0 -41
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/events/skipped.rb +0 -51
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/events/test_finished.rb +0 -92
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/events/test_started.rb +0 -51
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/events.rb +0 -35
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/exception/message.rb +0 -23
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/exception/raise.rb +0 -52
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/exception.rb +0 -81
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/message.rb +0 -43
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/metadata.rb +0 -9
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/path/apex_directory.rb +0 -76
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/path/file/create.rb +0 -113
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/path/file.rb +0 -42
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/path.rb +0 -87
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/random.rb +0 -9
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/result.rb +0 -17
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/sequence.rb +0 -13
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/status.rb +0 -92
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/telemetry.rb +0 -15
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/telemetry_sink.rb +0 -37
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/text.rb +0 -33
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/title.rb +0 -41
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls.rb +0 -43
- data/upstream-lib/test_bench_bootstrap/test_bench/session/defaults.rb +0 -17
- data/upstream-lib/test_bench_bootstrap/test_bench/session/events.rb +0 -24
- data/upstream-lib/test_bench_bootstrap/test_bench/session/exception/format_backtrace/substitute.rb +0 -34
- data/upstream-lib/test_bench_bootstrap/test_bench/session/exception/format_backtrace.rb +0 -114
- data/upstream-lib/test_bench_bootstrap/test_bench/session/isolate/substitute.rb +0 -45
- data/upstream-lib/test_bench_bootstrap/test_bench/session/isolate.rb +0 -159
- data/upstream-lib/test_bench_bootstrap/test_bench/session/result.rb +0 -44
- data/upstream-lib/test_bench_bootstrap/test_bench/session/session.rb +0 -236
- data/upstream-lib/test_bench_bootstrap/test_bench/session/status.rb +0 -60
- data/upstream-lib/test_bench_bootstrap/test_bench/session/substitute/sink.rb +0 -99
- data/upstream-lib/test_bench_bootstrap/test_bench/session/substitute.rb +0 -154
- data/upstream-lib/test_bench_bootstrap/test_bench/session/trace.rb +0 -53
- data/upstream-lib/test_bench_bootstrap/test_bench/session.rb +0 -22
- data/upstream-lib/test_bench_bootstrap/test_bench/telemetry/controls/event/metadata.rb +0 -72
- data/upstream-lib/test_bench_bootstrap/test_bench/telemetry/controls/event.rb +0 -156
- data/upstream-lib/test_bench_bootstrap/test_bench/telemetry/controls/event_data.rb +0 -113
- data/upstream-lib/test_bench_bootstrap/test_bench/telemetry/controls/handler.rb +0 -83
- data/upstream-lib/test_bench_bootstrap/test_bench/telemetry/controls/path/file.rb +0 -39
- data/upstream-lib/test_bench_bootstrap/test_bench/telemetry/controls/process_id.rb +0 -25
- data/upstream-lib/test_bench_bootstrap/test_bench/telemetry/controls/random.rb +0 -11
- data/upstream-lib/test_bench_bootstrap/test_bench/telemetry/controls/sink.rb +0 -35
- data/upstream-lib/test_bench_bootstrap/test_bench/telemetry/controls/time.rb +0 -104
- data/upstream-lib/test_bench_bootstrap/test_bench/telemetry/controls.rb +0 -16
- data/upstream-lib/test_bench_bootstrap/test_bench/telemetry/event.rb +0 -130
- data/upstream-lib/test_bench_bootstrap/test_bench/telemetry/event_data/serialization.rb +0 -85
- data/upstream-lib/test_bench_bootstrap/test_bench/telemetry/event_data.rb +0 -15
- data/upstream-lib/test_bench_bootstrap/test_bench/telemetry/sink/file.rb +0 -39
- data/upstream-lib/test_bench_bootstrap/test_bench/telemetry/sink/handler/event_registry.rb +0 -44
- data/upstream-lib/test_bench_bootstrap/test_bench/telemetry/sink/handler.rb +0 -128
- data/upstream-lib/test_bench_bootstrap/test_bench/telemetry/sink.rb +0 -13
- data/upstream-lib/test_bench_bootstrap/test_bench/telemetry/substitute/sink.rb +0 -71
- data/upstream-lib/test_bench_bootstrap/test_bench/telemetry/substitute.rb +0 -43
- data/upstream-lib/test_bench_bootstrap/test_bench/telemetry/telemetry.rb +0 -92
- data/upstream-lib/test_bench_bootstrap/test_bench/telemetry.rb +0 -18
- data/upstream-lib/test_bench_bootstrap/test_bench/test_bench.rb +0 -72
- data/upstream-lib/test_bench_bootstrap/test_bench.rb +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b4e2e358c29830ece30c5a9516c4cf96fe2d6748cb1a3c88e9d3d05727c66f9a
|
4
|
+
data.tar.gz: d07c4e27d9c6440427ff716ff8fe6cf405940287417c5f0f69e90560d6c140da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 787ba756e146d4b72a0a7dd265df1baa3c4ddab27bf78e3e0d271dd1b333a7006e1e486b0369c9727ffed7bf15adb9e150fe8a13b7f743b2833a0b78ee9cf881
|
7
|
+
data.tar.gz: faf41a1355cf5cc3a20cc46aa25cd1e1b62b4bb69da66ef25bc20b2efdacabdfe6d0f736908120f6ecab24f7b011d4ecee36bfa94ce78d0271da878260023681
|
@@ -0,0 +1,373 @@
|
|
1
|
+
module TestBench
|
2
|
+
module Bootstrap
|
3
|
+
def self.activate
|
4
|
+
Object.include(Fixture)
|
5
|
+
end
|
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
|
+
module Backtrace
|
24
|
+
if RUBY_ENGINE != 'mruby'
|
25
|
+
def self.frame(frame_index)
|
26
|
+
frame_index += 1
|
27
|
+
|
28
|
+
caller[frame_index]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
class AssertionFailure < RuntimeError
|
34
|
+
def self.build(frame_index=nil)
|
35
|
+
frame_index ||= 0
|
36
|
+
|
37
|
+
frame = Backtrace.frame(frame_index)
|
38
|
+
|
39
|
+
instance = new
|
40
|
+
instance.set_backtrace([frame])
|
41
|
+
instance
|
42
|
+
end
|
43
|
+
|
44
|
+
def message
|
45
|
+
"Assertion failed"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
module Path
|
50
|
+
if RUBY_ENGINE != 'mruby'
|
51
|
+
def self.match?(pattern, string)
|
52
|
+
::File.fnmatch?(pattern, string)
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.search(path, include_pattern=nil, exclude_pattern=nil)
|
56
|
+
files = []
|
57
|
+
|
58
|
+
if ::File.directory?(path)
|
59
|
+
search_directory(path, files, include_pattern, exclude_pattern)
|
60
|
+
elsif ::File.exist?(path)
|
61
|
+
files << path
|
62
|
+
else
|
63
|
+
raise LoadError, "no such file or directory -- #{path}"
|
64
|
+
end
|
65
|
+
|
66
|
+
files
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.search_directory(dir, files, include_pattern=nil, exclude_pattern=nil)
|
70
|
+
include_pattern ||= '*.rb'
|
71
|
+
|
72
|
+
::Dir[::File.join(dir, '**', '*')].each do |path|
|
73
|
+
next if ::File.directory?(path)
|
74
|
+
|
75
|
+
if match?(include_pattern, path)
|
76
|
+
if exclude_pattern.nil? || !match?(exclude_pattern, path)
|
77
|
+
files << path
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
module Fixture
|
86
|
+
def assert(value)
|
87
|
+
unless value
|
88
|
+
raise AssertionFailure.build(1)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def assert_raises(error_class=nil, &block)
|
93
|
+
begin
|
94
|
+
Output.raw_write("assert_raises\n")
|
95
|
+
block.()
|
96
|
+
|
97
|
+
rescue (error_class || StandardError) => error
|
98
|
+
return if error_class.nil?
|
99
|
+
|
100
|
+
if error.instance_of?(error_class)
|
101
|
+
return
|
102
|
+
else
|
103
|
+
raise error
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
raise AssertionFailure.build(1)
|
108
|
+
end
|
109
|
+
|
110
|
+
def refute(value)
|
111
|
+
if value
|
112
|
+
raise AssertionFailure.build(1)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
def refute_raises(error_class=nil, &block)
|
117
|
+
block.()
|
118
|
+
|
119
|
+
rescue (error_class || StandardError) => error
|
120
|
+
unless error.instance_of?(error_class)
|
121
|
+
raise error
|
122
|
+
end
|
123
|
+
|
124
|
+
raise AssertionFailure.build(1)
|
125
|
+
end
|
126
|
+
|
127
|
+
def context(prose=nil, &block)
|
128
|
+
if block.nil?
|
129
|
+
Output.write(prose || 'Context', sgr_code: 0x33)
|
130
|
+
return
|
131
|
+
end
|
132
|
+
|
133
|
+
unless prose.nil?
|
134
|
+
Output.indent(prose, sgr_code: 0x32) do
|
135
|
+
context(&block)
|
136
|
+
end
|
137
|
+
return
|
138
|
+
end
|
139
|
+
|
140
|
+
begin
|
141
|
+
block.()
|
142
|
+
|
143
|
+
rescue => error
|
144
|
+
Output.error(error)
|
145
|
+
|
146
|
+
Abort.()
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
def _context(prose=nil, &block)
|
151
|
+
context(prose)
|
152
|
+
end
|
153
|
+
|
154
|
+
def test(prose=nil, &block)
|
155
|
+
if block.nil?
|
156
|
+
Output.write(prose || 'Test', sgr_code: 0x33)
|
157
|
+
return
|
158
|
+
end
|
159
|
+
|
160
|
+
begin
|
161
|
+
block.()
|
162
|
+
|
163
|
+
Output.indent(prose, sgr_code: 0x32)
|
164
|
+
|
165
|
+
rescue => error
|
166
|
+
Output.indent(prose, sgr_codes: [0x1, 0x31]) do
|
167
|
+
Output.error(error)
|
168
|
+
end
|
169
|
+
|
170
|
+
Abort.()
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
def _test(prose=nil, &block)
|
175
|
+
test(prose)
|
176
|
+
end
|
177
|
+
|
178
|
+
def comment(text)
|
179
|
+
Output.write(text)
|
180
|
+
end
|
181
|
+
|
182
|
+
def detail(text)
|
183
|
+
comment(text)
|
184
|
+
end
|
185
|
+
|
186
|
+
def fixture(cls, *args, **kwargs, &block)
|
187
|
+
fixture = TestBench::Fixture.(cls, *args, **kwargs, &block)
|
188
|
+
|
189
|
+
passed = !fixture.test_session.failed?
|
190
|
+
|
191
|
+
assert(passed)
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
module Output
|
196
|
+
extend self
|
197
|
+
|
198
|
+
def write(text, device: nil, sgr_code: nil, sgr_codes: nil, tab_indent: nil)
|
199
|
+
indent(text, device: device, sgr_code: sgr_code, sgr_codes: sgr_codes, tab_indent: tab_indent)
|
200
|
+
end
|
201
|
+
|
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
|
+
def newline
|
260
|
+
write('')
|
261
|
+
end
|
262
|
+
|
263
|
+
def indent(text, device: nil, sgr_code: nil, sgr_codes: nil, tab_indent: nil, &block)
|
264
|
+
unless text.nil?
|
265
|
+
sgr_codes ||= []
|
266
|
+
unless sgr_code.nil?
|
267
|
+
sgr_codes << sgr_code
|
268
|
+
end
|
269
|
+
|
270
|
+
unless sgr_codes.empty?
|
271
|
+
sgr_codes.map! do |sgr_code|
|
272
|
+
sgr_code.to_s(16)
|
273
|
+
end
|
274
|
+
|
275
|
+
text = "\e[#{sgr_codes.join(';')}m#{text}\e[0m"
|
276
|
+
end
|
277
|
+
|
278
|
+
text = "#{"\t" if tab_indent}#{' ' * indentation}#{text}\n"
|
279
|
+
|
280
|
+
raw_write(text, device)
|
281
|
+
end
|
282
|
+
|
283
|
+
return if block.nil?
|
284
|
+
|
285
|
+
self.indentation += 1 unless text.nil?
|
286
|
+
|
287
|
+
begin
|
288
|
+
block.()
|
289
|
+
ensure
|
290
|
+
self.indentation -= 1 unless text.nil?
|
291
|
+
end
|
292
|
+
end
|
293
|
+
|
294
|
+
def raw_write(text, device=nil)
|
295
|
+
device ||= self.device
|
296
|
+
|
297
|
+
device.write(text)
|
298
|
+
end
|
299
|
+
|
300
|
+
def indentation
|
301
|
+
@indentation ||= 0
|
302
|
+
end
|
303
|
+
attr_writer :indentation
|
304
|
+
|
305
|
+
def device
|
306
|
+
@device ||= Defaults.output_device
|
307
|
+
end
|
308
|
+
end
|
309
|
+
|
310
|
+
module Run
|
311
|
+
def self.call(paths=nil, exclude_pattern: nil)
|
312
|
+
paths ||= []
|
313
|
+
exclude_pattern ||= Defaults.exclude_file_pattern
|
314
|
+
|
315
|
+
if paths.is_a?(String)
|
316
|
+
paths = [paths]
|
317
|
+
end
|
318
|
+
|
319
|
+
if paths.empty?
|
320
|
+
paths << Defaults.tests_dir
|
321
|
+
end
|
322
|
+
|
323
|
+
paths.each do |path|
|
324
|
+
Path.search(path, '*.rb', exclude_pattern).each do |file|
|
325
|
+
Output.write "Running #{file}"
|
326
|
+
|
327
|
+
begin
|
328
|
+
load(file)
|
329
|
+
ensure
|
330
|
+
Output.newline
|
331
|
+
end
|
332
|
+
end
|
333
|
+
end
|
334
|
+
end
|
335
|
+
end
|
336
|
+
|
337
|
+
module Defaults
|
338
|
+
def self.get(env_var, default)
|
339
|
+
if env.key?(env_var)
|
340
|
+
env[env_var]
|
341
|
+
else
|
342
|
+
default
|
343
|
+
end
|
344
|
+
end
|
345
|
+
|
346
|
+
def self.exclude_file_pattern
|
347
|
+
get('TEST_BENCH_EXCLUDE_FILE_PATTERN', '*_init.rb')
|
348
|
+
end
|
349
|
+
|
350
|
+
def self.omit_backtrace_pattern
|
351
|
+
get('TEST_BENCH_OMIT_BACKTRACE_PATTERN', '*/test_bench/bootstrap.rb')
|
352
|
+
end
|
353
|
+
|
354
|
+
def self.tests_dir
|
355
|
+
get('TEST_BENCH_TESTS_DIRECTORY', 'test/automated')
|
356
|
+
end
|
357
|
+
|
358
|
+
if RUBY_ENGINE == 'mruby'
|
359
|
+
def self.env
|
360
|
+
{}
|
361
|
+
end
|
362
|
+
else
|
363
|
+
def self.output_device
|
364
|
+
$stdout
|
365
|
+
end
|
366
|
+
|
367
|
+
def self.env
|
368
|
+
::ENV
|
369
|
+
end
|
370
|
+
end
|
371
|
+
end
|
372
|
+
end
|
373
|
+
end
|