test_bench-run 2.1.3.1 → 3.0.0.0.pre.1

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.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/lib/test_bench/run/controls/{result.rb → events.rb} +1 -1
  3. data/lib/test_bench/run/controls/{process_id.rb → message.rb} +1 -1
  4. data/lib/test_bench/run/controls/path.rb +1 -9
  5. data/lib/test_bench/run/controls/random.rb +1 -1
  6. data/lib/test_bench/run/controls/session.rb +14 -0
  7. data/lib/test_bench/run/controls/status.rb +42 -0
  8. data/lib/test_bench/run/controls/summary/file/info.rb +106 -0
  9. data/lib/test_bench/run/controls/summary/file/totals.rb +36 -0
  10. data/lib/test_bench/run/controls/summary/file.rb +42 -0
  11. data/lib/test_bench/run/controls/summary/run.rb +51 -0
  12. data/lib/test_bench/run/controls/summary.rb +43 -0
  13. data/lib/test_bench/run/controls/{events/session.rb → telemetry.rb} +2 -2
  14. data/lib/test_bench/run/controls/time.rb +1 -1
  15. data/lib/test_bench/run/controls.rb +14 -20
  16. data/lib/test_bench/run/run.rb +78 -90
  17. data/lib/test_bench/run/{get_files → select_files}/substitute.rb +11 -14
  18. data/lib/test_bench/run/select_files.rb +68 -0
  19. data/lib/test_bench/run/substitute.rb +40 -0
  20. data/lib/test_bench/run/summary/substitute.rb +17 -0
  21. data/lib/test_bench/run/summary.rb +475 -0
  22. data/lib/test_bench/run.rb +6 -14
  23. metadata +32 -45
  24. data/lib/test_bench/run/controls/directory.rb +0 -70
  25. data/lib/test_bench/run/controls/event_data.rb +0 -7
  26. data/lib/test_bench/run/controls/events/event_data.rb +0 -9
  27. data/lib/test_bench/run/controls/events/file_crashed.rb +0 -109
  28. data/lib/test_bench/run/controls/events/file_finished.rb +0 -56
  29. data/lib/test_bench/run/controls/events/file_started.rb +0 -47
  30. data/lib/test_bench/run/controls/events/finished.rb +0 -56
  31. data/lib/test_bench/run/controls/events/started.rb +0 -47
  32. data/lib/test_bench/run/controls/exception.rb +0 -101
  33. data/lib/test_bench/run/controls/executor.rb +0 -56
  34. data/lib/test_bench/run/controls/file/create.rb +0 -69
  35. data/lib/test_bench/run/controls/file/pattern.rb +0 -33
  36. data/lib/test_bench/run/controls/file.rb +0 -180
  37. data/lib/test_bench/run/events.rb +0 -12
  38. data/lib/test_bench/run/executor/serial.rb +0 -34
  39. data/lib/test_bench/run/executor/substitute.rb +0 -45
  40. data/lib/test_bench/run/executor.rb +0 -44
  41. data/lib/test_bench/run/file.rb +0 -81
  42. data/lib/test_bench/run/get_files.rb +0 -76
  43. data/lib/test_bench/run/output/file.rb +0 -135
  44. data/lib/test_bench/run/output/summary/error.rb +0 -139
  45. data/lib/test_bench/run/output/summary.rb +0 -182
