test_bench-bootstrap 6.1.1 → 7.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/executables/bench-bootstrap +7 -0
- data/lib/test_bench_bootstrap/controls.rb +1 -0
- data/lib/test_bench_bootstrap/test_bench_bootstrap.rb +7 -0
- data/lib/test_bench_bootstrap.rb +4 -0
- data/upstream-lib/test_bench_bootstrap/import_constants/controls/namespace.rb +84 -0
- data/upstream-lib/test_bench_bootstrap/import_constants/controls.rb +1 -0
- data/upstream-lib/test_bench_bootstrap/import_constants/import_constants.rb +46 -0
- data/upstream-lib/test_bench_bootstrap/import_constants/macro.rb +10 -0
- data/upstream-lib/test_bench_bootstrap/import_constants.rb +2 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/controls/telemetry_sink.rb +7 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/controls.rb +3 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/executable/controls/path.rb +9 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/executable/controls/random.rb +9 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/executable/controls/run.rb +12 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/executable/controls/standard_input.rb +31 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/executable/controls.rb +8 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/executable/defaults.rb +15 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/executable/executable.rb +61 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/executable/parse_arguments.rb +271 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/executable.rb +7 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/fixture/build.rb +41 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/fixture/controls/comment_style.rb +9 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/fixture/controls/exception.rb +9 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/fixture/controls/fixture.rb +69 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/fixture/controls/message.rb +9 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/fixture/controls/output.rb +11 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/fixture/controls/path.rb +9 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/fixture/controls/session.rb +21 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/fixture/controls/status.rb +9 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/fixture/controls/text.rb +9 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/fixture/controls/title.rb +9 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/fixture/controls.rb +14 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/fixture/evaluate.rb +37 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/fixture/fixture.rb +213 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/fixture.rb +7 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/output/comment_style.rb +63 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/output/controls/comment_style.rb +23 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/output/controls/event.rb +9 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/output/controls/events/aborted.rb +11 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/output/controls/events/commented.rb +23 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/output/controls/events/context_finished.rb +11 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/output/controls/events/context_started.rb +11 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/output/controls/events/detailed.rb +23 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/output/controls/events/failed.rb +11 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/output/controls/events/file_executed.rb +11 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/output/controls/events/file_not_found.rb +11 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/output/controls/events/file_queued.rb +11 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/output/controls/events/skipped.rb +11 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/output/controls/events/test_finished.rb +11 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/output/controls/events/test_started.rb +11 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/output/controls/random.rb +9 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/output/controls/session.rb +19 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/output/controls/status.rb +9 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/output/controls/style.rb +41 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/output/controls/text.rb +31 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/output/controls.rb +26 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/output/detail_policy.rb +46 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/output/device/null.rb +21 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/output/device/substitute.rb +46 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/output/device.rb +75 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/output/get.rb +32 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/output/level.rb +53 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/output/output.rb +572 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/output/writer/style.rb +54 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/output/writer/substitute.rb +27 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/output/writer.rb +119 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/output.rb +20 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/random/controls/seed.rb +25 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/random/controls/sequence.rb +70 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/random/controls.rb +2 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/random/defaults.rb +13 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/random/generator/substitute.rb +23 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/random/generator.rb +64 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/random/iterator.rb +54 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/random/random.rb +27 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/random.rb +8 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/run/controls/events.rb +9 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/run/controls/message.rb +9 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/run/controls/path.rb +9 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/run/controls/random.rb +9 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/run/controls/session.rb +16 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/run/controls/status.rb +44 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/run/controls/summary/file/info.rb +108 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/run/controls/summary/file/totals.rb +38 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/run/controls/summary/file.rb +44 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/run/controls/summary/run.rb +53 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/run/controls/summary.rb +45 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/run/controls/telemetry.rb +11 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/run/controls/time.rb +9 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/run/controls.rb +20 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/run/run.rb +146 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/run/select_files/substitute.rb +45 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/run/select_files.rb +70 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/run/substitute.rb +42 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/run/summary/substitute.rb +19 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/run/summary.rb +477 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/run.rb +10 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/backtrace/location.rb +48 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/backtrace.rb +83 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/comment_disposition.rb +17 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/event.rb +35 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/events/aborted.rb +51 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/events/commented.rb +62 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/events/context_finished.rb +112 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/events/context_started.rb +51 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/events/detailed.rb +62 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/events/failed.rb +41 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/events/file_executed.rb +101 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/events/file_not_found.rb +41 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/events/file_queued.rb +41 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/events/skipped.rb +51 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/events/test_finished.rb +92 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/events/test_started.rb +51 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/events.rb +35 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/exception/message.rb +23 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/exception/raise.rb +52 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/exception.rb +81 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/message.rb +43 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/metadata.rb +9 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/path/apex_directory.rb +76 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/path/file/create.rb +113 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/path/file.rb +42 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/path.rb +87 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/random.rb +9 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/result.rb +17 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/sequence.rb +13 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/status.rb +92 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/telemetry.rb +15 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/telemetry_sink.rb +37 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/text.rb +33 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/title.rb +41 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/session/controls.rb +43 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/session/defaults.rb +17 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/session/events.rb +24 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/session/exception/format_backtrace/substitute.rb +34 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/session/exception/format_backtrace.rb +114 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/session/isolate/substitute.rb +45 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/session/isolate.rb +159 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/session/result.rb +44 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/session/session.rb +236 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/session/status.rb +60 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/session/substitute/sink.rb +99 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/session/substitute.rb +154 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/session/trace.rb +53 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/session.rb +22 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/telemetry/controls/event/metadata.rb +72 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/telemetry/controls/event.rb +156 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/telemetry/controls/event_data.rb +113 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/telemetry/controls/handler.rb +83 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/telemetry/controls/path/file.rb +39 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/telemetry/controls/process_id.rb +25 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/telemetry/controls/random.rb +11 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/telemetry/controls/sink.rb +35 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/telemetry/controls/time.rb +104 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/telemetry/controls.rb +16 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/telemetry/event.rb +130 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/telemetry/event_data/serialization.rb +85 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/telemetry/event_data.rb +15 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/telemetry/sink/file.rb +39 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/telemetry/sink/handler/event_registry.rb +44 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/telemetry/sink/handler.rb +128 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/telemetry/sink.rb +13 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/telemetry/substitute/sink.rb +71 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/telemetry/substitute.rb +43 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/telemetry/telemetry.rb +92 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/telemetry.rb +18 -0
- data/upstream-lib/test_bench_bootstrap/test_bench/test_bench.rb +72 -0
- data/upstream-lib/test_bench_bootstrap/test_bench.rb +4 -0
- metadata +353 -16
- data/lib/test_bench/bootstrap.rb +0 -328
@@ -0,0 +1,236 @@
|
|
1
|
+
module TestBenchBootstrap
|
2
|
+
module TestBench
|
3
|
+
class Session
|
4
|
+
Failure = Class.new(RuntimeError)
|
5
|
+
|
6
|
+
ExecutionBreak = Object.new
|
7
|
+
|
8
|
+
def telemetry
|
9
|
+
@telemetry ||= Telemetry::Substitute.build
|
10
|
+
end
|
11
|
+
attr_writer :telemetry
|
12
|
+
|
13
|
+
def format_backtrace
|
14
|
+
@format_backtrace ||= Exception::FormatBacktrace::Substitute.build
|
15
|
+
end
|
16
|
+
attr_writer :format_backtrace
|
17
|
+
|
18
|
+
def isolate
|
19
|
+
@isolate ||= Isolate::Substitute.build
|
20
|
+
end
|
21
|
+
attr_writer :isolate
|
22
|
+
|
23
|
+
def status
|
24
|
+
@status ||= Status.initial
|
25
|
+
end
|
26
|
+
attr_writer :status
|
27
|
+
|
28
|
+
def trace
|
29
|
+
@trace ||= Trace.new
|
30
|
+
end
|
31
|
+
attr_writer :trace
|
32
|
+
|
33
|
+
def assertion_sequence
|
34
|
+
@assertion_sequence ||= 0
|
35
|
+
end
|
36
|
+
attr_writer :assertion_sequence
|
37
|
+
|
38
|
+
def self.build
|
39
|
+
instance = new
|
40
|
+
|
41
|
+
Telemetry.configure(instance)
|
42
|
+
Exception::FormatBacktrace.configure(instance)
|
43
|
+
Isolate.configure(instance)
|
44
|
+
|
45
|
+
instance
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.instance
|
49
|
+
@instance ||= build
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.configure(receiver, session: nil, attr_name: nil)
|
53
|
+
session ||= instance
|
54
|
+
attr_name ||= :session
|
55
|
+
|
56
|
+
receiver.public_send(:"#{attr_name}=", session)
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.establish(session)
|
60
|
+
@instance = session
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.register_telemetry_sink(telemetry_sink)
|
64
|
+
instance.register_telemetry_sink(telemetry_sink)
|
65
|
+
end
|
66
|
+
|
67
|
+
def assert(value, failure_message)
|
68
|
+
self.assertion_sequence += 1
|
69
|
+
|
70
|
+
if not value
|
71
|
+
raise Failure, failure_message
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def comment(text, disposition=nil)
|
76
|
+
record_event(Events::Commented.build(text, disposition))
|
77
|
+
end
|
78
|
+
|
79
|
+
def detail(text, disposition=nil)
|
80
|
+
record_event(Events::Detailed.build(text, disposition))
|
81
|
+
end
|
82
|
+
|
83
|
+
def test(title=nil, &block)
|
84
|
+
record_event(Events::TestStarted.build(title))
|
85
|
+
|
86
|
+
pending_test_finished_event = Events::TestFinished.build(title)
|
87
|
+
|
88
|
+
evaluate(pending_test_finished_event) do
|
89
|
+
previous_sequence = self.assertion_sequence
|
90
|
+
|
91
|
+
block.()
|
92
|
+
|
93
|
+
if self.assertion_sequence == previous_sequence
|
94
|
+
raise Failure, "Test didn't perform an assertion"
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def context(title=nil, &block)
|
100
|
+
record_event(Events::ContextStarted.build(title))
|
101
|
+
|
102
|
+
pending_context_finished_event = Events::ContextFinished.build(title)
|
103
|
+
|
104
|
+
evaluate(pending_context_finished_event, &block)
|
105
|
+
end
|
106
|
+
|
107
|
+
def skip(message=nil)
|
108
|
+
record_event(Events::Skipped.build(message))
|
109
|
+
end
|
110
|
+
|
111
|
+
def execute(file_path)
|
112
|
+
if file_not_found?(file_path)
|
113
|
+
record_event(Events::FileNotFound.build(file_path))
|
114
|
+
return
|
115
|
+
end
|
116
|
+
|
117
|
+
record_event(Events::FileQueued.build(file_path))
|
118
|
+
|
119
|
+
pended_event = Events::FileExecuted.build(file_path, result)
|
120
|
+
|
121
|
+
evaluate(pended_event) do
|
122
|
+
isolate.(file_path) do |event_data|
|
123
|
+
record_event(event_data)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
def file_not_found?(file_path)
|
129
|
+
!File.exist?(file_path)
|
130
|
+
end
|
131
|
+
|
132
|
+
def register_telemetry_sink(telemetry_sink)
|
133
|
+
telemetry.register(telemetry_sink)
|
134
|
+
end
|
135
|
+
|
136
|
+
def inspect(raw: nil)
|
137
|
+
if raw
|
138
|
+
return super()
|
139
|
+
end
|
140
|
+
|
141
|
+
telemetry_placeholder = Struct.new(:inspect).new("(not inspected)")
|
142
|
+
|
143
|
+
original_telemetry = self.telemetry
|
144
|
+
|
145
|
+
self.telemetry = telemetry_placeholder
|
146
|
+
|
147
|
+
begin
|
148
|
+
super()
|
149
|
+
|
150
|
+
ensure
|
151
|
+
self.telemetry = original_telemetry
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
def update(event_or_event_data)
|
156
|
+
case event_or_event_data
|
157
|
+
in Telemetry::Event => event
|
158
|
+
|
159
|
+
in Telemetry::EventData => event_data
|
160
|
+
event_type = event_data.type
|
161
|
+
event_class = Events.const_get(event_type, false)
|
162
|
+
|
163
|
+
event = Telemetry::Event::Import.(event_data, event_class)
|
164
|
+
end
|
165
|
+
|
166
|
+
case event
|
167
|
+
when Events::ContextStarted, Events::TestStarted
|
168
|
+
title = event.title
|
169
|
+
|
170
|
+
if not title.nil?
|
171
|
+
trace.push(title)
|
172
|
+
end
|
173
|
+
|
174
|
+
when Events::Commented, Events::Detailed
|
175
|
+
trace.push(event.text)
|
176
|
+
end
|
177
|
+
|
178
|
+
telemetry.record(event)
|
179
|
+
|
180
|
+
status.update(event)
|
181
|
+
|
182
|
+
case event
|
183
|
+
when Events::Commented, Events::Detailed
|
184
|
+
trace.pop
|
185
|
+
|
186
|
+
when Events::ContextFinished, Events::TestFinished
|
187
|
+
title = event.title
|
188
|
+
|
189
|
+
if not title.nil?
|
190
|
+
trace.pop
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|
194
|
+
alias :record_event :update
|
195
|
+
|
196
|
+
def result(previous_status=nil)
|
197
|
+
status.result(previous_status)
|
198
|
+
end
|
199
|
+
|
200
|
+
def evaluate(pending_event, &block)
|
201
|
+
previous_status = status.dup
|
202
|
+
|
203
|
+
catch(ExecutionBreak) do
|
204
|
+
block.(self)
|
205
|
+
end
|
206
|
+
|
207
|
+
rescue Failure => failure
|
208
|
+
message = failure.message
|
209
|
+
record_event(Events::Failed.build(message))
|
210
|
+
|
211
|
+
rescue ::Exception => exception
|
212
|
+
aborted_recorded = status.error_sequence > previous_status.error_sequence
|
213
|
+
|
214
|
+
if not aborted_recorded
|
215
|
+
location = format_backtrace.(exception)
|
216
|
+
|
217
|
+
message = exception.detailed_message
|
218
|
+
|
219
|
+
record_event(Events::Aborted.build(message, location))
|
220
|
+
end
|
221
|
+
|
222
|
+
raise exception
|
223
|
+
|
224
|
+
ensure
|
225
|
+
result = status.result(previous_status, pending_event)
|
226
|
+
|
227
|
+
pending_event.result = result
|
228
|
+
record_event(pending_event)
|
229
|
+
|
230
|
+
if exception.nil?
|
231
|
+
return result
|
232
|
+
end
|
233
|
+
end
|
234
|
+
end
|
235
|
+
end
|
236
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module TestBenchBootstrap
|
2
|
+
module TestBench
|
3
|
+
class Session
|
4
|
+
Status = Struct.new(:test_sequence, :failure_sequence, :error_sequence, :skip_sequence)
|
5
|
+
|
6
|
+
class Status
|
7
|
+
def self.initial
|
8
|
+
new(0, 0, 0, 0)
|
9
|
+
end
|
10
|
+
|
11
|
+
def result(previous_status=nil, pending_event=nil)
|
12
|
+
previous_status ||= Status.initial
|
13
|
+
|
14
|
+
compare_status = compare(previous_status)
|
15
|
+
|
16
|
+
if not pending_event.nil?
|
17
|
+
compare_status.update(pending_event)
|
18
|
+
end
|
19
|
+
|
20
|
+
if compare_status.error_sequence > 0
|
21
|
+
Result.aborted
|
22
|
+
elsif compare_status.failure_sequence > 0
|
23
|
+
Result.failed
|
24
|
+
elsif compare_status.skip_sequence > 0
|
25
|
+
Result.incomplete
|
26
|
+
elsif not compare_status.test_sequence > 0
|
27
|
+
Result.none
|
28
|
+
else
|
29
|
+
Result.passed
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def update(event)
|
34
|
+
case event
|
35
|
+
when Events::TestFinished
|
36
|
+
self.test_sequence += 1
|
37
|
+
when Events::Failed
|
38
|
+
self.failure_sequence += 1
|
39
|
+
when Events::Aborted, Events::FileNotFound
|
40
|
+
self.error_sequence += 1
|
41
|
+
when Events::Skipped
|
42
|
+
self.skip_sequence += 1
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def compare(previous_status)
|
47
|
+
test_sequence_difference = test_sequence - previous_status.test_sequence
|
48
|
+
|
49
|
+
failure_sequence_difference = failure_sequence - previous_status.failure_sequence
|
50
|
+
|
51
|
+
error_sequence_difference = error_sequence - previous_status.error_sequence
|
52
|
+
|
53
|
+
skip_sequence_difference = skip_sequence - previous_status.skip_sequence
|
54
|
+
|
55
|
+
Status.new(test_sequence_difference, failure_sequence_difference, error_sequence_difference, skip_sequence_difference)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
module TestBenchBootstrap
|
2
|
+
module TestBench
|
3
|
+
class Session
|
4
|
+
module Substitute
|
5
|
+
class Sink
|
6
|
+
include Telemetry::Sink
|
7
|
+
|
8
|
+
def trace
|
9
|
+
@trace ||= Trace.new
|
10
|
+
end
|
11
|
+
attr_writer :trace
|
12
|
+
|
13
|
+
def records
|
14
|
+
@records ||= []
|
15
|
+
end
|
16
|
+
attr_writer :records
|
17
|
+
|
18
|
+
def self.build(trace=nil)
|
19
|
+
instance = new
|
20
|
+
|
21
|
+
if not trace.nil?
|
22
|
+
instance.trace = trace
|
23
|
+
end
|
24
|
+
|
25
|
+
instance
|
26
|
+
end
|
27
|
+
|
28
|
+
def receive(event_data)
|
29
|
+
trace_copy = Trace.new
|
30
|
+
|
31
|
+
trace.each do |entry|
|
32
|
+
trace_copy.push(entry)
|
33
|
+
end
|
34
|
+
|
35
|
+
record = Record.new(event_data, trace_copy)
|
36
|
+
records.push(record)
|
37
|
+
|
38
|
+
record
|
39
|
+
end
|
40
|
+
|
41
|
+
def received?(event_data=nil)
|
42
|
+
if not event_data.nil?
|
43
|
+
records.any? do |record|
|
44
|
+
record.event_data == event_data
|
45
|
+
end
|
46
|
+
else
|
47
|
+
records.any?
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def one_event?(event_class, *titles, **attributes)
|
52
|
+
event_sink = event_sink(*titles)
|
53
|
+
event_sink.one_event?(event_class, **attributes)
|
54
|
+
end
|
55
|
+
|
56
|
+
def one_event(event_class, *titles, **attributes)
|
57
|
+
event_sink = event_sink(*titles)
|
58
|
+
event_sink.one_event(event_class, **attributes)
|
59
|
+
end
|
60
|
+
|
61
|
+
def any_event?(event_class, *titles, **attributes)
|
62
|
+
event_sink = event_sink(*titles)
|
63
|
+
event_sink.any_event?(event_class, **attributes)
|
64
|
+
end
|
65
|
+
alias :event? :any_event?
|
66
|
+
|
67
|
+
def events(event_class, *titles, **attributes)
|
68
|
+
event_sink = event_sink(*titles)
|
69
|
+
event_sink.events(event_class, **attributes)
|
70
|
+
end
|
71
|
+
|
72
|
+
def event_sink(*titles)
|
73
|
+
event_sink = Telemetry::Substitute::Sink.new
|
74
|
+
|
75
|
+
records.each do |record|
|
76
|
+
if record.match?(titles)
|
77
|
+
event_data = record.event_data
|
78
|
+
|
79
|
+
event_sink.receive(event_data)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
event_sink
|
84
|
+
end
|
85
|
+
|
86
|
+
Record = Struct.new(:event_data, :trace) do
|
87
|
+
def match?(titles)
|
88
|
+
if titles.any?
|
89
|
+
trace.match?(*titles)
|
90
|
+
else
|
91
|
+
true
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
@@ -0,0 +1,154 @@
|
|
1
|
+
module TestBenchBootstrap
|
2
|
+
module TestBench
|
3
|
+
class Session
|
4
|
+
module Substitute
|
5
|
+
def self.build
|
6
|
+
Session.build
|
7
|
+
end
|
8
|
+
|
9
|
+
class Session < Session
|
10
|
+
def sink
|
11
|
+
@sink ||= Sink.build(trace)
|
12
|
+
end
|
13
|
+
|
14
|
+
attr_accessor :record_file_not_found
|
15
|
+
|
16
|
+
def record_file_not_found!
|
17
|
+
self.record_file_not_found = true
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.build
|
21
|
+
instance = new
|
22
|
+
|
23
|
+
sink = instance.sink
|
24
|
+
|
25
|
+
telemetry = instance.telemetry
|
26
|
+
telemetry.register(sink)
|
27
|
+
|
28
|
+
instance
|
29
|
+
end
|
30
|
+
|
31
|
+
def executed?(...)
|
32
|
+
isolate.executed?(...)
|
33
|
+
end
|
34
|
+
|
35
|
+
def file_not_found?(_file_path)
|
36
|
+
record_file_not_found ? true : false
|
37
|
+
end
|
38
|
+
|
39
|
+
def one_passed_test_finished_event?(*, **)
|
40
|
+
result = Result.passed
|
41
|
+
|
42
|
+
one_test_finished_event?(*, **, result:)
|
43
|
+
end
|
44
|
+
alias :one_test_passed? :one_passed_test_finished_event?
|
45
|
+
|
46
|
+
def one_passed_test_finished_event(*, **)
|
47
|
+
result = Result.passed
|
48
|
+
|
49
|
+
one_test_finished_event(*, **, result:)
|
50
|
+
end
|
51
|
+
alias :one_passed_test :one_passed_test_finished_event
|
52
|
+
|
53
|
+
def any_passed_test_finished_event?(*, **)
|
54
|
+
result = Result.passed
|
55
|
+
|
56
|
+
any_test_finished_event?(*, **, result:)
|
57
|
+
end
|
58
|
+
alias :any_test_passed? :any_passed_test_finished_event?
|
59
|
+
alias :test_passed? :any_test_passed?
|
60
|
+
|
61
|
+
def passed_test_finished_events(*, **)
|
62
|
+
result = Result.passed
|
63
|
+
|
64
|
+
test_finished_events(*, **, result:)
|
65
|
+
end
|
66
|
+
alias :passed_tests :passed_test_finished_events
|
67
|
+
|
68
|
+
def one_failed_test_finished_event?(*, **)
|
69
|
+
result = Result.failed
|
70
|
+
|
71
|
+
one_test_finished_event?(*, **, result:)
|
72
|
+
end
|
73
|
+
alias :one_test_failed? :one_failed_test_finished_event?
|
74
|
+
|
75
|
+
def one_failed_test_finished_event(*, **)
|
76
|
+
result = Result.failed
|
77
|
+
|
78
|
+
one_test_finished_event(*, **, result:)
|
79
|
+
end
|
80
|
+
alias :one_failed_test :one_failed_test_finished_event
|
81
|
+
|
82
|
+
def any_failed_test_finished_event?(*, **)
|
83
|
+
result = Result.failed
|
84
|
+
|
85
|
+
any_test_finished_event?(*, **, result:)
|
86
|
+
end
|
87
|
+
alias :any_test_failed? :any_failed_test_finished_event?
|
88
|
+
alias :test_failed? :any_test_failed?
|
89
|
+
|
90
|
+
def failed_test_finished_events(*, **)
|
91
|
+
result = Result.failed
|
92
|
+
|
93
|
+
test_finished_events(*, **, result:)
|
94
|
+
end
|
95
|
+
alias :failed_tests :failed_test_finished_events
|
96
|
+
|
97
|
+
[
|
98
|
+
Events::Failed,
|
99
|
+
Events::Aborted,
|
100
|
+
Events::Skipped,
|
101
|
+
Events::Commented,
|
102
|
+
Events::Detailed,
|
103
|
+
Events::TestStarted,
|
104
|
+
Events::TestFinished,
|
105
|
+
Events::ContextStarted,
|
106
|
+
Events::ContextFinished,
|
107
|
+
Events::FileQueued,
|
108
|
+
Events::FileExecuted,
|
109
|
+
Events::FileNotFound
|
110
|
+
].each do |event_class|
|
111
|
+
|
112
|
+
event_name = event_class.event_name
|
113
|
+
|
114
|
+
module_eval(<<~RUBY, __FILE__, __LINE__)
|
115
|
+
def one_#{event_name}_event?(...)
|
116
|
+
one_event?(#{event_class}, ...)
|
117
|
+
end
|
118
|
+
|
119
|
+
def one_#{event_name}_event(...)
|
120
|
+
one_event(#{event_class}, ...)
|
121
|
+
end
|
122
|
+
|
123
|
+
def any_#{event_name}_event?(...)
|
124
|
+
any_event?(#{event_class}, ...)
|
125
|
+
end
|
126
|
+
alias :#{event_name}_event? :any_#{event_name}_event?
|
127
|
+
|
128
|
+
def #{event_name}_events(...)
|
129
|
+
events(#{event_class}, ...)
|
130
|
+
end
|
131
|
+
RUBY
|
132
|
+
end
|
133
|
+
|
134
|
+
def one_event?(...)
|
135
|
+
sink.one_event?(...)
|
136
|
+
end
|
137
|
+
|
138
|
+
def any_event?(...)
|
139
|
+
sink.any_event?(...)
|
140
|
+
end
|
141
|
+
alias :event? :any_event?
|
142
|
+
|
143
|
+
def one_event(...)
|
144
|
+
sink.one_event(...)
|
145
|
+
end
|
146
|
+
|
147
|
+
def events(...)
|
148
|
+
sink.events(...)
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module TestBenchBootstrap
|
2
|
+
module TestBench
|
3
|
+
class Session
|
4
|
+
class Trace
|
5
|
+
include Enumerable
|
6
|
+
|
7
|
+
def entries
|
8
|
+
@entries ||= []
|
9
|
+
end
|
10
|
+
attr_writer :entries
|
11
|
+
|
12
|
+
def push(entry)
|
13
|
+
entries.push(entry)
|
14
|
+
end
|
15
|
+
|
16
|
+
def pop
|
17
|
+
entries.pop
|
18
|
+
end
|
19
|
+
|
20
|
+
def match?(*context_titles, compare_text)
|
21
|
+
if compare_text != entries.last
|
22
|
+
return false
|
23
|
+
end
|
24
|
+
|
25
|
+
context_title_iterator = entries[0...-1].to_enum
|
26
|
+
|
27
|
+
context_titles.all? do |context_title|
|
28
|
+
title = context_title_iterator.next until title == context_title
|
29
|
+
|
30
|
+
true
|
31
|
+
|
32
|
+
rescue StopIteration
|
33
|
+
false
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def each(...)
|
38
|
+
entries.each(...)
|
39
|
+
end
|
40
|
+
|
41
|
+
def join(delimiter=nil)
|
42
|
+
delimiter ||= self.class.join_delimiter
|
43
|
+
|
44
|
+
entries.join(delimiter)
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.join_delimiter
|
48
|
+
' :: '
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'test_bench_bootstrap/test_bench/telemetry'
|
2
|
+
|
3
|
+
require 'test_bench_bootstrap/test_bench/session/defaults'
|
4
|
+
|
5
|
+
require 'test_bench_bootstrap/test_bench/session/result'
|
6
|
+
|
7
|
+
require 'test_bench_bootstrap/test_bench/session/exception/format_backtrace'
|
8
|
+
require 'test_bench_bootstrap/test_bench/session/exception/format_backtrace/substitute'
|
9
|
+
|
10
|
+
require 'test_bench_bootstrap/test_bench/session/events'
|
11
|
+
|
12
|
+
require 'test_bench_bootstrap/test_bench/session/trace'
|
13
|
+
|
14
|
+
require 'test_bench_bootstrap/test_bench/session/status'
|
15
|
+
|
16
|
+
require 'test_bench_bootstrap/test_bench/session/isolate'
|
17
|
+
require 'test_bench_bootstrap/test_bench/session/isolate/substitute'
|
18
|
+
|
19
|
+
require 'test_bench_bootstrap/test_bench/session/session'
|
20
|
+
|
21
|
+
require 'test_bench_bootstrap/test_bench/session/substitute/sink'
|
22
|
+
require 'test_bench_bootstrap/test_bench/session/substitute'
|
@@ -0,0 +1,72 @@
|
|
1
|
+
module TestBenchBootstrap
|
2
|
+
module TestBench
|
3
|
+
class Telemetry
|
4
|
+
module Controls
|
5
|
+
module Event
|
6
|
+
module Metadata
|
7
|
+
def self.example(process_id: nil, time: nil)
|
8
|
+
if process_id == :none
|
9
|
+
process_id = nil
|
10
|
+
else
|
11
|
+
process_id ||= self.process_id
|
12
|
+
end
|
13
|
+
|
14
|
+
if time == :none
|
15
|
+
time = nil
|
16
|
+
else
|
17
|
+
time ||= self.time
|
18
|
+
end
|
19
|
+
|
20
|
+
metadata = Telemetry::Event::Metadata.new
|
21
|
+
metadata.process_id = process_id
|
22
|
+
metadata.time = time
|
23
|
+
metadata
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.other_example
|
27
|
+
Other.example
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.random
|
31
|
+
Random.example
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.process_id
|
35
|
+
ProcessID.example
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.time
|
39
|
+
Time.example
|
40
|
+
end
|
41
|
+
|
42
|
+
module Other
|
43
|
+
def self.example(process_id: nil, time: nil)
|
44
|
+
process_id ||= self.process_id
|
45
|
+
time ||= self.time
|
46
|
+
|
47
|
+
Metadata.example(process_id:, time:)
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.process_id
|
51
|
+
ProcessID.other_example
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.time
|
55
|
+
Time.other_example
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
module Random
|
60
|
+
def self.example(process_id: nil, time: nil)
|
61
|
+
process_id ||= ProcessID.random
|
62
|
+
time ||= Controls::Time.random
|
63
|
+
|
64
|
+
Metadata.example(process_id:, time:)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|