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.
Files changed (171) hide show
  1. checksums.yaml +4 -4
  2. data/executables/bench-bootstrap +7 -0
  3. data/lib/test_bench_bootstrap/controls.rb +1 -0
  4. data/lib/test_bench_bootstrap/test_bench_bootstrap.rb +7 -0
  5. data/lib/test_bench_bootstrap.rb +4 -0
  6. data/upstream-lib/test_bench_bootstrap/import_constants/controls/namespace.rb +84 -0
  7. data/upstream-lib/test_bench_bootstrap/import_constants/controls.rb +1 -0
  8. data/upstream-lib/test_bench_bootstrap/import_constants/import_constants.rb +46 -0
  9. data/upstream-lib/test_bench_bootstrap/import_constants/macro.rb +10 -0
  10. data/upstream-lib/test_bench_bootstrap/import_constants.rb +2 -0
  11. data/upstream-lib/test_bench_bootstrap/test_bench/controls/telemetry_sink.rb +7 -0
  12. data/upstream-lib/test_bench_bootstrap/test_bench/controls.rb +3 -0
  13. data/upstream-lib/test_bench_bootstrap/test_bench/executable/controls/path.rb +9 -0
  14. data/upstream-lib/test_bench_bootstrap/test_bench/executable/controls/random.rb +9 -0
  15. data/upstream-lib/test_bench_bootstrap/test_bench/executable/controls/run.rb +12 -0
  16. data/upstream-lib/test_bench_bootstrap/test_bench/executable/controls/standard_input.rb +31 -0
  17. data/upstream-lib/test_bench_bootstrap/test_bench/executable/controls.rb +8 -0
  18. data/upstream-lib/test_bench_bootstrap/test_bench/executable/defaults.rb +15 -0
  19. data/upstream-lib/test_bench_bootstrap/test_bench/executable/executable.rb +61 -0
  20. data/upstream-lib/test_bench_bootstrap/test_bench/executable/parse_arguments.rb +271 -0
  21. data/upstream-lib/test_bench_bootstrap/test_bench/executable.rb +7 -0
  22. data/upstream-lib/test_bench_bootstrap/test_bench/fixture/build.rb +41 -0
  23. data/upstream-lib/test_bench_bootstrap/test_bench/fixture/controls/comment_style.rb +9 -0
  24. data/upstream-lib/test_bench_bootstrap/test_bench/fixture/controls/exception.rb +9 -0
  25. data/upstream-lib/test_bench_bootstrap/test_bench/fixture/controls/fixture.rb +69 -0
  26. data/upstream-lib/test_bench_bootstrap/test_bench/fixture/controls/message.rb +9 -0
  27. data/upstream-lib/test_bench_bootstrap/test_bench/fixture/controls/output.rb +11 -0
  28. data/upstream-lib/test_bench_bootstrap/test_bench/fixture/controls/path.rb +9 -0
  29. data/upstream-lib/test_bench_bootstrap/test_bench/fixture/controls/session.rb +21 -0
  30. data/upstream-lib/test_bench_bootstrap/test_bench/fixture/controls/status.rb +9 -0
  31. data/upstream-lib/test_bench_bootstrap/test_bench/fixture/controls/text.rb +9 -0
  32. data/upstream-lib/test_bench_bootstrap/test_bench/fixture/controls/title.rb +9 -0
  33. data/upstream-lib/test_bench_bootstrap/test_bench/fixture/controls.rb +14 -0
  34. data/upstream-lib/test_bench_bootstrap/test_bench/fixture/evaluate.rb +37 -0
  35. data/upstream-lib/test_bench_bootstrap/test_bench/fixture/fixture.rb +213 -0
  36. data/upstream-lib/test_bench_bootstrap/test_bench/fixture.rb +7 -0
  37. data/upstream-lib/test_bench_bootstrap/test_bench/output/comment_style.rb +63 -0
  38. data/upstream-lib/test_bench_bootstrap/test_bench/output/controls/comment_style.rb +23 -0
  39. data/upstream-lib/test_bench_bootstrap/test_bench/output/controls/event.rb +9 -0
  40. data/upstream-lib/test_bench_bootstrap/test_bench/output/controls/events/aborted.rb +11 -0
  41. data/upstream-lib/test_bench_bootstrap/test_bench/output/controls/events/commented.rb +23 -0
  42. data/upstream-lib/test_bench_bootstrap/test_bench/output/controls/events/context_finished.rb +11 -0
  43. data/upstream-lib/test_bench_bootstrap/test_bench/output/controls/events/context_started.rb +11 -0
  44. data/upstream-lib/test_bench_bootstrap/test_bench/output/controls/events/detailed.rb +23 -0
  45. data/upstream-lib/test_bench_bootstrap/test_bench/output/controls/events/failed.rb +11 -0
  46. data/upstream-lib/test_bench_bootstrap/test_bench/output/controls/events/file_executed.rb +11 -0
  47. data/upstream-lib/test_bench_bootstrap/test_bench/output/controls/events/file_not_found.rb +11 -0
  48. data/upstream-lib/test_bench_bootstrap/test_bench/output/controls/events/file_queued.rb +11 -0
  49. data/upstream-lib/test_bench_bootstrap/test_bench/output/controls/events/skipped.rb +11 -0
  50. data/upstream-lib/test_bench_bootstrap/test_bench/output/controls/events/test_finished.rb +11 -0
  51. data/upstream-lib/test_bench_bootstrap/test_bench/output/controls/events/test_started.rb +11 -0
  52. data/upstream-lib/test_bench_bootstrap/test_bench/output/controls/random.rb +9 -0
  53. data/upstream-lib/test_bench_bootstrap/test_bench/output/controls/session.rb +19 -0
  54. data/upstream-lib/test_bench_bootstrap/test_bench/output/controls/status.rb +9 -0
  55. data/upstream-lib/test_bench_bootstrap/test_bench/output/controls/style.rb +41 -0
  56. data/upstream-lib/test_bench_bootstrap/test_bench/output/controls/text.rb +31 -0
  57. data/upstream-lib/test_bench_bootstrap/test_bench/output/controls.rb +26 -0
  58. data/upstream-lib/test_bench_bootstrap/test_bench/output/detail_policy.rb +46 -0
  59. data/upstream-lib/test_bench_bootstrap/test_bench/output/device/null.rb +21 -0
  60. data/upstream-lib/test_bench_bootstrap/test_bench/output/device/substitute.rb +46 -0
  61. data/upstream-lib/test_bench_bootstrap/test_bench/output/device.rb +75 -0
  62. data/upstream-lib/test_bench_bootstrap/test_bench/output/get.rb +32 -0
  63. data/upstream-lib/test_bench_bootstrap/test_bench/output/level.rb +53 -0
  64. data/upstream-lib/test_bench_bootstrap/test_bench/output/output.rb +572 -0
  65. data/upstream-lib/test_bench_bootstrap/test_bench/output/writer/style.rb +54 -0
  66. data/upstream-lib/test_bench_bootstrap/test_bench/output/writer/substitute.rb +27 -0
  67. data/upstream-lib/test_bench_bootstrap/test_bench/output/writer.rb +119 -0
  68. data/upstream-lib/test_bench_bootstrap/test_bench/output.rb +20 -0
  69. data/upstream-lib/test_bench_bootstrap/test_bench/random/controls/seed.rb +25 -0
  70. data/upstream-lib/test_bench_bootstrap/test_bench/random/controls/sequence.rb +70 -0
  71. data/upstream-lib/test_bench_bootstrap/test_bench/random/controls.rb +2 -0
  72. data/upstream-lib/test_bench_bootstrap/test_bench/random/defaults.rb +13 -0
  73. data/upstream-lib/test_bench_bootstrap/test_bench/random/generator/substitute.rb +23 -0
  74. data/upstream-lib/test_bench_bootstrap/test_bench/random/generator.rb +64 -0
  75. data/upstream-lib/test_bench_bootstrap/test_bench/random/iterator.rb +54 -0
  76. data/upstream-lib/test_bench_bootstrap/test_bench/random/random.rb +27 -0
  77. data/upstream-lib/test_bench_bootstrap/test_bench/random.rb +8 -0
  78. data/upstream-lib/test_bench_bootstrap/test_bench/run/controls/events.rb +9 -0
  79. data/upstream-lib/test_bench_bootstrap/test_bench/run/controls/message.rb +9 -0
  80. data/upstream-lib/test_bench_bootstrap/test_bench/run/controls/path.rb +9 -0
  81. data/upstream-lib/test_bench_bootstrap/test_bench/run/controls/random.rb +9 -0
  82. data/upstream-lib/test_bench_bootstrap/test_bench/run/controls/session.rb +16 -0
  83. data/upstream-lib/test_bench_bootstrap/test_bench/run/controls/status.rb +44 -0
  84. data/upstream-lib/test_bench_bootstrap/test_bench/run/controls/summary/file/info.rb +108 -0
  85. data/upstream-lib/test_bench_bootstrap/test_bench/run/controls/summary/file/totals.rb +38 -0
  86. data/upstream-lib/test_bench_bootstrap/test_bench/run/controls/summary/file.rb +44 -0
  87. data/upstream-lib/test_bench_bootstrap/test_bench/run/controls/summary/run.rb +53 -0
  88. data/upstream-lib/test_bench_bootstrap/test_bench/run/controls/summary.rb +45 -0
  89. data/upstream-lib/test_bench_bootstrap/test_bench/run/controls/telemetry.rb +11 -0
  90. data/upstream-lib/test_bench_bootstrap/test_bench/run/controls/time.rb +9 -0
  91. data/upstream-lib/test_bench_bootstrap/test_bench/run/controls.rb +20 -0
  92. data/upstream-lib/test_bench_bootstrap/test_bench/run/run.rb +146 -0
  93. data/upstream-lib/test_bench_bootstrap/test_bench/run/select_files/substitute.rb +45 -0
  94. data/upstream-lib/test_bench_bootstrap/test_bench/run/select_files.rb +70 -0
  95. data/upstream-lib/test_bench_bootstrap/test_bench/run/substitute.rb +42 -0
  96. data/upstream-lib/test_bench_bootstrap/test_bench/run/summary/substitute.rb +19 -0
  97. data/upstream-lib/test_bench_bootstrap/test_bench/run/summary.rb +477 -0
  98. data/upstream-lib/test_bench_bootstrap/test_bench/run.rb +10 -0
  99. data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/backtrace/location.rb +48 -0
  100. data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/backtrace.rb +83 -0
  101. data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/comment_disposition.rb +17 -0
  102. data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/event.rb +35 -0
  103. data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/events/aborted.rb +51 -0
  104. data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/events/commented.rb +62 -0
  105. data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/events/context_finished.rb +112 -0
  106. data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/events/context_started.rb +51 -0
  107. data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/events/detailed.rb +62 -0
  108. data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/events/failed.rb +41 -0
  109. data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/events/file_executed.rb +101 -0
  110. data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/events/file_not_found.rb +41 -0
  111. data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/events/file_queued.rb +41 -0
  112. data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/events/skipped.rb +51 -0
  113. data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/events/test_finished.rb +92 -0
  114. data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/events/test_started.rb +51 -0
  115. data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/events.rb +35 -0
  116. data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/exception/message.rb +23 -0
  117. data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/exception/raise.rb +52 -0
  118. data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/exception.rb +81 -0
  119. data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/message.rb +43 -0
  120. data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/metadata.rb +9 -0
  121. data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/path/apex_directory.rb +76 -0
  122. data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/path/file/create.rb +113 -0
  123. data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/path/file.rb +42 -0
  124. data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/path.rb +87 -0
  125. data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/random.rb +9 -0
  126. data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/result.rb +17 -0
  127. data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/sequence.rb +13 -0
  128. data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/status.rb +92 -0
  129. data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/telemetry.rb +15 -0
  130. data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/telemetry_sink.rb +37 -0
  131. data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/text.rb +33 -0
  132. data/upstream-lib/test_bench_bootstrap/test_bench/session/controls/title.rb +41 -0
  133. data/upstream-lib/test_bench_bootstrap/test_bench/session/controls.rb +43 -0
  134. data/upstream-lib/test_bench_bootstrap/test_bench/session/defaults.rb +17 -0
  135. data/upstream-lib/test_bench_bootstrap/test_bench/session/events.rb +24 -0
  136. data/upstream-lib/test_bench_bootstrap/test_bench/session/exception/format_backtrace/substitute.rb +34 -0
  137. data/upstream-lib/test_bench_bootstrap/test_bench/session/exception/format_backtrace.rb +114 -0
  138. data/upstream-lib/test_bench_bootstrap/test_bench/session/isolate/substitute.rb +45 -0
  139. data/upstream-lib/test_bench_bootstrap/test_bench/session/isolate.rb +159 -0
  140. data/upstream-lib/test_bench_bootstrap/test_bench/session/result.rb +44 -0
  141. data/upstream-lib/test_bench_bootstrap/test_bench/session/session.rb +236 -0
  142. data/upstream-lib/test_bench_bootstrap/test_bench/session/status.rb +60 -0
  143. data/upstream-lib/test_bench_bootstrap/test_bench/session/substitute/sink.rb +99 -0
  144. data/upstream-lib/test_bench_bootstrap/test_bench/session/substitute.rb +154 -0
  145. data/upstream-lib/test_bench_bootstrap/test_bench/session/trace.rb +53 -0
  146. data/upstream-lib/test_bench_bootstrap/test_bench/session.rb +22 -0
  147. data/upstream-lib/test_bench_bootstrap/test_bench/telemetry/controls/event/metadata.rb +72 -0
  148. data/upstream-lib/test_bench_bootstrap/test_bench/telemetry/controls/event.rb +156 -0
  149. data/upstream-lib/test_bench_bootstrap/test_bench/telemetry/controls/event_data.rb +113 -0
  150. data/upstream-lib/test_bench_bootstrap/test_bench/telemetry/controls/handler.rb +83 -0
  151. data/upstream-lib/test_bench_bootstrap/test_bench/telemetry/controls/path/file.rb +39 -0
  152. data/upstream-lib/test_bench_bootstrap/test_bench/telemetry/controls/process_id.rb +25 -0
  153. data/upstream-lib/test_bench_bootstrap/test_bench/telemetry/controls/random.rb +11 -0
  154. data/upstream-lib/test_bench_bootstrap/test_bench/telemetry/controls/sink.rb +35 -0
  155. data/upstream-lib/test_bench_bootstrap/test_bench/telemetry/controls/time.rb +104 -0
  156. data/upstream-lib/test_bench_bootstrap/test_bench/telemetry/controls.rb +16 -0
  157. data/upstream-lib/test_bench_bootstrap/test_bench/telemetry/event.rb +130 -0
  158. data/upstream-lib/test_bench_bootstrap/test_bench/telemetry/event_data/serialization.rb +85 -0
  159. data/upstream-lib/test_bench_bootstrap/test_bench/telemetry/event_data.rb +15 -0
  160. data/upstream-lib/test_bench_bootstrap/test_bench/telemetry/sink/file.rb +39 -0
  161. data/upstream-lib/test_bench_bootstrap/test_bench/telemetry/sink/handler/event_registry.rb +44 -0
  162. data/upstream-lib/test_bench_bootstrap/test_bench/telemetry/sink/handler.rb +128 -0
  163. data/upstream-lib/test_bench_bootstrap/test_bench/telemetry/sink.rb +13 -0
  164. data/upstream-lib/test_bench_bootstrap/test_bench/telemetry/substitute/sink.rb +71 -0
  165. data/upstream-lib/test_bench_bootstrap/test_bench/telemetry/substitute.rb +43 -0
  166. data/upstream-lib/test_bench_bootstrap/test_bench/telemetry/telemetry.rb +92 -0
  167. data/upstream-lib/test_bench_bootstrap/test_bench/telemetry.rb +18 -0
  168. data/upstream-lib/test_bench_bootstrap/test_bench/test_bench.rb +72 -0
  169. data/upstream-lib/test_bench_bootstrap/test_bench.rb +4 -0
  170. metadata +353 -16
  171. data/lib/test_bench/bootstrap.rb +0 -328
