test_bench 1.2.0.10 → 2.0.0.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/lib/test_bench/cli.rb +268 -18
  3. data/lib/test_bench/controls/file.rb +5 -0
  4. data/lib/test_bench/controls/path.rb +1 -11
  5. data/lib/test_bench/controls/random.rb +7 -0
  6. data/lib/test_bench/controls/result.rb +1 -1
  7. data/lib/test_bench/controls/stdin.rb +27 -0
  8. data/lib/test_bench/controls.rb +7 -24
  9. data/lib/test_bench/test_bench.rb +23 -77
  10. data/lib/test_bench.rb +1 -35
  11. metadata +16 -55
  12. data/lib/test_bench/cli/parse_arguments.rb +0 -181
  13. data/lib/test_bench/controls/caller_location.rb +0 -5
  14. data/lib/test_bench/controls/depth.rb +0 -21
  15. data/lib/test_bench/controls/device.rb +0 -27
  16. data/lib/test_bench/controls/directory.rb +0 -15
  17. data/lib/test_bench/controls/error.rb +0 -35
  18. data/lib/test_bench/controls/fixture.rb +0 -29
  19. data/lib/test_bench/controls/output/batch_data.rb +0 -52
  20. data/lib/test_bench/controls/output/detail_setting.rb +0 -29
  21. data/lib/test_bench/controls/output/escape_code.rb +0 -23
  22. data/lib/test_bench/controls/output/exercise.rb +0 -7
  23. data/lib/test_bench/controls/output/log_level.rb +0 -7
  24. data/lib/test_bench/controls/output/newline_character.rb +0 -16
  25. data/lib/test_bench/controls/output/print_error.rb +0 -19
  26. data/lib/test_bench/controls/output/styling.rb +0 -29
  27. data/lib/test_bench/controls/output/summary/error.rb +0 -28
  28. data/lib/test_bench/controls/output/summary/session.rb +0 -20
  29. data/lib/test_bench/controls/pattern.rb +0 -33
  30. data/lib/test_bench/controls/test_file.rb +0 -5
  31. data/lib/test_bench/controls/time.rb +0 -89
  32. data/lib/test_bench/deactivation_variants.rb +0 -11
  33. data/lib/test_bench/environment/boolean.rb +0 -40
  34. data/lib/test_bench/fixtures/configure_receiver.rb +0 -80
  35. data/lib/test_bench/fixtures.rb +0 -5
  36. data/lib/test_bench/output/batch_data.rb +0 -17
  37. data/lib/test_bench/output/buffer.rb +0 -114
  38. data/lib/test_bench/output/log.rb +0 -27
  39. data/lib/test_bench/output/print_error.rb +0 -163
  40. data/lib/test_bench/output/raw.rb +0 -363
  41. data/lib/test_bench/output/summary/session.rb +0 -94
  42. data/lib/test_bench/output/summary.rb +0 -146
  43. data/lib/test_bench/output/timer/substitute.rb +0 -45
  44. data/lib/test_bench/output/timer.rb +0 -75
  45. data/lib/test_bench/output/writer/dependency.rb +0 -12
  46. data/lib/test_bench/output/writer/sgr.rb +0 -54
  47. data/lib/test_bench/output/writer/substitute.rb +0 -38
  48. data/lib/test_bench/output/writer.rb +0 -192
  49. data/lib/test_bench/output.rb +0 -21
  50. data/lib/test_bench/run/substitute.rb +0 -36
  51. data/lib/test_bench/run.rb +0 -113
  52. data/script/bench +0 -19
metadata CHANGED
@@ -1,31 +1,31 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: test_bench
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0.10
4
+ version: 2.0.0.0.pre1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Ladd
8
8
  autorequire:
9
- bindir: script
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-31 00:00:00.000000000 Z
11
+ date: 2023-07-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: test_bench-fixture
14
+ name: test_bench-run
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 1.4.0.0
19
+ version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 1.4.0.0
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: test_bench-bootstrap
28
+ name: test_bench-isolated
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -40,58 +40,19 @@ dependencies:
40
40
  version: '0'