@@ -0,0 +1,475 @@
1
+ module TestBench
2
+ class Run
3
+ class Summary
4
+ include Telemetry::Sink::Handler
5
+ include ImportConstants
6
+
7
+ import_constants Session::Events
8
+
9
+ def writer
10
+ @writer ||= Output::Writer::Substitute.build
11
+ end
12
+ attr_writer :writer
13
+
14
+ def status
15
+ @status ||= Session::Status.initial
16
+ end
17
+ attr_writer :status
18
+
19
+ def file_totals
20
+ @file_totals ||= FileTotals.initial
21
+ end
22
+ attr_writer :file_totals
23
+
24
+ def files
25
+ @files ||= {}
26
+ end
27
+ attr_writer :files
28
+
29
+ def file_stack
30
+ @file_stack ||= FileStack.new
31
+ end
32
+
33
+ attr_accessor :start_time
34
+
35
+ def self.build(styling: nil, device: nil)
36
+ instance = new
37
+
38
+ instance.start_time = ::Time.now
39
+
40
+ Output::Writer.configure(instance, styling:, device:)
41
+
42
+ instance
43
+ end
44
+
45
+ def self.configure(receiver, styling: nil, device: nil, attr_name: nil)
46
+ attr_name ||= :summary
47
+
48
+ instance = build(styling:, device:)
49
+ receiver.public_send(:"#{attr_name}=", instance)
50
+ end
51
+
52
+ handle Failed do |failed|
53
+ status.update(failed)
54
+
55
+ if current_file?
56
+ current_file.update(failed)
57
+ end
58
+ end
59
+
60
+ handle Aborted do |aborted|
61
+ status.update(aborted)
62
+
63
+ if current_file?
64
+ current_file.update(aborted)
65
+ end
66
+ end
67
+
68
+ handle Skipped do |skipped|
69
+ status.update(skipped)
70
+
71
+ if current_file?
72
+ current_file.update(skipped)
73
+ end
74
+ end
75
+
76
+ handle TestFinished do |test_finished|
77
+ status.update(test_finished)
78
+
79
+ if current_file?
80
+ current_file.update(test_finished)
81
+ end
82
+ end
83
+
84
+ handle FileQueued do |file_queued|
85
+ file_totals.record_file_queued
86
+
87
+ path = file_queued.file
88
+
89
+ file_info = FileInfo.initial(path)
90
+ add_file(file_info)
91
+
92
+ file_stack.push(path)
93
+ end
94
+
95
+ handle FileExecuted do |file_executed|
96
+ result = file_executed.result
97
+
98
+ case result
99
+ when Session::Result.aborted
100
+ file_totals.record_file_aborted
101
+ else
102
+ file_totals.record_file_completed
103
+
104
+ if result == Session::Result.passed
105
+ file_path = file_executed.file
106
+ files.delete(file_path)
107
+ end
108
+ end
109
+
110
+ file_stack.pop
111
+ end
112
+
113
+ handle FileNotFound do |file_not_found|
114
+ file_totals.record_file_not_found
115
+
116
+ path = file_not_found.file
117
+
118
+ file_info = FileInfo.not_found(path)
119
+ add_file(file_info)
120
+
121
+ status.update(file_not_found)
122
+ end
123
+
124
+ def print(finish_time=nil)
125
+ finish_time ||= ::Time.now
126
+
127
+ if not start_time.nil?
128
+ elapsed_time = finish_time - start_time
129
+ else
130
+ elapsed_time = 0.0
131
+ end
132
+
133
+ tests_per_second = status.test_sequence / elapsed_time
134
+
135
+ if files.any?
136
+ none_failed = files.each_value.none?(&:failed?)
137
+
138
+ if writer.styling?
139
+ writer.
140
+ style(:bold, :underline)
141
+
142
+ if not none_failed
143
+ writer.style(:red)
144
+ end
145
+ end
146
+
147
+ writer.puts("File Summary")
148
+
149
+ if not writer.styling?
150
+ writer.puts("- - -")
151
+ end
152
+
153
+ files.each_value do |file_info|
154
+ if file_info.failed?
155
+ writer.style(:red)
156
+ end
157
+
158
+ writer.
159
+ style(:faint).
160
+ print('-').
161
+ style(:reset_intensity).
162
+ print(' ').
163
+ style(:bold).
164
+ print(file_info.file_path).
165
+ style(:reset_intensity).
166
+ print(': ')
167
+
168
+ separator = false
169
+
170
+ if file_info.not_found?
171
+ writer.
172
+ puts('file not found').
173
+ puts
174
+
175
+ next
176
+ end
177
+
178
+ if not file_info.tests?
179
+ if not file_info.failed?
180
+ writer.style(:faint, :italic)
181
+ end
182
+
183
+ writer.print('no tests')
184
+
185
+ if not file_info.failed?
186
+ writer.style(:reset_italic, :reset_intensity)
187
+ end
188
+
189
+ separator = true
190
+ end
191
+
192
+ if file_info.failures?
193
+ writer.print(', ') if separator
194
+ writer.print(file_info.failures)
195
+
196
+ separator = true
197
+ end
198
+
199
+ if file_info.skipped?
200
+ writer.print(', ') if separator
201
+
202
+ if not file_info.failed?
203
+ writer.style(:bold, :yellow)
204
+ end
205
+
206
+ writer.print(file_info.skipped)
207
+
208
+ separator = true
209
+ end
210
+
211
+ if file_info.errors?
212
+ writer.print(', ') if separator
213
+
214
+ writer.print(file_info.errors)
215
+
216
+ separator = true
217
+ end
218
+
219
+ writer.puts
220
+
221
+ writer.increase_indentation
222
+
223
+ file_info.aborted_events.each_with_index do |aborted, index|
224
+ message = aborted.message
225
+ location = aborted.location
226
+
227
+ if not index.zero?
228
+ writer.puts
229
+ end
230
+
231
+ writer.
232
+ indent.
233
+ style(:red).
234
+ puts(message)
235
+
236
+ writer.
237
+ indent.
238
+ style(:red).
239
+ puts(location)
240
+ end
241
+
242
+ writer.decrease_indentation
243
+
244
+ writer.puts
245
+ end
246
+ end
247
+
248
+ writer.
249
+ print("Attempted %s: %s, " % [file_totals.attempted, file_totals.completed])
250
+
251
+ if file_totals.aborted?
252
+ writer.style(:bold, :red)
253
+ end
254
+
255
+ writer.print("%s" % file_totals.aborted)
256
+
257
+ if file_totals.aborted?
258
+ writer.style(:reset_fg, :reset_intensity)
259
+ end
260
+
261
+ writer.print(', ')
262
+
263
+ if file_totals.not_found?
264
+ writer.style(:red)
265
+ end
266
+
267
+ writer.puts("%s" % file_totals.not_found)
268
+
269
+ writer.
270
+ puts("%i test#{'s' if status.test_sequence != 1} in %0.2f seconds (%0.2f tests/sec)" % [status.test_sequence, elapsed_time, tests_per_second])
271
+
272
+ if status.test_sequence.zero?
273
+ writer.
274
+ style(:faint, :italic).
275
+ print('0 passed').
276
+ style(:reset_italic, :reset_intensity)
277
+
278
+ else
279
+ passed_tests = status.test_sequence - status.failure_sequence
280
+
281
+ writer.
282
+ style(:green).
283
+ print("%i passed" % passed_tests).
284
+ style(:reset_fg)
285
+ end
286
+
287
+ writer.print(', ')
288
+
289
+ if status.failure_sequence.zero?
290
+ writer.print('0 failed')
291
+ else
292
+ writer.
293
+ style(:bold, :red).
294
+ print("%i failed" % status.failure_sequence).
295
+ style(:reset_fg, :reset_intensity)
296
+ end
297
+
298
+ writer.print(', ')
299
+
300
+ if status.skip_sequence.zero?
301
+ writer.print('0 skipped')
302
+ else
303
+ writer.
304
+ style(:yellow).
305
+ print("%i+ skipped" % status.skip_sequence)
306
+ end
307
+
308
+ 2.times do
309
+ writer.puts
310
+ end
311
+ end
312
+
313
+ def add_file(file_info)
314
+ file_path = file_info.file_path
315
+
316
+ files[file_path] = file_info
317
+ end
318
+
319
+ def current_file
320
+ current_file_path = file_stack.current_file
321
+
322
+ files[current_file_path]
323
+ end
324
+
325
+ def current_file?
326
+ file_stack.current_file?
327
+ end
328
+
329
+ class FileStack
330
+ def entries
331
+ @entries ||= []
332
+ end
333
+ attr_writer :entries
334
+
335
+ def push(file_path)
336
+ entries.push(file_path)
337
+ end
338
+
339
+ def pop
340
+ entries.pop
341
+ end
342
+
343
+ def current_file?
344
+ !entries.empty?
345
+ end
346
+
347
+ def current_file
348
+ entries.last
349
+ end
350
+ end
351
+
352
+ FileInfo = Struct.new(:file_path, :status, :aborted_events, :not_found) do
353
+ def self.initial(file_path)
354
+ status = Session::Status.initial
355
+
356
+ aborted_events = []
357
+
358
+ new(file_path, status, aborted_events)
359
+ end
360
+
361
+ def self.not_found(file_path)
362
+ instance = new(file_path)
363
+ instance.not_found = true
364
+ instance
365
+ end
366
+
367
+ def update(event)
368
+ status.update(event)
369
+
370
+ if event in Aborted => aborted
371
+ self.aborted_events << aborted
372
+ end
373
+ end
374
+
375
+ def failed?
376
+ if not_found?
377
+ return true
378
+ end
379
+
380
+ case status.result
381
+ when Session::Result.failed, Session::Result.aborted
382
+ true
383
+ else
384
+ false
385
+ end
386
+ end
387
+
388
+ def tests?
389
+ status.test_sequence > 0
390
+ end
391
+
392
+ def failures?
393
+ status.failure_sequence > 0
394
+ end
395
+
396
+ def failures
397
+ failures = status.failure_sequence
398
+
399
+ "%i failure#{'s' if failures != 1}" % failures
400
+ end
401
+
402
+ def skipped?
403
+ status.skip_sequence > 0
404
+ end
405
+
406
+ def skipped
407
+ skipped = status.skip_sequence
408
+
409
+ "%i+ skipped" % skipped
410
+ end
411
+
412
+ def errors?
413
+ aborted_events.any?
414
+ end
415
+
416
+ def errors
417
+ errors = aborted_events.count
418
+
419
+ "%i error#{'s' if errors != 1}:" % errors
420
+ end
421
+
422
+ def not_found?
423
+ not_found ? true : false
424
+ end
425
+ end
426
+
427
+ FileTotals = Struct.new(:attempted_count, :completed_count, :aborted_count, :not_found_count) do
428
+ def self.initial
429
+ new(0, 0, 0, 0)
430
+ end
431
+
432
+ def record_file_queued
433
+ self.attempted_count += 1
434
+ end
435
+
436
+ def record_file_completed
437
+ self.completed_count += 1
438
+ end
439
+
440
+ def record_file_aborted
441
+ self.aborted_count += 1
442
+ end
443
+
444
+ def record_file_not_found
445
+ self.attempted_count += 1
446
+ self.not_found_count += 1
447
+ end
448
+
449
+ def attempted
450
+ "%i file#{'s' if attempted_count != 1}" % attempted_count
451
+ end
452
+
453
+ def completed
454
+ "%i completed" % completed_count
455
+ end
456
+
457
+ def aborted?
458
+ aborted_count > 0
459
+ end
460
+
461
+ def aborted
462
+ "%i aborted" % aborted_count
463
+ end
464
+
465
+ def not_found?
466
+ not_found_count > 0
467
+ end
468
+
469
+ def not_found
470
+ "%i not found" % not_found_count
471
+ end
472
+ end
473
+ end
474
+ end
475
+ end
@@ -1,18 +1,10 @@
1
- require 'test_bench/fixture'
1
+ require 'test_bench/output'
2
2
 
