test_bench-executable 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.
- checksums.yaml +7 -0
- data/executables/bench +7 -0
- data/lib/test_bench/executable/controls/path.rb +7 -0
- data/lib/test_bench/executable/controls/random.rb +7 -0
- data/lib/test_bench/executable/controls/run.rb +10 -0
- data/lib/test_bench/executable/controls/standard_input.rb +29 -0
- data/lib/test_bench/executable/controls.rb +8 -0
- data/lib/test_bench/executable/defaults.rb +13 -0
- data/lib/test_bench/executable/executable.rb +59 -0
- data/lib/test_bench/executable/parse_arguments.rb +269 -0
- data/lib/test_bench/executable.rb +7 -0
- metadata +83 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3361ac46c2f4a7c781487b6cb0bd2cbba8e42641e9c65f6f79c818dc4d117c10
|
4
|
+
data.tar.gz: 4e880c8bd7c350be520d97090576aff3ec1df15d1ed7fb554c8afb6514258e21
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 73653a1db9633eafb8c2f78a5fc23d40e91db825ef926223601812f28ce994aa4c60a15951997e9ff1ce35701b7f2d649642709334033de4c780ae409bd047e2
|
7
|
+
data.tar.gz: 3a1b01385a0711606330638591c9ef1bed953efc2da99f7f6cc6f9efe03c799317c460c1e5deaddbd799ae35d62420268f822e74b3713bf8133b6683d77327b2
|
data/executables/bench
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
module TestBench
|
2
|
+
class Executable
|
3
|
+
module Controls
|
4
|
+
module StandardInput
|
5
|
+
module Create
|
6
|
+
def self.call(*paths)
|
7
|
+
if paths.empty?
|
8
|
+
paths = Path.examples
|
9
|
+
end
|
10
|
+
|
11
|
+
content = <<~TEXT
|
12
|
+
#{paths.join("\n")}
|
13
|
+
TEXT
|
14
|
+
|
15
|
+
file = Session::Controls::Path::File::Create.(content)
|
16
|
+
|
17
|
+
::File.open(file, 'r')
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.contents
|
21
|
+
<<~TEXT
|
22
|
+
#{Path.example}
|
23
|
+
TEXT
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module TestBench
|
2
|
+
class Executable
|
3
|
+
def run
|
4
|
+
@run ||= Run::Substitute.build
|
5
|
+
end
|
6
|
+
attr_writer :run
|
7
|
+
|
8
|
+
def arguments
|
9
|
+
@arguments ||= []
|
10
|
+
end
|
11
|
+
attr_writer :arguments
|
12
|
+
|
13
|
+
def stdin
|
14
|
+
@stdin ||= STDIN
|
15
|
+
end
|
16
|
+
attr_writer :stdin
|
17
|
+
|
18
|
+
def self.build(arguments=nil, env: nil)
|
19
|
+
instance = new
|
20
|
+
|
21
|
+
arguments = ParseArguments.(arguments, env:)
|
22
|
+
instance.arguments = arguments
|
23
|
+
|
24
|
+
Run.configure(instance)
|
25
|
+
|
26
|
+
instance
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.call(arguments=nil, env: nil)
|
30
|
+
instance = build(arguments, env:)
|
31
|
+
instance.()
|
32
|
+
end
|
33
|
+
|
34
|
+
def call
|
35
|
+
result = run.() do
|
36
|
+
if not stdin.tty?
|
37
|
+
until stdin.eof?
|
38
|
+
path = stdin.gets(chomp: true)
|
39
|
+
|
40
|
+
next if path.empty?
|
41
|
+
|
42
|
+
run << path
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
arguments.each do |path|
|
47
|
+
run << path
|
48
|
+
end
|
49
|
+
|
50
|
+
if not run.ran?
|
51
|
+
run << Defaults.path
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
exit_code = result ? 0 : 1
|
56
|
+
exit_code
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,269 @@
|
|
1
|
+
module TestBench
|
2
|
+
class Executable
|
3
|
+
class ParseArguments
|
4
|
+
Error = Class.new(RuntimeError)
|
5
|
+
|
6
|
+
def writer
|
7
|
+
@writer ||= Output::Writer::Substitute.build
|
8
|
+
end
|
9
|
+
attr_writer :writer
|
10
|
+
|
11
|
+
def env
|
12
|
+
@env ||= {}
|
13
|
+
end
|
14
|
+
attr_writer :env
|
15
|
+
|
16
|
+
def non_switch_arguments
|
17
|
+
@non_switch_arguments ||= []
|
18
|
+
end
|
19
|
+
|
20
|
+
attr_reader :raw_arguments
|
21
|
+
|
22
|
+
def initialize(raw_arguments)
|
23
|
+
@raw_arguments = raw_arguments
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.build(arguments=nil, env: nil)
|
27
|
+
arguments ||= ::ARGV
|
28
|
+
env ||= ::ENV
|
29
|
+
|
30
|
+
instance = new(arguments)
|
31
|
+
|
32
|
+
instance.env = env
|
33
|
+
|
34
|
+
Output::Writer.configure(instance)
|
35
|
+
|
36
|
+
instance
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.call(arguments=nil, env: nil)
|
40
|
+
instance = build(arguments, env:)
|
41
|
+
instance.()
|
42
|
+
end
|
43
|
+
|
44
|
+
def call
|
45
|
+
loop do
|
46
|
+
switch = next_switch
|
47
|
+
|
48
|
+
case switch
|
49
|
+
when '--', nil
|
50
|
+
break
|
51
|
+
|
52
|
+
when '-a', '--abort-on-failure'
|
53
|
+
env['TEST_BENCH_ABORT_ON_FAILURE'] = 'on'
|
54
|
+
|
55
|
+
when '-x', '--exclude'
|
56
|
+
exclude_pattern = require_next_argument(switch)
|
57
|
+
|
58
|
+
env['TEST_BENCH_EXCLUDE_FILE_PATTERN'] = [
|
59
|
+
env['TEST_BENCH_EXCLUDE_FILE_PATTERN'],
|
60
|
+
exclude_pattern
|
61
|
+
].compact.join(':')
|
62
|
+
when '-X', '--no-exclude'
|
63
|
+
env['TEST_BENCH_EXCLUDE_FILE_PATTERN'] = ''
|
64
|
+
|
65
|
+
when '-s', '--strict'
|
66
|
+
env['TEST_BENCH_STRICT'] = 'on'
|
67
|
+
when '-S', '--no-strict'
|
68
|
+
env['TEST_BENCH_STRICT'] = 'off'
|
69
|
+
|
70
|
+
when '-r', '--require'
|
71
|
+
library = require_next_argument(switch)
|
72
|
+
require(library)
|
73
|
+
when '-I', '--include'
|
74
|
+
load_path = require_next_argument(switch)
|
75
|
+
if not $LOAD_PATH.include?(load_path)
|
76
|
+
$LOAD_PATH << load_path
|
77
|
+
end
|
78
|
+
|
79
|
+
when '--random-seed'
|
80
|
+
seed = require_next_argument(switch)
|
81
|
+
env['TEST_BENCH_RANDOM_SEED'] = seed
|
82
|
+
|
83
|
+
when '-b', '--omit-backtrace'
|
84
|
+
omit_pattern = require_next_argument(switch)
|
85
|
+
|
86
|
+
env['TEST_BENCH_OMIT_BACKTRACE_PATTERN'] = [
|
87
|
+
env['TEST_BENCH_OMIT_BACKTRACE_PATTERN'],
|
88
|
+
omit_pattern
|
89
|
+
].compact.join(':')
|
90
|
+
|
91
|
+
when '-d', '--detail'
|
92
|
+
env['TEST_BENCH_OUTPUT_DETAIL'] = 'on'
|
93
|
+
when '-D', '--no-detail'
|
94
|
+
env['TEST_BENCH_OUTPUT_DETAIL'] = 'off'
|
95
|
+
|
96
|
+
when '--device'
|
97
|
+
device = require_next_argument(switch)
|
98
|
+
env['TEST_BENCH_OUTPUT_DEVICE'] = device
|
99
|
+
|
100
|
+
when '-l', '--output-level'
|
101
|
+
output_level = require_next_argument(switch)
|
102
|
+
env['TEST_BENCH_OUTPUT_LEVEL'] = output_level
|
103
|
+
when '-q', '--quiet'
|
104
|
+
env['TEST_BENCH_OUTPUT_LEVEL'] = 'not-passing'
|
105
|
+
|
106
|
+
when '-o', '--output-styling'
|
107
|
+
env['TEST_BENCH_OUTPUT_STYLING'] = 'on'
|
108
|
+
when '-O', '--no-output-styling'
|
109
|
+
env['TEST_BENCH_OUTPUT_STYLING'] = 'off'
|
110
|
+
|
111
|
+
when '--no-summary'
|
112
|
+
env['TEST_BENCH_OUTPUT_SUMMARY'] = 'off'
|
113
|
+
|
114
|
+
when '-h', '--help'
|
115
|
+
writer.write(<<~TEXT)
|
116
|
+
Usage: #{Defaults.program_name} [options] [paths]
|
117
|
+
|
118
|
+
Informational Options:
|
119
|
+
Help:
|
120
|
+
-h, --help
|
121
|
+
Print this help message and exit immediately
|
122
|
+
|
123
|
+
Execution Options:
|
124
|
+
Abort On Failure:
|
125
|
+
-a, --abort-on-failure
|
126
|
+
Stops execution if a test fails or a test file aborts
|
127
|
+
|
128
|
+
Exclude File Patterns:
|
129
|
+
-x, --exclude PATTERN
|
130
|
+
Exclude test files that match PATTERN
|
131
|
+
If multiple --exclude arguments are supplied, then files that match any will be excluded
|
132
|
+
-X, --no-exclude
|
133
|
+
Don't exclude any files
|
134
|
+
Default: '*_init.rb'
|
135
|
+
|
136
|
+
Strict:
|
137
|
+
-s, --strict
|
138
|
+
Prohibit skipped tests and contexts, and require at least one test to be performed
|
139
|
+
-S, --no-strict
|
140
|
+
Relax strictness
|
141
|
+
Default: non strict, unless TEST_BENCH_STRICT is set to 'on'
|
142
|
+
|
143
|
+
Require Library:
|
144
|
+
-r, --require LIBRARY
|
145
|
+
Require LIBRARY before running any files
|
146
|
+
-I, --include DIR
|
147
|
+
Add DIR to the load path
|
148
|
+
|
149
|
+
Random Seed:
|
150
|
+
--random-seed SEED
|
151
|
+
Pseudorandom number seed
|
152
|
+
|
153
|
+
Output Options:
|
154
|
+
Backtrace Formatting:
|
155
|
+
-b, --omit-backtrace PATTERN
|
156
|
+
Omits backtrace frames that match PATTERN
|
157
|
+
If multiple --omit-backtrace arguments are supplied, then frames that match any will be omitted
|
158
|
+
|
159
|
+
Detail:
|
160
|
+
-d, --detail
|
161
|
+
Always show details
|
162
|
+
-D, --no-detail
|
163
|
+
Never show details
|
164
|
+
Default: print details when their surrounding context failed, unless TEST_DETAIL is set to 'on' or 'off'
|
165
|
+
|
166
|
+
Device:
|
167
|
+
--device DEVICE
|
168
|
+
stderr: redirect output to standard error
|
169
|
+
null: don't write any output
|
170
|
+
Default: stdout
|
171
|
+
|
172
|
+
Verbosity:
|
173
|
+
-l, --output-level LEVEL
|
174
|
+
all: print output from every file
|
175
|
+
not-passing: print output from files that skip tests and contexts or don't perform any tests
|
176
|
+
failure: print output only from files that failed or aborted
|
177
|
+
abort: print output only from file that aborted
|
178
|
+
-q, --quiet
|
179
|
+
Sets output verbosity level to 'not-passing'
|
180
|
+
Default: all
|
181
|
+
|
182
|
+
Styling:
|
183
|
+
-o, --output-styling
|
184
|
+
Enable output text styling
|
185
|
+
-O, --no-output-styling
|
186
|
+
Disable output text styling
|
187
|
+
Default: enabled if the output device is an interactive terminal
|
188
|
+
|
189
|
+
Summary:
|
190
|
+
--no-summary
|
191
|
+
Don't print summary after running files
|
192
|
+
|
193
|
+
Paths to test files (and directories containing test files) can be given after any command line arguments or via STDIN (or both).
|
194
|
+
|
195
|
+
If no paths are given, the directory '#{Defaults.path}' is scanned for test files.
|
196
|
+
|
197
|
+
The following environment variables can also control execution:
|
198
|
+
|
199
|
+
TEST_BENCH_ABORT_ON_FAILURE See --abort-on-failure
|
200
|
+
TEST_BENCH_EXCLUDE_FILE_PATTERN See --exclude
|
201
|
+
TEST_BENCH_OUTPUT_SUMMARY See --no-summary
|
202
|
+
TEST_BENCH_STRICT See --strict
|
203
|
+
TEST_BENCH_RANDOM_SEED See --random-seed
|
204
|
+
TEST_BENCH_FILTER_BACKTRACE_PATTERN See --filter-backtrace
|
205
|
+
TEST_BENCH_OUTPUT_DETAIL See --detail
|
206
|
+
TEST_BENCH_OUTPUT_DEVICE See --device
|
207
|
+
TEST_BENCH_OUTPUT_LEVEL See --output-level
|
208
|
+
TEST_BENCH_OUTPUT_STYLING See --output-styling
|
209
|
+
TEST_BENCH_DEFAULT_TEST_PATH Specifies default path
|
210
|
+
|
211
|
+
TEXT
|
212
|
+
exit(true)
|
213
|
+
|
214
|
+
else
|
215
|
+
raise Error, "Incorrect switch #{switch}"
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
remaining_arguments
|
220
|
+
end
|
221
|
+
|
222
|
+
def remaining_arguments
|
223
|
+
non_switch_arguments + raw_arguments
|
224
|
+
end
|
225
|
+
alias :arguments :remaining_arguments
|
226
|
+
|
227
|
+
def require_next_argument(switch_text)
|
228
|
+
argument = next_argument
|
229
|
+
|
230
|
+
if argument.nil?
|
231
|
+
raise Error, "Switch #{switch_text} requires an argument"
|
232
|
+
end
|
233
|
+
|
234
|
+
argument
|
235
|
+
end
|
236
|
+
|
237
|
+
def next_argument
|
238
|
+
next_argument = raw_arguments.shift
|
239
|
+
|
240
|
+
if next_argument.nil?
|
241
|
+
nil
|
242
|
+
elsif switch?(next_argument)
|
243
|
+
raw_arguments.unshift(next_argument)
|
244
|
+
nil
|
245
|
+
else
|
246
|
+
next_argument
|
247
|
+
end
|
248
|
+
end
|
249
|
+
|
250
|
+
def next_switch
|
251
|
+
until raw_arguments.empty?
|
252
|
+
argument = raw_arguments.shift
|
253
|
+
|
254
|
+
if switch?(argument)
|
255
|
+
return argument
|
256
|
+
end
|
257
|
+
|
258
|
+
non_switch_arguments << argument
|
259
|
+
end
|
260
|
+
|
261
|
+
nil
|
262
|
+
end
|
263
|
+
|
264
|
+
def switch?(argument)
|
265
|
+
argument.start_with?('-')
|
266
|
+
end
|
267
|
+
end
|
268
|
+
end
|
269
|
+
end
|
metadata
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: test_bench-executable
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 3.0.0.0.pre.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Brightworks Digital
|
8
|
+
bindir: executables
|
9
|
+
cert_chain: []
|
10
|
+
dependencies:
|
11
|
+
- !ruby/object:Gem::Dependency
|
12
|
+
name: test_bench-run
|
13
|
+
requirement: !ruby/object:Gem::Requirement
|
14
|
+
requirements:
|
15
|
+
- - ">="
|
16
|
+
- !ruby/object:Gem::Version
|
17
|
+
version: '0'
|
18
|
+
type: :runtime
|
19
|
+
prerelease: false
|
20
|
+
version_requirements: !ruby/object:Gem::Requirement
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: '0'
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: test_bench-bootstrap
|
27
|
+
requirement: !ruby/object:Gem::Requirement
|
28
|
+
requirements:
|
29
|
+
- - ">="
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: '0'
|
32
|
+
type: :development
|
33
|
+
prerelease: false
|
34
|
+
version_requirements: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ">="
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
description: Command line interface for TestBench.
|
40
|
+
email: development@bright.works
|
41
|
+
executables:
|
42
|
+
- bench
|
43
|
+
extensions: []
|
44
|
+
extra_rdoc_files: []
|
45
|
+
files:
|
46
|
+
- lib/test_bench
|
47
|
+
- lib/test_bench/executable
|
48
|
+
- lib/test_bench/executable/controls
|
49
|
+
- lib/test_bench/executable/controls/path.rb
|
50
|
+
- lib/test_bench/executable/controls/random.rb
|
51
|
+
- lib/test_bench/executable/controls/run.rb
|
52
|
+
- lib/test_bench/executable/controls/standard_input.rb
|
53
|
+
- lib/test_bench/executable/controls.rb
|
54
|
+
- lib/test_bench/executable/defaults.rb
|
55
|
+
- lib/test_bench/executable/executable.rb
|
56
|
+
- lib/test_bench/executable/parse_arguments.rb
|
57
|
+
- lib/test_bench/executable.rb
|
58
|
+
homepage: http://test-bench.software
|
59
|
+
licenses:
|
60
|
+
- MIT
|
61
|
+
metadata:
|
62
|
+
homepage_uri: http://test-bench.software
|
63
|
+
source_code_uri: https://github.com/test-bench-demo/test-bench-executable
|
64
|
+
allowed_push_host: https://rubygems.org
|
65
|
+
namespace: TestBench::Executable
|
66
|
+
rdoc_options: []
|
67
|
+
require_paths:
|
68
|
+
- lib
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
requirements: []
|
80
|
+
rubygems_version: 3.6.9
|
81
|
+
specification_version: 4
|
82
|
+
summary: Command line interface for TestBench
|
83
|
+
test_files: []
|