41
41
  description:
42
42
  email: nathanladd+github@gmail.com
43
- executables:
44
- - bench
43
+ executables: []
45
44
  extensions: []
46
45
  extra_rdoc_files: []
47
46
  files:
48
47
  - lib/test_bench.rb
49
48
  - lib/test_bench/cli.rb
50
- - lib/test_bench/cli/parse_arguments.rb
51
49
  - lib/test_bench/controls.rb
52
- - lib/test_bench/controls/caller_location.rb
53
- - lib/test_bench/controls/depth.rb
54
- - lib/test_bench/controls/device.rb
55
- - lib/test_bench/controls/directory.rb
56
- - lib/test_bench/controls/error.rb
57
- - lib/test_bench/controls/fixture.rb
58
- - lib/test_bench/controls/output/batch_data.rb
59
- - lib/test_bench/controls/output/detail_setting.rb
60
- - lib/test_bench/controls/output/escape_code.rb
61
- - lib/test_bench/controls/output/exercise.rb
62
- - lib/test_bench/controls/output/log_level.rb
63
- - lib/test_bench/controls/output/newline_character.rb
64
- - lib/test_bench/controls/output/print_error.rb
65
- - lib/test_bench/controls/output/styling.rb
66
- - lib/test_bench/controls/output/summary/error.rb
67
- - lib/test_bench/controls/output/summary/session.rb
50
+ - lib/test_bench/controls/file.rb
68
51
  - lib/test_bench/controls/path.rb
69
- - lib/test_bench/controls/pattern.rb
52
+ - lib/test_bench/controls/random.rb
70
53
  - lib/test_bench/controls/result.rb
71
- - lib/test_bench/controls/test_file.rb
72
- - lib/test_bench/controls/time.rb
73
- - lib/test_bench/deactivation_variants.rb
74
- - lib/test_bench/environment/boolean.rb
75
- - lib/test_bench/fixtures.rb
76
- - lib/test_bench/fixtures/configure_receiver.rb
77
- - lib/test_bench/output.rb
78
- - lib/test_bench/output/batch_data.rb
79
- - lib/test_bench/output/buffer.rb
80
- - lib/test_bench/output/log.rb
81
- - lib/test_bench/output/print_error.rb
82
- - lib/test_bench/output/raw.rb
83
- - lib/test_bench/output/summary.rb
84
- - lib/test_bench/output/summary/session.rb
85
- - lib/test_bench/output/timer.rb
86
- - lib/test_bench/output/timer/substitute.rb
87
- - lib/test_bench/output/writer.rb
88
- - lib/test_bench/output/writer/dependency.rb
89
- - lib/test_bench/output/writer/sgr.rb
90
- - lib/test_bench/output/writer/substitute.rb
91
- - lib/test_bench/run.rb
92
- - lib/test_bench/run/substitute.rb
54
+ - lib/test_bench/controls/stdin.rb
93
55
  - lib/test_bench/test_bench.rb
94
- - script/bench
95
56
  homepage: https://github.com/test-bench/test-bench
96
57
  licenses:
97
58
  - MIT
@@ -107,12 +68,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
107
68
  version: '0'
108
69
  required_rubygems_version: !ruby/object:Gem::Requirement
109
70
  requirements:
110
- - - ">="
71
+ - - ">"
111
72
  - !ruby/object:Gem::Version
112
- version: '0'
73
+ version: 1.3.1
113
74
  requirements: []
114
75
  rubygems_version: 3.4.10
115
76
  signing_key:
116
77
  specification_version: 4
117
- summary: Principled Test Framework for Ruby and MRuby
78
+ summary: ruby
118
79
  test_files: []