3
- require 'test_bench/run/events'
3
+ require 'test_bench/run/select_files'
4
+ require 'test_bench/run/select_files/substitute'
4
5
 
5
- require 'test_bench/run/get_files'
6
- require 'test_bench/run/get_files/substitute'
7
-
8
- require 'test_bench/run/file'
9
-
10
- require 'test_bench/run/output/file'
11
- require 'test_bench/run/output/summary/error'
12
- require 'test_bench/run/output/summary'
13
-
14
- require 'test_bench/run/executor'
15
- require 'test_bench/run/executor/substitute'
16
- require 'test_bench/run/executor/serial'
6
+ require 'test_bench/run/summary'
7
+ require 'test_bench/run/summary/substitute'
17
8
 
18
9
  require 'test_bench/run/run'
10
+ require 'test_bench/run/substitute'
metadata CHANGED
@@ -1,14 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: test_bench-run
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.3.1
4
+ version: 3.0.0.0.pre.1
5
5
  platform: ruby
6
6
  authors:
7
- - Nathan Ladd
8
- autorequire:
7
+ - Brightworks Digital
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date:
12
10
  dependencies:
13
11
  - !ruby/object:Gem::Dependency
14
12
  name: test_bench-fixture
@@ -25,7 +23,7 @@ dependencies:
25
23
  - !ruby/object:Gem::Version
