test_bench 1.0.1.0 → 1.2.0.2
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/lib/test_bench.rb +12 -10
- data/lib/test_bench/cli.rb +2 -2
- data/lib/test_bench/cli/parse_arguments.rb +50 -37
- data/lib/test_bench/controls.rb +8 -2
- data/lib/test_bench/controls/error.rb +8 -8
- data/lib/test_bench/controls/output/batch_data.rb +52 -0
- data/lib/test_bench/controls/output/detail_setting.rb +29 -0
- data/lib/test_bench/controls/output/exercise.rb +7 -0
- data/lib/test_bench/controls/output/log_level.rb +7 -0
- data/lib/test_bench/controls/output/newline_character.rb +6 -1
- data/lib/test_bench/controls/output/summary/error.rb +5 -21
- data/lib/test_bench/controls/output/summary/session.rb +20 -0
- data/lib/test_bench/controls/pattern.rb +6 -2
- data/lib/test_bench/controls/time.rb +30 -2
- data/lib/test_bench/deactivation_variants.rb +0 -10
- data/lib/test_bench/fixtures.rb +3 -1
- data/lib/test_bench/output.rb +14 -2
- data/lib/test_bench/output/batch_data.rb +17 -0
- data/lib/test_bench/output/buffer.rb +114 -0
- data/lib/test_bench/output/log.rb +27 -0
- data/lib/test_bench/output/raw.rb +353 -0
- data/lib/test_bench/output/summary.rb +146 -0
- data/lib/test_bench/output/summary/session.rb +94 -0
- data/lib/test_bench/output/timer/substitute.rb +1 -1
- data/lib/test_bench/output/writer.rb +3 -3
- data/lib/test_bench/run.rb +9 -9
- data/lib/test_bench/test_bench.rb +23 -3
- metadata +18 -17
- data/lib/test_bench/controls/output/summary/run.rb +0 -59
- data/lib/test_bench/output/build.rb +0 -57
- data/lib/test_bench/output/levels/debug.rb +0 -229
- data/lib/test_bench/output/levels/failure.rb +0 -31
- data/lib/test_bench/output/levels/none.rb +0 -13
- data/lib/test_bench/output/levels/pass.rb +0 -286
- data/lib/test_bench/output/levels/summary.rb +0 -21
- data/lib/test_bench/output/summary/error.rb +0 -77
- data/lib/test_bench/output/summary/run.rb +0 -102
- data/lib/test_bench/output/summary/run/print.rb +0 -98
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3b488668e7e9d65b4a0ec2adbabb94b9a1cf8e4a29d9e4b1c90b5b3c867fd59
|
4
|
+
data.tar.gz: 9d4034e73a32b4d694197a1f3ee6a89c9c7843288cdf23934e9aeea4e4136ce8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b49bf38f0ed60504849c6e726fdcbf372d8700b459b1357d967ea472ae76f9ce0ff06c2eef60f0ce438843e5a540c431c80ab9ecc44f6a2f4de18179056e3b0
|
7
|
+
data.tar.gz: 770d4bf06d1048be6d031a11ce2040f16275296d731f01052dac9ded7632c587424b7af317c94c3b55acbcc1988e9ff93045724fb88c3307aa2614504bc09f8d
|
data/lib/test_bench.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
unless RUBY_ENGINE == 'mruby'
|
2
|
+
require 'optionparser'
|
3
|
+
end
|
2
4
|
|
3
5
|
require 'test_bench/fixture'
|
4
6
|
|
@@ -14,17 +16,17 @@ require 'test_bench/output/timer/substitute'
|
|
14
16
|
|
15
17
|
require 'test_bench/output/print_error'
|
16
18
|
|
17
|
-
require 'test_bench/output/summary
|
18
|
-
require 'test_bench/output/summary/
|
19
|
-
require 'test_bench/output/summary/error'
|
19
|
+
require 'test_bench/output/summary'
|
20
|
+
require 'test_bench/output/summary/session'
|
20
21
|
|
21
|
-
require 'test_bench/output/
|
22
|
-
|
23
|
-
require 'test_bench/output/
|
24
|
-
|
25
|
-
require 'test_bench/output/
|
22
|
+
require 'test_bench/output/batch_data'
|
23
|
+
|
24
|
+
require 'test_bench/output/raw'
|
25
|
+
|
26
|
+
require 'test_bench/output/buffer'
|
27
|
+
|
28
|
+
require 'test_bench/output/log'
|
26
29
|
|
27
|
-
require 'test_bench/output/build'
|
28
30
|
require 'test_bench/output'
|
29
31
|
|
30
32
|
require 'test_bench/test_bench'
|
data/lib/test_bench/cli.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module TestBench
|
2
2
|
module CLI
|
3
|
-
def self.call(tests_directory=nil,
|
3
|
+
def self.call(tests_directory=nil, exclude_file_pattern: nil)
|
4
4
|
tests_directory ||= Defaults.tests_directory
|
5
5
|
|
6
6
|
path_arguments = ParseArguments.()
|
@@ -11,7 +11,7 @@ module TestBench
|
|
11
11
|
warn "$stdin is a pipe, but no data was written to it; no test files will be run"
|
12
12
|
end
|
13
13
|
|
14
|
-
Run.(
|
14
|
+
Run.(exclude: exclude_file_pattern) do |run|
|
15
15
|
if read_stdin
|
16
16
|
until $stdin.eof?
|
17
17
|
path = $stdin.gets.chomp
|
@@ -48,25 +48,37 @@ module TestBench
|
|
48
48
|
parser.on('-h', '--help', "Print this help message and exit successfully") do
|
49
49
|
output_device.puts(parser.help)
|
50
50
|
|
51
|
-
|
51
|
+
raise SystemExit.new(0)
|
52
52
|
end
|
53
53
|
|
54
54
|
parser.on('-V', '--version', "Print version and exit successfully") do
|
55
|
-
output_device.puts
|
56
|
-
|
57
|
-
|
55
|
+
output_device.puts <<TEXT
|
56
|
+
test-bench (#{self.class.program_name}) version #{self.class.version}
|
57
|
+
TEXT
|
58
58
|
|
59
|
-
|
59
|
+
raise SystemExit.new(0)
|
60
60
|
end
|
61
61
|
|
62
62
|
parser.separator('')
|
63
63
|
parser.separator("Configuration Options")
|
64
64
|
|
65
|
-
parser.on('-a', '--[no-]abort-on-error', %{Exit immediately after any test failure or error (Default: #{
|
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
66
|
env['TEST_BENCH_ABORT_ON_ERROR'] = abort_on_error ? 'on' : 'off'
|
67
67
|
end
|
68
68
|
|
69
|
-
parser.on('-
|
69
|
+
parser.on('-d', '--[no-]detail [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|
|
70
82
|
if pattern_text == false
|
71
83
|
pattern_text = self.none_pattern
|
72
84
|
end
|
@@ -76,6 +88,14 @@ module TestBench
|
|
76
88
|
env['TEST_BENCH_EXCLUDE_FILE_PATTERN'] = pattern_text
|
77
89
|
end
|
78
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
|
+
|
79
99
|
parser.on('-o', '--[no-]omit-backtrace PATTERN', %{Omit backtrace frames matching PATTERN (Default: #{Output::PrintError::Defaults.omit_backtrace_pattern.inspect})}) do |pattern_text|
|
80
100
|
if pattern_text == false
|
81
101
|
pattern_text = self.none_pattern
|
@@ -86,25 +106,17 @@ module TestBench
|
|
86
106
|
env['TEST_BENCH_OMIT_BACKTRACE_PATTERN'] = pattern_text
|
87
107
|
end
|
88
108
|
|
89
|
-
parser.on('-
|
90
|
-
level = level_text.to_sym
|
91
|
-
|
92
|
-
Output::Build.assure_level(level)
|
93
|
-
|
94
|
-
env['TEST_BENCH_OUTPUT_LEVEL'] = level_text
|
95
|
-
end
|
96
|
-
|
97
|
-
parser.on('-s', '--output-styling [on|off|detect]', %{Render output coloring and font styling escape codes (Default: #{Output::Writer::Defaults.styling_setting})}) do |styling_text|
|
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|
|
98
110
|
styling_text ||= 'on'
|
99
111
|
|
100
|
-
|
112
|
+
styling = styling_text.to_sym
|
101
113
|
|
102
|
-
Output::Writer.assure_styling_setting(
|
114
|
+
Output::Writer.assure_styling_setting(styling)
|
103
115
|
|
104
116
|
env['TEST_BENCH_OUTPUT_STYLING'] = styling_text
|
105
117
|
end
|
106
118
|
|
107
|
-
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: #{!
|
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|
|
108
120
|
env['TEST_BENCH_FAIL_DEACTIVATED_TESTS'] = !permit_deactivated_tests ? 'on' : 'off'
|
109
121
|
end
|
110
122
|
|
@@ -112,32 +124,33 @@ module TestBench
|
|
112
124
|
env['TEST_BENCH_REVERSE_BACKTRACES'] = reverse_backtraces ? 'on' : 'off'
|
113
125
|
end
|
114
126
|
|
115
|
-
parser.
|
116
|
-
|
117
|
-
|
118
|
-
If no paths are given, a default path (#{Defaults.tests_directory}) is scanned for test files.
|
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
|
119
130
|
|
120
|
-
|
131
|
+
parser.separator(<<TEXT)
|
121
132
|
|
122
|
-
|
123
|
-
|
124
|
-
#{parser.summary_indent}TEST_BENCH_OMIT_BACKTRACE_PATTERN Same as -o or --omit-backtrace-pattern
|
125
|
-
#{parser.summary_indent}TEST_BENCH_OUTPUT_LEVEL Same as -l or --output-level
|
126
|
-
#{parser.summary_indent}TEST_BENCH_OUTPUT_STYLING Same as -s or --output-styling
|
127
|
-
#{parser.summary_indent}TEST_BENCH_FAIL_DEACTIVATED_TESTS Opposite of -p or --permit-deactivated-tests
|
128
|
-
#{parser.summary_indent}TEST_BENCH_REVERSE_BACKTRACES Same as -r or --reverse-backtraces
|
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.
|
129
135
|
|
130
|
-
|
136
|
+
The following environment variables can also control execution:
|
131
137
|
|
132
|
-
|
133
|
-
|
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
|
134
147
|
|
135
|
-
|
148
|
+
TEXT
|
136
149
|
end
|
137
150
|
end
|
138
151
|
|
139
152
|
def assure_pattern(pattern_text)
|
140
|
-
Regexp.new(pattern_text)
|
153
|
+
Regexp.new(pattern_text.to_s)
|
141
154
|
rescue RegexpError
|
142
155
|
raise Error, "Invalid regular expression pattern (Pattern: #{pattern_text.inspect})"
|
143
156
|
end
|
@@ -151,7 +164,7 @@ module TestBench
|
|
151
164
|
end
|
152
165
|
|
153
166
|
def self.version
|
154
|
-
if
|
167
|
+
if Object.const_defined?(:Gem)
|
155
168
|
spec = Gem.loaded_specs['test_bench']
|
156
169
|
end
|
157
170
|
|
data/lib/test_bench/controls.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
unless RUBY_ENGINE == 'mruby'
|
2
|
+
require 'securerandom'
|
3
|
+
end
|
2
4
|
|
3
5
|
require 'test_bench/fixture/controls'
|
4
6
|
|
@@ -18,5 +20,9 @@ require 'test_bench/controls/output/escape_code'
|
|
18
20
|
require 'test_bench/controls/output/newline_character'
|
19
21
|
require 'test_bench/controls/output/styling'
|
20
22
|
require 'test_bench/controls/output/print_error'
|
21
|
-
require 'test_bench/controls/output/
|
23
|
+
require 'test_bench/controls/output/exercise'
|
24
|
+
require 'test_bench/controls/output/summary/session'
|
22
25
|
require 'test_bench/controls/output/summary/error'
|
26
|
+
require 'test_bench/controls/output/batch_data'
|
27
|
+
require 'test_bench/controls/output/detail_setting'
|
28
|
+
require 'test_bench/controls/output/log_level'
|
@@ -11,11 +11,11 @@ module TestBench
|
|
11
11
|
|
12
12
|
error = Error.example(message)
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
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
19
|
end
|
20
20
|
|
21
21
|
module Assertion
|
@@ -24,9 +24,9 @@ module TestBench
|
|
24
24
|
|
25
25
|
assertion_failure = TestBench::Fixture::AssertionFailure.build(caller_location)
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
27
|
+
<<TEXT
|
28
|
+
#{assertion_failure.backtrace[0]}: #{assertion_failure.message} (#{assertion_failure.class.name})
|
29
|
+
TEXT
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
@@ -0,0 +1,52 @@
|
|
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
|
@@ -0,0 +1,29 @@
|
|
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
|
@@ -3,30 +3,14 @@ module TestBench
|
|
3
3
|
module Output
|
4
4
|
module Summary
|
5
5
|
module Error
|
6
|
-
def self.example(writer: nil)
|
7
|
-
error_summary = Example.new
|
8
|
-
error_summary.writer = writer unless writer.nil?
|
9
|
-
error_summary
|
10
|
-
end
|
11
|
-
|
12
|
-
class Example
|
13
|
-
include TestBench::Fixture::Output
|
14
|
-
include TestBench::Output::Summary::Error
|
15
|
-
|
16
|
-
TestBench::Fixture::Output.instance_methods.each do |method|
|
17
|
-
define_method(method) do |*|
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
6
|
module Text
|
23
7
|
def self.example
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
8
|
+
<<TEXT
|
9
|
+
Error Summary:
|
10
|
+
1: #{file}
|
11
|
+
#{error.backtrace[0]}: #{error} (#{error.class})
|
28
12
|
|
29
|
-
|
13
|
+
TEXT
|
30
14
|
end
|
31
15
|
|
32
16
|
def self.file
|
@@ -0,0 +1,20 @@
|
|
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
|