@@ -1,181 +0,0 @@
1
- module TestBench
2
- module CLI
3
- class ParseArguments
4
- Error = Class.new(RuntimeError)
5
-
6
- attr_reader :argv
7
-
8
- def env
9
- @env ||= {}
10
- end
11
- attr_writer :env
12
-
13
- def output_device
14
- @output_device ||= StringIO.new
15
- end
16
- attr_writer :output_device
17
-
18
- def initialize(argv)
19
- @argv = argv
20
- end
21
-
22
- def self.build(argv=nil, env: nil)
23
- argv ||= ::ARGV
24
- env ||= ::ENV
25
-
26
- instance = new(argv)
27
- instance.output_device = Output::Writer::Defaults.device
28
- instance.env = env
29
- instance
30
- end
31
-
32
- def self.call(argv=nil, env: nil)
33
- instance = build(argv, env: env)
34
- instance.()
35
- end
36
-
37
- def call
38
- option_parser.parse(argv)
39
- end
40
-
41
- def option_parser
42
- @option_parser ||= OptionParser.new do |parser|
43
- parser.banner = "Usage: #{self.class.program_name} [options] [paths]"
44
-
45
- parser.separator('')
46
- parser.separator("Informational Options")
47
-
48
- parser.on('-h', '--help', "Print this help message and exit successfully") do
49
- output_device.puts(parser.help)
50
-
51
- raise SystemExit.new(0)
52
- end
53
-
54
- parser.on('-V', '--version', "Print version and exit successfully") do
55
- output_device.puts <<TEXT
56
- test-bench (#{self.class.program_name}) version #{self.class.version}
57
- TEXT
58
-
59
- raise SystemExit.new(0)
60
- end
61
-
62
- parser.separator('')
63
- parser.separator("Configuration Options")
64
-
65
- parser.on('-a', '--[no-]abort-on-error', %{Exit immediately after any test failure or error (Default: #{TestBench::Defaults.abort_on_error ? 'on' : 'off'})}) do |abort_on_error|
66
- env['TEST_BENCH_ABORT_ON_ERROR'] = abort_on_error ? 'on' : 'off'
67
- end
68
-
69
- parser.on('-d', '--[no-]detail', %{Always show (or hide) details (Default: #{Output::Raw::Defaults.detail})}) do |detail|
70
- if detail.nil?
71
- detail = 'on'
72
- elsif detail == true
73
- detail = 'on'
74
- elsif detail == false
75
- detail = 'off'
76
- end
77
-
78
- env['TEST_BENCH_DETAIL'] = detail
79
- end
80
-
81
- parser.on('-x', '--[no-]exclude PATTERN', %{Do not execute test files matching PATTERN (Default: #{Run::Defaults.exclude_pattern.inspect})}) do |pattern_text|
82
- if pattern_text == false
83
- pattern_text = self.none_pattern
84
- end
85
-
86
- assure_pattern(pattern_text)
87
-
88
- env['TEST_BENCH_EXCLUDE_FILE_PATTERN'] = pattern_text
89
- end
90
-
91
- parser.on('-l', '--log-level LEVEL', %{Set the internal logging level to LEVEL (Default: #{Output::Log::Defaults.level})}) do |level_text|
92
- level = level_text.to_sym
93
-
94
- Fixture::Output::Log.assure_level(level)
95
-
96
- env['TEST_BENCH_LOG_LEVEL'] = level_text
97
- end
98
-
99
- parser.on('-o', '--[no-]omit-backtrace PATTERN', %{Omit backtrace frames matching PATTERN (Default: #{Output::PrintError::Defaults.omit_backtrace_pattern.inspect})}) do |pattern_text|
100
- if pattern_text == false
101
- pattern_text = self.none_pattern
102
- end
103
-
104
- assure_pattern(pattern_text)
105
-
106
- env['TEST_BENCH_OMIT_BACKTRACE_PATTERN'] = pattern_text
107
- end
108
-
109
- parser.on('-s', '--output-styling [on|off|detect]', %{Render output coloring and font styling escape codes (Default: #{Output::Writer::Defaults.styling})}) do |styling_text|
110
- styling_text ||= 'on'
111
-
112
- styling = styling_text.to_sym
113
-
114
- Output::Writer.assure_styling_setting(styling)
115
-
116
- env['TEST_BENCH_OUTPUT_STYLING'] = styling_text
117
- end
118
-
119
- parser.on('-p', '--[no-]permit-deactivated-tests', %{Do not fail the test run if there are deactivated tests or contexts, e.g. _test or _context (Default: #{!TestBench::Defaults.fail_deactivated_tests ? 'on' : 'off'})}) do |permit_deactivated_tests|
120
- env['TEST_BENCH_FAIL_DEACTIVATED_TESTS'] = !permit_deactivated_tests ? 'on' : 'off'
121
- end
122
-
123
- parser.on('-r', '--[no-]reverse-backtraces', %{Reverse order of backtraces when printing errors (Default: #{Output::PrintError::Defaults.reverse_backtraces ? 'on' : 'off'})}) do |reverse_backtraces|
124
- env['TEST_BENCH_REVERSE_BACKTRACES'] = reverse_backtraces ? 'on' : 'off'
125
- end
126
-
127
- parser.on('-v', '--[no-]verbose', %{Increase output verbosity (Default: #{Output::Raw::Defaults.verbose ? 'on' : 'off'})}) do |verbose|
128
- env['TEST_BENCH_VERBOSE'] = verbose ? 'on' : 'off'
129
- end
130
-
131
- parser.separator(<<TEXT)
132
-
133
- Paths to test files (and directories containing test files) can be given after any command line arguments or via STDIN (or both).
134
- If no paths are given, a default path (#{Defaults.tests_directory}) is scanned for test files.
135
-
136
- The following environment variables can also control execution:
137
-
138
- #{parser.summary_indent}TEST_BENCH_ABORT_ON_ERROR Same as -a or --abort-on-error
139
- #{parser.summary_indent}TEST_BENCH_DETAIL Same as -d or --detail
140
- #{parser.summary_indent}TEST_BENCH_EXCLUDE_FILE_PATTERN Same as -x or --exclude-file-pattern
141
- #{parser.summary_indent}TEST_BENCH_LOG_LEVEL Same as -l or --log-level
142
- #{parser.summary_indent}TEST_BENCH_OMIT_BACKTRACE_PATTERN Same as -o or --omit-backtrace-pattern
143
- #{parser.summary_indent}TEST_BENCH_OUTPUT_STYLING Same as -s or --output-styling
144
- #{parser.summary_indent}TEST_BENCH_FAIL_DEACTIVATED_TESTS Opposite of -p or --permit-deactivated-tests
145
- #{parser.summary_indent}TEST_BENCH_REVERSE_BACKTRACES Same as -r or --reverse-backtraces
146
- #{parser.summary_indent}TEST_BENCH_VERBOSE Same as -v or --reverse-backtraces
147
-
148
- TEXT
149
- end
150
- end
151
-
152
- def assure_pattern(pattern_text)
153
- Regexp.new(pattern_text.to_s)
154
- rescue RegexpError
155
- raise Error, "Invalid regular expression pattern (Pattern: #{pattern_text.inspect})"
156
- end
157
-
158
- def none_pattern
159
- /\z./
160
- end
161
-
162
- def self.program_name
163
- $PROGRAM_NAME
164
- end
165
-
166
- def self.version
167
- if Object.const_defined?(:Gem)
168
- spec = Gem.loaded_specs['test_bench']
169
- end
170
-
171
- spec&.version || '(unknown)'
172
- end
173
-
174
- module Defaults
175
- def self.tests_directory
176
- ENV.fetch('TEST_BENCH_TESTS_DIRECTORY', 'test/automated')
177
- end
178
- end
179
- end
180
- end
181
- end
@@ -1,5 +0,0 @@
1
- module TestBench
2
- module Controls
3
- CallerLocation = TestBench::Fixture::Controls::CallerLocation
4
- end
5
- end
@@ -1,21 +0,0 @@
1
- module TestBench
2
- module Controls
3
- module Depth
4
- def self.example
5
- Nested.example
6
- end
7
-
8
- module Nested
9
- def self.example
10
- 2
11
- end
12
- end
13
-
14
- module Outermost
15
- def self.example
16
- 0
17
- end
18
- end
19
- end
20
- end
21
- end
@@ -1,27 +0,0 @@
1
- module TestBench
2
- module Controls
3
- module Device
4
- def self.example
5
- Interactive.example
6
- end
7
-
8
- module Interactive
9
- def self.example
10
- device = Non.example
11
-
12
- def device.tty?
13
- true
14
- end
15
-
16
- device
17
- end
18
-
19
- module Non
20
- def self.example
21
- StringIO.new
22
- end
23
- end
24
- end
25
- end
26
- end
27
- end
@@ -1,15 +0,0 @@
1
- module TestBench
2
- module Controls
3
- module Directory
4
- def self.example
5
- Dir.mktmpdir
6
- end
7
-
8
- module NonExistent
9
- def self.example
10
- "/tmp/#{SecureRandom.hex(7)}"
11
- end
12
- end
13
- end
14
- end
15
- end
@@ -1,35 +0,0 @@
1
- module TestBench
2
- module Controls
3
- Error = TestBench::Fixture::Controls::Error
4
-
5
- module Error
6
- module Text
7
- def self.example(message=nil, indentation_depth: nil)
8
- indentation_depth ||= 0
9
-
10
- indent = ' ' * indentation_depth
11
-
12
- error = Error.example(message)
13
-
14
- <<TEXT
15
- #{indent}#{error.backtrace[0]}: #{error.message} (#{error.class.name})
16
- \t#{indent}from #{error.backtrace[1]}
17
- \t#{indent}from #{error.backtrace[2]}
18
- TEXT
19
- end
20
-
21
- module Assertion
22
- def self.example(caller_location: nil)
23
- caller_location ||= CallerLocation.example
24
-
25
- assertion_failure = TestBench::Fixture::AssertionFailure.build(caller_location)
26
-
27
- <<TEXT
28
- #{assertion_failure.backtrace[0]}: #{assertion_failure.message} (#{assertion_failure.class.name})
29
- TEXT
30
- end
31
- end
32
- end
33
- end
34
- end
35
- end
@@ -1,29 +0,0 @@
1
- module TestBench
2
- module Controls
3
- module Fixture
4
- def self.example(output=nil, error_policy: nil)
5
- error_policy ||= self.error_policy
6
-
7
- fixture = Example.new
8
-
9
- TestBench::Fixture::ErrorPolicy.configure(fixture.test_session, policy: error_policy)
10
-
11
- unless output.nil?
12
- fixture.test_session.output = output
13
- end
14
-
15
- fixture
16
- end
17
-
18
- def self.example_class(&block)
19
- TestBench::Fixture::Controls::Fixture.example_class(&block)
20
- end
21
-
22
- def self.error_policy
23
- :rescue
24
- end
25
-
26
- Example = example_class
27
- end
28
- end
29
- end
@@ -1,52 +0,0 @@
1
- module TestBench
2
- module Controls
3
- module Output
4
- module BatchData
5
- def self.example(result: nil, depth: nil)
6
- result = self.result if result.nil?
7
- depth ||= self.depth
8
-
9
- TestBench::Output::BatchData.new(result, depth)
10
- end
11
-
12
- def self.result
13
- Pass.result
14
- end
15
-
16
- def self.depth
17
- 1
18
- end
19
-
20
- module Pass
21
- def self.example(depth: nil)
22
- BatchData.example(result: result, depth: depth)
23
- end
24
-
25
- def self.result
26
- Result::Pass.example
27
- end
28
- end
29
-
30
- module Failure
31
- def self.example(depth: nil)
32
- BatchData.example(result: result, depth: depth)
33
- end
34
-
35
- def self.result
36
- Result::Failure.example
37
- end
38
- end
39
-
40
- module Toplevel
41
- def self.example(result: nil)
42
- BatchData.example(depth: depth, result: result)
43
- end
44
-
45
- def self.depth
46
- 0
47
- end
48
- end
49
- end
50
- end
51
- end
52
- end
@@ -1,29 +0,0 @@
1
- module TestBench
2
- module Controls
3
- module Output
4
- module DetailSetting
5
- def self.example
6
- failure
7
- end
8
-
9
- def self.failure
10
- :failure
11
- end
12
-
13
- def self.on
14
- :on
15
- end
16
-
17
- def self.off
18
- :off
19
- end
20
-
21
- module Invalid
22
- def self.example
23
- :not_a_detail_setting
24
- end
25
- end
26
- end
27
- end
28
- end
29
- end
@@ -1,23 +0,0 @@
1
- module TestBench
2
- module Controls
3
- module Output
4
- module EscapeCode
5
- def self.example
6
- '1'
7
- end
8
-
9
- module ID
10
- def self.example
11
- :bold
12
- end
13
-
14
- module Unknown
15
- def self.example
16
- :unknown
17
- end
18
- end
19
- end
20
- end
21
- end
22
- end
23
- end
@@ -1,7 +0,0 @@
1
- module TestBench
2
- module Controls
3
- module Output
4
- Exercise = TestBench::Fixture::Controls::Output::Exercise
5
- end
6
- end
7
- end
@@ -1,7 +0,0 @@
1
- module TestBench
2
- module Controls
3
- module Output
4
- LogLevel = TestBench::Fixture::Controls::Output::Log::Level
5
- end
6
- end
7
- end
@@ -1,16 +0,0 @@
1
- module TestBench
2
- module Controls
3
- module Output
4
- module NewlineCharacter
5
- def self.example
6
- str = String.new
7
-
8
- string_io = StringIO.new(str)
9
- string_io.puts('')
10
-
11
- str
12
- end
13
- end
14
- end
15
- end
16
- end
@@ -1,19 +0,0 @@
1
- module TestBench
2
- module Controls
3
- module Output
4
- module PrintError
5
- def self.example(omit_backtrace_pattern: nil, reverse_backtraces: nil, writer: nil)
6
- print_error = Example.new
7
- print_error.omit_backtrace_pattern = omit_backtrace_pattern unless omit_backtrace_pattern.nil?
8
- print_error.reverse_backtraces = reverse_backtraces unless reverse_backtraces.nil?
9
- print_error.writer = writer unless writer.nil?
10
- print_error
11
- end
12
-
13
- class Example
14
- include TestBench::Output::PrintError
15
- end
16
- end
17
- end
18
- end
19
- end
@@ -1,29 +0,0 @@
1
- module TestBench
2
- module Controls
3
- module Output
4
- module Styling
5
- def self.example
6
- detect
7
- end
8
-
9
- def self.detect
10
- :detect
11
- end
12
-
13
- def self.on
14
- :on
15
- end
16
-
17
- def self.off
18
- :off
19
- end
20
-
21
- module Invalid
22
- def self.example
23
- :not_a_styling_setting
24
- end
25
- end
26
- end
27
- end
28
- end
29
- end
@@ -1,28 +0,0 @@
1
- module TestBench
2
- module Controls
3
- module Output
4
- module Summary
5
- module Error
6
- module Text
7
- def self.example
8
- <<TEXT
9
- Error Summary:
10
- 1: #{file}
11
- #{error.backtrace[0]}: #{error} (#{error.class})
12
-
13
- TEXT
14
- end
15
-
16
- def self.file
17
- TestFile.filename
18
- end
19
-
20
- def self.error
21
- Controls::Error.example
22
- end
23
- end
24
- end
25
- end
26
- end
27
- end
28
- end
@@ -1,20 +0,0 @@
1
- module TestBench
2
- module Controls
3
- module Output
4
- module Summary
5
- module Session
6
- module Text
7
- def self.example
8
- <<TEXT
9
- Finished running 0 files
10
- Ran 0 tests in 0.000s (0.0 tests/second)
11
- 0 passed, 0 skipped, 0 failed, 0 total errors
12
-
13
- TEXT
14
- end
15
- end
16
- end
17
- end
18
- end
19
- end
20
- end