26
24
  version: '0'
27
25
  - !ruby/object:Gem::Dependency
28
- name: test_bench-isolated
26
+ name: test_bench-bootstrap
29
27
  requirement: !ruby/object:Gem::Requirement
30
28
  requirements:
31
29
  - - ">="
@@ -38,8 +36,8 @@ dependencies:
38
36
  - - ">="
39
37
  - !ruby/object:Gem::Version
40
38
  version: '0'
41
- description:
42
- email: nathanladd+github@gmail.com
39
+ description: Runs a batch of TestBench files and directories.
40
+ email: development@bright.works
43
41
  executables: []
44
42
  extensions: []
45
43
  extra_rdoc_files: []
@@ -47,49 +45,39 @@ files:
47
45
  - lib/test_bench
48
46
  - lib/test_bench/run
49
47
  - lib/test_bench/run/controls
50
- - lib/test_bench/run/controls/directory.rb
51
- - lib/test_bench/run/controls/event_data.rb
52
- - lib/test_bench/run/controls/events
53
- - lib/test_bench/run/controls/events/event_data.rb
54
- - lib/test_bench/run/controls/events/file_crashed.rb
55
- - lib/test_bench/run/controls/events/file_finished.rb
56
- - lib/test_bench/run/controls/events/file_started.rb
57
- - lib/test_bench/run/controls/events/finished.rb
58
- - lib/test_bench/run/controls/events/session.rb
59
- - lib/test_bench/run/controls/events/started.rb
60
- - lib/test_bench/run/controls/exception.rb
61
- - lib/test_bench/run/controls/executor.rb
62
- - lib/test_bench/run/controls/file
63
- - lib/test_bench/run/controls/file/create.rb
64
- - lib/test_bench/run/controls/file/pattern.rb
65
- - lib/test_bench/run/controls/file.rb
48
+ - lib/test_bench/run/controls/events.rb
49
+ - lib/test_bench/run/controls/message.rb
66
50
  - lib/test_bench/run/controls/path.rb
