test_bench 1.0.0.0 → 1.2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/test_bench.rb +9 -9
- data/lib/test_bench/cli.rb +2 -2
- data/lib/test_bench/cli/parse_arguments.rb +33 -20
- data/lib/test_bench/controls.rb +5 -1
- 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/summary/error.rb +0 -16
- 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 +18 -0
- data/lib/test_bench/deactivation_variants.rb +0 -10
- 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 +112 -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/writer.rb +2 -2
- data/lib/test_bench/run.rb +9 -9
- data/lib/test_bench/test_bench.rb +31 -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 -274
- 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: afaeab0cc192ef871046e2b2080e87f9ae413a0da8a55e2893e240f76369c87e
|
4
|
+
data.tar.gz: 9cca5db44320b3956cbb8754251703087024411d274e608a2d731ce6c7a2729d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80da06a441f1f3a547a62ee37fbf36f1d6c1c9541bd240c82fc94d7d380da1f6ddf717d6a626c5f50161488dfe4178057e14c59183ad751660bf8627fc322db4
|
7
|
+
data.tar.gz: 42d0355bb4f6c81a1819da5cfffa1fd41ece43b1f1a2e14600e5f52a9ef53f11a10309c792862bef9557bfe62a5e44a644883dda4b427b362fd813f8c2361c0b
|
data/lib/test_bench.rb
CHANGED
@@ -14,17 +14,17 @@ require 'test_bench/output/timer/substitute'
|
|
14
14
|
|
15
15
|
require 'test_bench/output/print_error'
|
16
16
|
|
17
|
-
require 'test_bench/output/summary
|
18
|
-
require 'test_bench/output/summary/
|
19
|
-
require 'test_bench/output/summary/error'
|
17
|
+
require 'test_bench/output/summary'
|
18
|
+
require 'test_bench/output/summary/session'
|
20
19
|
|
21
|
-
require 'test_bench/output/
|
22
|
-
|
23
|
-
require 'test_bench/output/
|
24
|
-
|
25
|
-
require 'test_bench/output/
|
20
|
+
require 'test_bench/output/batch_data'
|
21
|
+
|
22
|
+
require 'test_bench/output/raw'
|
23
|
+
|
24
|
+
require 'test_bench/output/buffer'
|
25
|
+
|
26
|
+
require 'test_bench/output/log'
|
26
27
|
|
27
|
-
require 'test_bench/output/build'
|
28
28
|
require 'test_bench/output'
|
29
29
|
|
30
30
|
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
|
@@ -62,11 +62,23 @@ module TestBench
|
|
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,6 +124,10 @@ module TestBench
|
|
112
124
|
env['TEST_BENCH_REVERSE_BACKTRACES'] = reverse_backtraces ? 'on' : 'off'
|
113
125
|
end
|
114
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
|
+
|
115
131
|
parser.separator(<<~TEXT)
|
116
132
|
|
117
133
|
Paths to test files (and directories containing test files) can be given after any command line arguments or via STDIN (or both).
|
@@ -120,17 +136,14 @@ module TestBench
|
|
120
136
|
The following environment variables can also control execution:
|
121
137
|
|
122
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
|
123
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
|
124
142
|
#{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
143
|
#{parser.summary_indent}TEST_BENCH_OUTPUT_STYLING Same as -s or --output-styling
|
127
144
|
#{parser.summary_indent}TEST_BENCH_FAIL_DEACTIVATED_TESTS Opposite of -p or --permit-deactivated-tests
|
128
145
|
#{parser.summary_indent}TEST_BENCH_REVERSE_BACKTRACES Same as -r or --reverse-backtraces
|
129
|
-
|
130
|
-
TEXT
|
131
|
-
|
132
|
-
parser.separator(<<~TEXT)
|
133
|
-
Finally, the VERBOSE environment variable can set the output level to debug. If given, VERBOSE will take precedence over TEST_BENCH_OUTPUT_STYLING.
|
146
|
+
#{parser.summary_indent}TEST_BENCH_VERBOSE Same as -v or --reverse-backtraces
|
134
147
|
|
135
148
|
TEXT
|
136
149
|
end
|
data/lib/test_bench/controls.rb
CHANGED
@@ -18,5 +18,9 @@ require 'test_bench/controls/output/escape_code'
|
|
18
18
|
require 'test_bench/controls/output/newline_character'
|
19
19
|
require 'test_bench/controls/output/styling'
|
20
20
|
require 'test_bench/controls/output/print_error'
|
21
|
-
require 'test_bench/controls/output/
|
21
|
+
require 'test_bench/controls/output/exercise'
|
22
|
+
require 'test_bench/controls/output/summary/session'
|
22
23
|
require 'test_bench/controls/output/summary/error'
|
24
|
+
require 'test_bench/controls/output/batch_data'
|
25
|
+
require 'test_bench/controls/output/detail_setting'
|
26
|
+
require 'test_bench/controls/output/log_level'
|
@@ -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,22 +3,6 @@ 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
8
|
<<~TEXT
|
@@ -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
|
@@ -55,6 +55,24 @@ module TestBench
|
|
55
55
|
"1.111s"
|
56
56
|
end
|
57
57
|
end
|
58
|
+
|
59
|
+
module PerSecond
|
60
|
+
def self.example
|
61
|
+
elapsed_time = Elapsed.example
|
62
|
+
|
63
|
+
Rational(ocurrences, elapsed_time)
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.ocurrences
|
67
|
+
1
|
68
|
+
end
|
69
|
+
|
70
|
+
module Text
|
71
|
+
def self.example
|
72
|
+
"0.9"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
58
76
|
end
|
59
77
|
end
|
60
78
|
end
|
@@ -1,21 +1,11 @@
|
|
1
1
|
module TestBench
|
2
2
|
module DeactivationVariants
|
3
3
|
def _context(title=nil, &block)
|
4
|
-
test_session.fail! if Defaults.fail_session
|
5
|
-
|
6
4
|
context(title)
|
7
5
|
end
|
8
6
|
|
9
7
|
def _test(title=nil, &block)
|
10
|
-
test_session.fail! if Defaults.fail_session
|
11
|
-
|
12
8
|
test(title)
|
13
9
|
end
|
14
|
-
|
15
|
-
module Defaults
|
16
|
-
def self.fail_session
|
17
|
-
Environment::Boolean.fetch('TEST_BENCH_FAIL_DEACTIVATED_TESTS', true)
|
18
|
-
end
|
19
|
-
end
|
20
10
|
end
|
21
11
|
end
|
data/lib/test_bench/output.rb
CHANGED
@@ -1,7 +1,19 @@
|
|
1
1
|
module TestBench
|
2
2
|
module Output
|
3
|
-
def self.build(**
|
4
|
-
|
3
|
+
def self.build(log_level: nil, writer: nil, device: nil, styling: nil, **buffer_output_args)
|
4
|
+
summary = Summary.build(writer: writer, device: device, styling: styling)
|
5
|
+
|
6
|
+
log_output = Log.build(level: log_level)
|
7
|
+
|
8
|
+
writer = summary.writer
|
9
|
+
|
10
|
+
buffer_output = Buffer.build(writer: writer, **buffer_output_args)
|
11
|
+
|
12
|
+
Fixture::Output::Multiple.build(
|
13
|
+
log_output,
|
14
|
+
buffer_output,
|
15
|
+
summary
|
16
|
+
)
|
5
17
|
end
|
6
18
|
|
7
19
|
Substitute = Fixture::Output::Substitute
|
@@ -0,0 +1,112 @@
|
|
1
|
+
module TestBench
|
2
|
+
module Output
|
3
|
+
class Buffer < Fixture::Output::Capture
|
4
|
+
attr_accessor :writer
|
5
|
+
|
6
|
+
def raw_output
|
7
|
+
@raw_output ||= Raw.new
|
8
|
+
end
|
9
|
+
attr_writer :raw_output
|
10
|
+
|
11
|
+
def stack
|
12
|
+
@stack ||= []
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.build(verbose: nil, detail: nil, omit_backtrace_pattern: nil, reverse_backtraces: nil, writer: nil, device: nil, styling: nil)
|
16
|
+
instance = new
|
17
|
+
|
18
|
+
raw_output = Raw.configure(instance, verbose: verbose, detail: detail, omit_backtrace_pattern: omit_backtrace_pattern, reverse_backtraces: reverse_backtraces, writer: writer, device: device, styling: styling)
|
19
|
+
|
20
|
+
instance.writer = raw_output.writer
|
21
|
+
|
22
|
+
instance
|
23
|
+
end
|
24
|
+
|
25
|
+
def exit_context(*)
|
26
|
+
super
|
27
|
+
|
28
|
+
flush unless buffering?
|
29
|
+
end
|
30
|
+
|
31
|
+
def finish_test(*)
|
32
|
+
super
|
33
|
+
|
34
|
+
flush unless buffering?
|
35
|
+
end
|
36
|
+
|
37
|
+
def finish_fixture(*)
|
38
|
+
super
|
39
|
+
|
40
|
+
flush unless buffering?
|
41
|
+
end
|
42
|
+
|
43
|
+
def new_record(signal, data)
|
44
|
+
record = Record.new(signal, data)
|
45
|
+
|
46
|
+
case signal
|
47
|
+
when :enter_context, :start_test, :start_fixture
|
48
|
+
start_batch(record)
|
49
|
+
|
50
|
+
when :exit_context, :finish_test, :finish_fixture
|
51
|
+
result = record.data.last
|
52
|
+
|
53
|
+
finish_batch(record, result)
|
54
|
+
end
|
55
|
+
|
56
|
+
record
|
57
|
+
end
|
58
|
+
|
59
|
+
def start_batch(record)
|
60
|
+
record.start_batch(stack_depth)
|
61
|
+
|
62
|
+
stack.push(record)
|
63
|
+
end
|
64
|
+
|
65
|
+
def finish_batch(final_record, result)
|
66
|
+
first_record = stack.pop
|
67
|
+
|
68
|
+
batch_data = first_record.batch_data
|
69
|
+
batch_data.result = result
|
70
|
+
|
71
|
+
final_record.batch_data = first_record.batch_data
|
72
|
+
end
|
73
|
+
|
74
|
+
def flush
|
75
|
+
records.each do |record|
|
76
|
+
record.forward(raw_output)
|
77
|
+
end
|
78
|
+
|
79
|
+
records.clear
|
80
|
+
end
|
81
|
+
|
82
|
+
def buffering?
|
83
|
+
stack_depth.nonzero?
|
84
|
+
end
|
85
|
+
|
86
|
+
def stack_depth
|
87
|
+
stack.length
|
88
|
+
end
|
89
|
+
|
90
|
+
class Record < Fixture::Output::Capture::Record
|
91
|
+
attr_accessor :batch_data
|
92
|
+
|
93
|
+
def forward(raw_output)
|
94
|
+
return super if batch_data.nil?
|
95
|
+
|
96
|
+
raw_output.public_send(signal, *data, batch_data: batch_data)
|
97
|
+
end
|
98
|
+
|
99
|
+
def start_batch(depth)
|
100
|
+
batch_data = Output::BatchData.new
|
101
|
+
batch_data.depth = depth
|
102
|
+
|
103
|
+
self.batch_data = batch_data
|
104
|
+
end
|
105
|
+
|
106
|
+
def finish_batch(result)
|
107
|
+
batch_data.result = result
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|