@@ -0,0 +1,35 @@
1
+ module TestBenchBootstrap
2
+ module TestBench
3
+ class Session
4
+ module Controls
5
+ module Events
6
+ def self.examples(control_method=nil)
7
+ control_method ||= :example
8
+
9
+ [
10
+ Failed,
11
+ Aborted,
12
+ Skipped,
13
+ Commented,
14
+ Detailed,
15
+ TestStarted,
16
+ TestFinished,
17
+ ContextStarted,
18
+ ContextFinished,
19
+ FileQueued,
20
+ FileExecuted,
21
+ FileNotFound
22
+ ].map do |control|
23
+
24
+ control.public_send(control_method)
25
+ end
26
+ end
27
+
28
+ def self.other_examples
29
+ examples(:other_example)
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,23 @@
1
+ module TestBenchBootstrap
2
+ module TestBench
3
+ class Session
4
+ module Controls
5
+ module Exception
6
+ module Message
7
+ def self.example
8
+ exception = Example
9
+
10
+ exception.detailed_message
11
+ end
12
+
13
+ def self.other_example
14
+ exception = Other::Example
15
+
16
+ exception.detailed_message
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,52 @@
1
+ module TestBenchBootstrap
2
+ module TestBench
3
+ class Session
4
+ module Controls
5
+ module Exception
6
+ module Raise
7
+ def self.call(exception_class, exception_message, relative: nil)
8
+ apex_directory = Path::ApexDirectory::Create.()
9
+
10
+ if Exception.const_defined?(:SomeNamespace)
11
+ Exception.send(:remove_const, :SomeNamespace)
12
+ end
13
+
14
+ file_1 = Controls::Path::File::Create.(<<~RUBY, subdirectory: :none, apex_directory:, relative:)
15
+ #{Controls::Exception}::SomeNamespace.module_exec { def self.some_method = raise #{exception_class}, #{exception_message.inspect}, caller_locations(0, 4) }
16
+ RUBY
17
+
18
+ file_2 = Controls::Path::File::Create.(<<~RUBY, basename: 'some-file', apex_directory:, relative:)
19
+ module #{Controls::Exception}::SomeNamespace
20
+ def self.some_other_method = some_method
21
+ end
22
+ RUBY
23
+
24
+ file_3 = Controls::Path::File::Create.(<<~RUBY, basename: 'some-other-file', apex_directory:, relative:)
25
+ module #{Controls::Exception}
26
+ module SomeNamespace
27
+ def self.yet_another_method = some_other_method
28
+ end
29
+ end
30
+ RUBY
31
+
32
+ file_4 = Controls::Path::File::Create.(<<~RUBY, basename: 'some-other-file', subdirectory: :none, apex_directory:, relative:)
33
+ #{[file_3, file_2, file_1].inspect}.each { |file| load file }
34
+
35
+ module #{Controls::Exception}::SomeNamespace
36
+ def self.origin = yet_another_method; origin
37
+ end
38
+ RUBY
39
+
40
+ ::Dir.chdir(apex_directory) do
41
+ load file_4
42
+ end
43
+
44
+ ensure
45
+ Path::ApexDirectory::Remove.(apex_directory)
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,81 @@
1
+ module TestBenchBootstrap
2
+ module TestBench
3
+ class Session
4
+ module Controls
5
+ module Exception
6
+ def self.example(exception_message: nil, exception_class: nil, relative: nil)
7
+ exception_message ||= self.exception_message
8
+ exception_class ||= self.exception_class
9
+
10
+ Raise.(exception_class, exception_message, relative:)
11
+ rescue exception_class => exception
12
+ return exception
13
+ else
14
+ abort "Unreachable"
15
+ end
16
+
17
+ def self.exception_message
18
+ "Some exception"
19
+ end
20
+
21
+ def self.exception_class
22
+ SomeException
23
+ end
24
+
25
+ SomeException = Class.new(::Exception)
26
+ SomeOtherException = Class.new(::Exception)
27
+
28
+ Example = self.example
29
+
30
+ module Other
31
+ def self.example
32
+ Exception.example(exception_message:, exception_class:)
33
+ end
34
+
35
+ def self.exception_message
36
+ "Some other exception"
37
+ end
38
+
39
+ def self.exception_class
40
+ SomeOtherException
41
+ end
42
+
43
+ Example = self.example
44
+ end
45
+
46
+ module Cause
47
+ def self.example(exception_message: nil, exception_class: nil)
48
+ exception_message ||= self.exception_message
49
+ exception_class ||= self.exception_class
50
+
51
+ Raise.(exception_class, exception_message)
52
+ rescue SomeOtherException
53
+ exception = Exception.example(exception_message:, exception_class:)
54
+ return exception
55
+ else
56
+ abort "Unreachable"
57
+ end
58
+
59
+ def self.exception_message
60
+ "Some exception cause"
61
+ end
62
+
63
+ def self.exception_class
64
+ SomeOtherException
65
+ end
66
+
67
+ Example = self.example
68
+ end
69
+
70
+ module AbsolutePaths
71
+ def self.example
72
+ Exception.example(relative: false)
73
+ end
74
+
75
+ Example = self.example
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,43 @@
1
+ module TestBenchBootstrap
2
+ module TestBench
3
+ class Session
4
+ module Controls
5
+ module Message
6
+ def self.example
7
+ "Some message"
8
+ end
9
+
10
+ module Failure
11
+ def self.example
12
+ "Some failure"
13
+ end
14
+
15
+ def self.other_example
16
+ "Some other failure"
17
+ end
18
+ end
19
+
20
+ module Error
21
+ def self.example
22
+ Exception::Message.example
23
+ end
24
+
25
+ def self.other_example
26
+ Exception::Message.other_example
27
+ end
28
+ end
29
+
30
+ module Skip
31
+ def self.example
32
+ "Some skipped test or context"
33
+ end
34
+
35
+ def self.other_example
36
+ "Some other skipped test or context"
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,9 @@
1
+ module TestBenchBootstrap
2
+ module TestBench
3
+ class Session
4
+ module Controls
5
+ Metadata = Telemetry::Metadata
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,76 @@
1
+ module TestBenchBootstrap
2
+ module TestBench
3
+ class Session
4
+ module Controls
5
+ module Path
6
+ module ApexDirectory
7
+ def self.example(name=nil)
8
+ name ||= Name.example
9
+
10
+ ::File.expand_path(name, tmpdir)
11
+ end
12
+
13
+ def self.tmpdir
14
+ ::Dir.tmpdir
15
+ end
16
+
17
+ module Name
18
+ def self.example
19
+ 'test-automated-session-controls'
20
+ end
21
+
22
+ def self.random
23
+ "#{example}-#{Random.string}"
24
+ end
25
+ end
26
+
27
+ module Create
28
+ def self.call(name=nil)
29
+ name ||= Name.random
30
+
31
+ apex_directory = ApexDirectory.example(name)
32
+
33
+ ::Dir.mkdir(apex_directory)
34
+
35
+ if ENV.fetch('DEBUG_PATH_CONTROLS', 'off') == 'on'
36
+ warn "created directory '#{apex_directory}'"
37
+ end
38
+
39
+ apex_directory
40
+ end
41
+ end
42
+
43
+ module Remove
44
+ def self.call(apex_directory)
45
+ remove(apex_directory)
46
+ end
47
+
48
+ def self.remove(directory)
49
+ ::Dir.each_child(directory) do |entry|
50
+ absolute_path = ::File.expand_path(entry, directory)
51
+
52
+ if ::File.directory?(absolute_path)
53
+ subdirectory = absolute_path
54
+ remove(subdirectory)
55
+ else
56
+ ::File.unlink(absolute_path)
57
+
58
+ if ENV.fetch('DEBUG_PATH_CONTROLS', 'off') == 'on'
59
+ warn "removed '#{absolute_path}'"
60
+ end
61
+ end
62
+ end
63
+
64
+ ::Dir.rmdir(directory)
65
+
66
+ if ENV.fetch('DEBUG_PATH_CONTROLS', 'off') == 'on'
67
+ warn "removed directory '#{directory}'"
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,113 @@
1
+ module TestBenchBootstrap
2
+ module TestBench
3
+ class Session
4
+ module Controls
5
+ module Path
6
+ module File
7
+ module Create
8
+ def self.call(content=nil, basename: nil, extension: nil, directory: nil, subdirectory: nil, apex_directory: nil, relative: nil)
9
+ if relative.nil?
10
+ relative = !apex_directory.nil?
11
+ end
12
+
13
+ apex_directory ||= ::Dir.tmpdir
14
+
15
+ absolute_path = File.example(basename:, extension:, directory:, subdirectory:, apex_directory:)
16
+
17
+ relative_path = absolute_path.delete_prefix(::File.join(apex_directory, ''))
18
+
19
+ if relative
20
+ file_path = relative_path
21
+ else
22
+ file_path = absolute_path
23
+ end
24
+
25
+ content ||= "# #{file_path}\n"
26
+
27
+ segments = []
28
+
29
+ until ['.', '/'].include?(relative_path)
30
+ segments.unshift(::File.basename(relative_path))
31
+
32
+ relative_path = ::File.dirname(relative_path)
33
+ end
34
+
35
+ (1...segments.length).each do |index|
36
+ directory_segments = segments[...index]
37
+
38
+ directory = ::File.join(apex_directory, *directory_segments)
39
+
40
+ if not ::File.directory?(directory)
41
+ ::Dir.mkdir(directory)
42
+ end
43
+ end
44
+
45
+ ::File.write(absolute_path, content)
46
+
47
+ if ENV.fetch('DEBUG_PATH_CONTROLS', 'off') == 'on'
48
+ warn "created '#{absolute_path}'"
49
+ end
50
+
51
+ file_path
52
+ end
53
+
54
+ module Exception
55
+ def self.call(apex_directory: nil)
56
+ Create.(content, basename:, apex_directory:)
57
+ end
58
+
59
+ def self.basename
60
+ 'some_aborting_file.rb'
61
+ end
62
+
63
+ def self.content
64
+ <<~RUBY
65
+ raise #{Controls::Exception}::Example
66
+ RUBY
67
+ end
68
+ end
69
+
70
+ module Comment
71
+ def self.call(text: nil, apex_directory: nil)
72
+ text ||= self.text
73
+
74
+ basename = "write_comment__#{text.gsub(' ', '_')}"
75
+
76
+ content = Content.example(text:)
77
+
78
+ Create.(content, basename:, apex_directory:)
79
+ end
80
+
81
+ def self.content
82
+ Content.example
83
+ end
84
+
85
+ def self.basename
86
+ 'some_commenting_file'
87
+ end
88
+
89
+ def self.text
90
+ Text::Comment.example
91
+ end
92
+
93
+ module Content
94
+ def self.example(text: nil)
95
+ text ||= Comment.text
96
+
97
+ <<~RUBY
98
+ comment_text = #{text.inspect}
99
+
100
+ commented = #{Controls::Events::Commented}.example(text: comment_text)
101
+
102
+ Session.instance.record_event(commented)
103
+ RUBY
104
+ end
105
+ end
106
+ end
107
+ end
108
+ end
109
+ end
110
+ end
111
+ end
112
+ end
113
+ end
@@ -0,0 +1,42 @@
1
+ module TestBenchBootstrap
2
+ module TestBench
3
+ class Session
4
+ module Controls
5
+ module Path
6
+ module File
7
+ def self.example(basename: nil, extension: nil, directory: nil, subdirectory: nil, apex_directory: nil)
8
+ basename ||= self.basename
9
+ extension ||= self.extension
10
+
11
+ filename = "#{basename}#{extension}"
12
+
13
+ Path.example(name: filename, directory:, subdirectory:, apex_directory:)
14
+ end
15
+
16
+ def self.basename
17
+ 'some-file'
18
+ end
19
+
20
+ def self.extension
21
+ '.rb'
22
+ end
23
+
24
+ def self.other_example
25
+ Other.example
26
+ end
27
+
28
+ module Other
29
+ def self.example(apex_directory: nil)
30
+ File.example(basename:, apex_directory:)
31
+ end
32
+
33
+ def self.basename
34
+ 'some-other-file'
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,87 @@
1
+ module TestBenchBootstrap
2
+ module TestBench
3
+ class Session
4
+ module Controls
5
+ module Path
6
+ def self.example(name: nil, directory: nil, subdirectory: nil, apex_directory: nil)
7
+ if apex_directory.nil?
8
+ Relative.example(name:, directory:, subdirectory:)
9
+ else
10
+ Absolute.example(name:, directory:, subdirectory:, apex_directory:)
11
+ end
12
+ end
13
+
14
+ def self.name
15
+ 'some-entry'
16
+ end
17
+
18
+ def self.directory
19
+ 'some-dir'
20
+ end
21
+
22
+ def self.subdirectory
23
+ 'some-subdir'
24
+ end
25
+
26
+ def self.other_example
27
+ Other.example
28
+ end
29
+
30
+ module Other
31
+ def self.example(apex_directory: nil)
32
+ Path.example(name:, directory:, subdirectory:, apex_directory:)
33
+ end
34
+
35
+ def self.name
36
+ 'some-other-entry'
37
+ end
38
+
39
+ def self.directory
40
+ 'some-other-dir'
41
+ end
42
+
43
+ def self.subdirectory
44
+ 'some-other-subdir'
45
+ end
46
+ end
47
+
48
+ module Absolute
49
+ def self.example(name: nil, directory: nil, subdirectory: nil, apex_directory: nil)
50
+ apex_directory ||= self.apex_directory
51
+
52
+ relative_path = Relative.example(name:, directory:, subdirectory:)
53
+
54
+ ::File.join(apex_directory, relative_path)
55
+ end
56
+
57
+ def self.apex_directory
58
+ '/'
59
+ end
60
+ end
61
+
62
+ module Relative
63
+ def self.example(name: nil, directory: nil, subdirectory: nil)
64
+ name ||= Path.name
65
+
66
+ if directory == :none
67
+ directory = nil
68
+ else
69
+ directory ||= Path.directory
70
+ end
71
+
72
+ if subdirectory == :none
73
+ subdirectory = nil
74
+ elsif not directory.nil?
75
+ subdirectory ||= Path.subdirectory
76
+ end
77
+
78
+ segments = [directory, subdirectory, name].compact
79
+
80
+ ::File.join(*segments)
81
+ end
82
+ end
83
+ end
84
+ end
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,9 @@
1
+ module TestBenchBootstrap
2
+ module TestBench
3
+ class Session
4
+ module Controls
5
+ Random = Telemetry::Random
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,17 @@
1
+ module TestBenchBootstrap
2
+ module TestBench
3
+ class Session
4
+ module Controls
5
+ module Result
6
+ def self.example
7
+ Session::Result.passed
8
+ end
9
+
10
+ def self.other_example
11
+ Session::Result.failed
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,13 @@
1
+ module TestBenchBootstrap
2
+ module TestBench
3
+ class Session
4
+ module Controls
5
+ module Sequence
6
+ def self.example
7
+ 11
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,92 @@
1
+ module TestBenchBootstrap
2
+ module TestBench
3
+ class Session
4
+ module Controls
5
+ module Status
6
+ def self.example
7
+ Relative.example
8
+ end
9
+
10
+ module Passed
11
+ def self.example
12
+ Session::Status.new(
13
+ test_sequence: Sequence.example,
14
+ failure_sequence: 0,
15
+ error_sequence: 0,
16
+ skip_sequence: 0
17
+ )
18
+ end
19
+ end
20
+
21
+ module Failed
22
+ def self.example
23
+ Session::Status.new(
24
+ test_sequence: Sequence.example,
25
+ failure_sequence: Sequence.example,
26
+ error_sequence: 0,
27
+ skip_sequence: 0
28
+ )
29
+ end
30
+ end
31
+
32
+ module None
33
+ def self.example
34
+ Session::Status.new(
35
+ test_sequence: 0,
36
+ failure_sequence: 0,
37
+ error_sequence: 0,
38
+ skip_sequence: 0
39
+ )
40
+ end
41
+ end
42
+
43
+ module Aborted
44
+ def self.example
45
+ Session::Status.new(
46
+ test_sequence: Sequence.example,
47
+ failure_sequence: Sequence.example,
48
+ error_sequence: Sequence.example,
49
+ skip_sequence: 0
50
+ )
51
+ end
52
+ end
53
+
54
+ module Incomplete
55
+ def self.example
56
+ Session::Status.new(
57
+ test_sequence: Sequence.example,
58
+ failure_sequence: 0,
59
+ error_sequence: 0,
60
+ skip_sequence: Sequence.example
61
+ )
62
+ end
63
+ end
64
+
65
+ module Relative
66
+ def self.example
67
+ Session::Status.new(
68
+ test_sequence: 1,
69
+ failure_sequence: 11,
70
+ error_sequence: 111,
71
+ skip_sequence: 1111
72
+ )
73
+ end
74
+
75
+ def self.reference
76
+ Session::Status.new(
77
+ test_sequence: 0,
78
+ failure_sequence: 1,
79
+ error_sequence: 11,
80
+ skip_sequence: 111
81
+ )
82
+ end
83
+
84
+ def self.result
85
+ Session::Result.aborted
86
+ end
87
+ end
88
+ end
89
+ end
90
+ end
91
+ end
92
+ end