67
- - lib/test_bench/run/controls/process_id.rb
68
51
  - lib/test_bench/run/controls/random.rb
69
- - lib/test_bench/run/controls/result.rb
52
+ - lib/test_bench/run/controls/session.rb
53
+ - lib/test_bench/run/controls/status.rb
54
+ - lib/test_bench/run/controls/summary
55
+ - lib/test_bench/run/controls/summary/file
56
+ - lib/test_bench/run/controls/summary/file/info.rb
57
+ - lib/test_bench/run/controls/summary/file/totals.rb
58
+ - lib/test_bench/run/controls/summary/file.rb
59
+ - lib/test_bench/run/controls/summary/run.rb
60
+ - lib/test_bench/run/controls/summary.rb
61
+ - lib/test_bench/run/controls/telemetry.rb
70
62
  - lib/test_bench/run/controls/time.rb
71
63
  - lib/test_bench/run/controls.rb
72
- - lib/test_bench/run/events.rb
73
- - lib/test_bench/run/executor
74
- - lib/test_bench/run/executor/serial.rb
75
- - lib/test_bench/run/executor/substitute.rb
76
- - lib/test_bench/run/executor.rb
77
- - lib/test_bench/run/file.rb
78
- - lib/test_bench/run/get_files
79
- - lib/test_bench/run/get_files/substitute.rb
80
- - lib/test_bench/run/get_files.rb
81
- - lib/test_bench/run/output
82
- - lib/test_bench/run/output/file.rb
83
- - lib/test_bench/run/output/summary
84
- - lib/test_bench/run/output/summary/error.rb
85
- - lib/test_bench/run/output/summary.rb
86
64
  - lib/test_bench/run/run.rb
65
+ - lib/test_bench/run/select_files
66
+ - lib/test_bench/run/select_files/substitute.rb
67
+ - lib/test_bench/run/select_files.rb
68
+ - lib/test_bench/run/substitute.rb
69
+ - lib/test_bench/run/summary
70
+ - lib/test_bench/run/summary/substitute.rb
71
+ - lib/test_bench/run/summary.rb
87
72
  - lib/test_bench/run.rb
88
- homepage: https://github.com/test-bench/test-bench-run
73
+ homepage: http://test-bench.software
89
74
  licenses:
90
75
  - MIT
91
- metadata: {}
92
- post_install_message:
76
+ metadata:
77
+ homepage_uri: http://test-bench.software
78
+ source_code_uri: https://github.com/test-bench-demo/test-bench-run
79
+ allowed_push_host: https://rubygems.org
80
+ namespace: TestBench::Run
93
81
  rdoc_options: []
94
82
  require_paths:
95
83
  - lib
@@ -104,8 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
104
92
  - !ruby/object:Gem::Version
105
93
  version: '0'
106
94
  requirements: []
107
- rubygems_version: 3.4.10
108
- signing_key:
95
+ rubygems_version: 3.6.9
109
96
  specification_version: 4
110
- summary: ruby
97
+ summary: Runs a batch of TestBench files and directories
111
98
  test_files: []
@@ -1,70 +0,0 @@
1
- module TestBench
2
- class Run
3
- module Controls
4
- module Directory
5
- def self.example(name=nil, parent_directory: nil, root_directory: nil)
6
- name ||= self.name
7
- parent_directory ||= self.parent_directory
8
-
9
- ::File.join(parent_directory, name)
10
- end
11
-
12
- def self.random
13
- Random.example
14
- end
15
-
16
- def self.name
17
- Name.example
18
- end
19
-
20
- def self.parent_directory
21
- File::Create.directory
22
- end
23
-
24
- def self.root_directory
25
- File::Create.root_directory
26
- end
27
-
28
- module Pattern
29
- def self.example
30
- 'some-directory*'
31
- end
32
- end
33
-
34
- module Random
35
- def self.example(basename: nil, parent_directory: nil)
36
- name = Name::Random.example(basename)
37
-
38
- Directory.example(name, parent_directory:)
39
- end
40
- end
41
-
42
- module Name
43
- def self.example
44
- "some-directory"
45
- end
46
-
47
- module Random
48
- def self.example(basename=nil)
49
- basename ||= Name.example
50
-
51
- suffix = Controls::Random.string
52
-
53
- "#{basename}-#{suffix}"
54
- end
55
- end
56
- end
57
-
58
- module Create
59
- def self.call(basename: nil, parent_directory: nil)
60
- directory = Random.example(basename:, parent_directory:)
61
-
62
- ::Dir.mkdir(directory)
63
-
64
- directory
65
- end
66
- end
67
- end
68
- end
69
- end
70
- end
@@ -1,7 +0,0 @@
1
- module TestBench
2
- class Run
3
- module Controls
4
- EventData = Telemetry::Controls::EventData
5
- end
6
- end
7
- end
@@ -1,9 +0,0 @@
1
- module TestBench
2
- class Run
3
- module Controls
4
- module Events
5
- EventData = Session::Controls::Events::EventData
6
- end
7
- end
8
- end
9
- end