test_bench-run 2.1.3.1 → 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 +4 -4
- data/lib/test_bench/run/controls/{result.rb → events.rb} +1 -1
- data/lib/test_bench/run/controls/{process_id.rb → message.rb} +1 -1
- data/lib/test_bench/run/controls/path.rb +1 -9
- data/lib/test_bench/run/controls/random.rb +1 -1
- data/lib/test_bench/run/controls/session.rb +14 -0
- data/lib/test_bench/run/controls/status.rb +42 -0
- data/lib/test_bench/run/controls/summary/file/info.rb +106 -0
- data/lib/test_bench/run/controls/summary/file/totals.rb +36 -0
- data/lib/test_bench/run/controls/summary/file.rb +42 -0
- data/lib/test_bench/run/controls/summary/run.rb +51 -0
- data/lib/test_bench/run/controls/summary.rb +43 -0
- data/lib/test_bench/run/controls/{events/session.rb → telemetry.rb} +2 -2
- data/lib/test_bench/run/controls/time.rb +1 -1
- data/lib/test_bench/run/controls.rb +14 -20
- data/lib/test_bench/run/run.rb +78 -90
- data/lib/test_bench/run/{get_files → select_files}/substitute.rb +11 -14
- data/lib/test_bench/run/select_files.rb +68 -0
- data/lib/test_bench/run/substitute.rb +40 -0
- data/lib/test_bench/run/summary/substitute.rb +17 -0
- data/lib/test_bench/run/summary.rb +475 -0
- data/lib/test_bench/run.rb +6 -14
- metadata +32 -45
- data/lib/test_bench/run/controls/directory.rb +0 -70
- data/lib/test_bench/run/controls/event_data.rb +0 -7
- data/lib/test_bench/run/controls/events/event_data.rb +0 -9
- data/lib/test_bench/run/controls/events/file_crashed.rb +0 -109
- data/lib/test_bench/run/controls/events/file_finished.rb +0 -56
- data/lib/test_bench/run/controls/events/file_started.rb +0 -47
- data/lib/test_bench/run/controls/events/finished.rb +0 -56
- data/lib/test_bench/run/controls/events/started.rb +0 -47
- data/lib/test_bench/run/controls/exception.rb +0 -101
- data/lib/test_bench/run/controls/executor.rb +0 -56
- data/lib/test_bench/run/controls/file/create.rb +0 -69
- data/lib/test_bench/run/controls/file/pattern.rb +0 -33
- data/lib/test_bench/run/controls/file.rb +0 -180
- data/lib/test_bench/run/events.rb +0 -12
- data/lib/test_bench/run/executor/serial.rb +0 -34
- data/lib/test_bench/run/executor/substitute.rb +0 -45
- data/lib/test_bench/run/executor.rb +0 -44
- data/lib/test_bench/run/file.rb +0 -81
- data/lib/test_bench/run/get_files.rb +0 -76
- data/lib/test_bench/run/output/file.rb +0 -135
- data/lib/test_bench/run/output/summary/error.rb +0 -139
- data/lib/test_bench/run/output/summary.rb +0 -182
data/lib/test_bench/run/run.rb
CHANGED
@@ -1,127 +1,125 @@
|
|
1
1
|
module TestBench
|
2
2
|
class Run
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
def summary
|
4
|
+
@summary ||= Summary::Substitute.build
|
5
|
+
end
|
6
|
+
attr_writer :summary
|
6
7
|
|
7
|
-
def
|
8
|
-
@
|
8
|
+
def select_files
|
9
|
+
@select_files ||= SelectFiles::Substitute.build
|
9
10
|
end
|
10
|
-
attr_writer :
|
11
|
+
attr_writer :select_files
|
11
12
|
|
12
13
|
def session
|
13
14
|
@session ||= Session::Substitute.build
|
14
15
|
end
|
15
16
|
attr_writer :session
|
16
17
|
|
17
|
-
def
|
18
|
-
@
|
18
|
+
def print_summary
|
19
|
+
@print_summary.nil? ?
|
20
|
+
@print_summary = true :
|
21
|
+
@print_summary
|
19
22
|
end
|
20
|
-
attr_writer :
|
23
|
+
attr_writer :print_summary
|
24
|
+
alias :print_summary? :print_summary
|
21
25
|
|
22
|
-
def
|
23
|
-
@
|
26
|
+
def abort_on_failure
|
27
|
+
@abort_on_failure.nil? ?
|
28
|
+
@abort_on_failure = false :
|
29
|
+
@abort_on_failure
|
24
30
|
end
|
25
|
-
attr_writer :
|
26
|
-
|
27
|
-
def random
|
28
|
-
@random ||= Random::Substitute.build
|
29
|
-
end
|
30
|
-
attr_writer :random
|
31
|
+
attr_writer :abort_on_failure
|
32
|
+
alias :abort_on_failure? :abort_on_failure
|
31
33
|
|
32
34
|
def path_sequence
|
33
35
|
@path_sequence ||= 0
|
34
36
|
end
|
35
37
|
attr_writer :path_sequence
|
36
38
|
|
37
|
-
def self.build(exclude: nil, session: nil)
|
39
|
+
def self.build(exclude: nil, print_summary: nil, abort_on_failure: nil, session: nil)
|
40
|
+
if print_summary.nil?
|
41
|
+
print_summary = Defaults.print_summary
|
42
|
+
end
|
43
|
+
|
44
|
+
if abort_on_failure.nil?
|
45
|
+
abort_on_failure = Defaults.abort_on_failure
|
46
|
+
end
|
47
|
+
|
38
48
|
instance = new
|
39
49
|
|
40
|
-
|
50
|
+
instance.print_summary = print_summary
|
51
|
+
instance.abort_on_failure = abort_on_failure
|
52
|
+
|
53
|
+
Session.configure(instance, session:)
|
41
54
|
|
42
|
-
|
55
|
+
Summary.configure(instance)
|
43
56
|
|
44
|
-
|
57
|
+
SelectFiles.configure(instance, exclude_patterns: exclude)
|
45
58
|
|
46
|
-
|
47
|
-
session = Session.build do |telemetry|
|
48
|
-
Output::File.register(telemetry)
|
49
|
-
Output::Summary::Error.register(telemetry)
|
50
|
-
Output::Summary.register(telemetry)
|
51
|
-
end
|
52
|
-
end
|
59
|
+
session = instance.session
|
53
60
|
|
54
|
-
|
61
|
+
Output.register_telemetry_sink(session)
|
55
62
|
|
56
|
-
|
63
|
+
summary = instance.summary
|
64
|
+
session.register_telemetry_sink(summary)
|
57
65
|
|
58
66
|
instance
|
59
67
|
end
|
60
68
|
|
61
|
-
def self.
|
62
|
-
|
63
|
-
|
64
|
-
instance = build(exclude:)
|
69
|
+
def self.configure(receiver, attr_name: nil)
|
70
|
+
attr_name ||= :run
|
65
71
|
|
66
|
-
|
72
|
+
session = establish_session
|
67
73
|
|
68
|
-
instance
|
74
|
+
instance = build(session:)
|
75
|
+
receiver.public_send(:"#{attr_name}=", instance)
|
69
76
|
end
|
70
77
|
|
71
|
-
def self.
|
72
|
-
|
78
|
+
def self.call(path, exclude: nil)
|
79
|
+
session = establish_session
|
73
80
|
|
74
81
|
instance = build(exclude:, session:)
|
75
|
-
receiver.public_send(:"#{attr_name}=", instance)
|
76
|
-
end
|
77
82
|
|
78
|
-
|
79
|
-
|
80
|
-
path(path)
|
83
|
+
instance.() do
|
84
|
+
instance << path
|
81
85
|
end
|
82
86
|
end
|
83
87
|
|
84
|
-
def
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
telemetry.record(Started.build(random.seed))
|
90
|
-
|
91
|
-
executor.start
|
92
|
-
|
93
|
-
if not block.nil?
|
94
|
-
block.(self)
|
88
|
+
def self.establish_session
|
89
|
+
session = Session.build
|
90
|
+
Session.establish(session)
|
91
|
+
session
|
92
|
+
end
|
95
93
|
|
96
|
-
|
97
|
-
|
98
|
-
end
|
99
|
-
end
|
94
|
+
def call(&block)
|
95
|
+
block.(self)
|
100
96
|
|
101
|
-
|
97
|
+
session.isolate.stop
|
102
98
|
|
103
|
-
if
|
104
|
-
|
105
|
-
elsif session.failed?
|
106
|
-
result = false
|
99
|
+
if print_summary?
|
100
|
+
summary.print
|
107
101
|
end
|
108
102
|
|
109
|
-
|
110
|
-
result
|
103
|
+
result = session.result
|
104
|
+
Session::Result.resolve(result)
|
111
105
|
end
|
112
|
-
alias :! :run
|
113
106
|
|
114
107
|
def path(path)
|
115
108
|
self.path_sequence += 1
|
116
109
|
|
117
|
-
|
118
|
-
|
119
|
-
|
110
|
+
select_files.(path) do |file_path|
|
111
|
+
if abort_on_failure?
|
112
|
+
case session.result
|
113
|
+
when Session::Result.aborted, Session::Result.failed
|
114
|
+
next
|
115
|
+
end
|
116
|
+
end
|
120
117
|
|
121
|
-
|
122
|
-
|
118
|
+
session.execute(file_path)
|
119
|
+
end
|
123
120
|
|
124
|
-
|
121
|
+
rescue SelectFiles::PathNotFoundError
|
122
|
+
session.execute(path)
|
125
123
|
end
|
126
124
|
alias :<< :path
|
127
125
|
|
@@ -129,27 +127,17 @@ module TestBench
|
|
129
127
|
path_sequence > 0
|
130
128
|
end
|
131
129
|
|
132
|
-
module
|
133
|
-
def self.
|
134
|
-
|
135
|
-
end
|
130
|
+
module Defaults
|
131
|
+
def self.abort_on_failure
|
132
|
+
env_abort_on_failure = ENV.fetch('TEST_BENCH_ABORT_ON_FAILURE', 'off')
|
136
133
|
|
137
|
-
|
138
|
-
|
139
|
-
new
|
140
|
-
end
|
134
|
+
env_abort_on_failure == 'on'
|
135
|
+
end
|
141
136
|
|
142
|
-
|
143
|
-
|
144
|
-
end
|
137
|
+
def self.print_summary
|
138
|
+
env_print_summary = ENV.fetch('TEST_BENCH_OUTPUT_SUMMARY', 'on')
|
145
139
|
|
146
|
-
|
147
|
-
if result
|
148
|
-
session.record_assertion
|
149
|
-
else
|
150
|
-
session.record_failure
|
151
|
-
end
|
152
|
-
end
|
140
|
+
env_print_summary == 'on'
|
153
141
|
end
|
154
142
|
end
|
155
143
|
end
|
@@ -1,15 +1,12 @@
|
|
1
1
|
module TestBench
|
2
2
|
class Run
|
3
|
-
class
|
3
|
+
class SelectFiles
|
4
4
|
module Substitute
|
5
5
|
def self.build
|
6
|
-
|
6
|
+
SelectFiles.new
|
7
7
|
end
|
8
8
|
|
9
|
-
class
|
10
|
-
attr_accessor :file_error
|
11
|
-
def file_error? = !!file_error
|
12
|
-
|
9
|
+
class SelectFiles
|
13
10
|
def files
|
14
11
|
@files ||= []
|
15
12
|
end
|
@@ -20,18 +17,18 @@ module TestBench
|
|
20
17
|
@paths ||= []
|
21
18
|
end
|
22
19
|
|
23
|
-
|
24
|
-
|
20
|
+
attr_accessor :raise_path_not_found_error
|
21
|
+
|
22
|
+
def raise_path_not_found_error!
|
23
|
+
self.raise_path_not_found_error = true
|
25
24
|
end
|
26
25
|
|
27
|
-
def call(path,
|
28
|
-
|
29
|
-
|
26
|
+
def call(path, &block)
|
27
|
+
if raise_path_not_found_error
|
28
|
+
raise PathNotFoundError
|
30
29
|
end
|
31
30
|
|
32
|
-
|
33
|
-
raise FileError
|
34
|
-
end
|
31
|
+
self.paths << path
|
35
32
|
|
36
33
|
files.each(&block)
|
37
34
|
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
module TestBench
|
2
|
+
class Run
|
3
|
+
class SelectFiles
|
4
|
+
PathNotFoundError = Class.new(RuntimeError)
|
5
|
+
|
6
|
+
def exclude_patterns
|
7
|
+
@exclude_patterns ||= []
|
8
|
+
end
|
9
|
+
attr_writer :exclude_patterns
|
10
|
+
|
11
|
+
attr_accessor :apex_directory
|
12
|
+
|
13
|
+
def self.build(exclude_patterns: nil)
|
14
|
+
exclude_patterns ||= Defaults.exclude_file_patterns
|
15
|
+
|
16
|
+
exclude_patterns = Array(exclude_patterns)
|
17
|
+
|
18
|
+
instance = new
|
19
|
+
instance.exclude_patterns = exclude_patterns
|
20
|
+
instance
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.configure(receiver, exclude_patterns: nil, attr_name: nil)
|
24
|
+
attr_name ||= :select_files
|
25
|
+
|
26
|
+
instance = build(exclude_patterns:)
|
27
|
+
receiver.public_send(:"#{attr_name}=", instance)
|
28
|
+
end
|
29
|
+
|
30
|
+
def call(path, &block)
|
31
|
+
full_path = ::File.expand_path(path, apex_directory)
|
32
|
+
if not ::File.exist?(full_path)
|
33
|
+
raise PathNotFoundError, "No such file or directory - #{full_path}"
|
34
|
+
end
|
35
|
+
|
36
|
+
extension = ::File.extname(path)
|
37
|
+
|
38
|
+
if extension.empty?
|
39
|
+
directory_path = path
|
40
|
+
glob_pattern = ::File.join(directory_path, '**', '*.rb')
|
41
|
+
else
|
42
|
+
file_path = path
|
43
|
+
glob_pattern = file_path
|
44
|
+
end
|
45
|
+
|
46
|
+
Dir.glob(glob_pattern, base: apex_directory) do |file|
|
47
|
+
excluded = exclude_patterns.any? do |exclude_pattern|
|
48
|
+
::File.fnmatch?(exclude_pattern, file, ::File::FNM_EXTGLOB)
|
49
|
+
end
|
50
|
+
|
51
|
+
if excluded
|
52
|
+
next
|
53
|
+
end
|
54
|
+
|
55
|
+
block.(file)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
module Defaults
|
60
|
+
def self.exclude_file_patterns
|
61
|
+
env_exclude_file_pattern = ENV.fetch('TEST_BENCH_EXCLUDE_FILE_PATTERN', '*_init.rb')
|
62
|
+
|
63
|
+
env_exclude_file_pattern.split(':')
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module TestBench
|
2
|
+
class Run
|
3
|
+
module Substitute
|
4
|
+
def self.build
|
5
|
+
Run.new
|
6
|
+
end
|
7
|
+
|
8
|
+
class Run
|
9
|
+
attr_accessor :result
|
10
|
+
alias :set_result :result=
|
11
|
+
|
12
|
+
attr_accessor :ran
|
13
|
+
def ran?
|
14
|
+
ran ? true : false
|
15
|
+
end
|
16
|
+
|
17
|
+
def paths
|
18
|
+
@paths ||= []
|
19
|
+
end
|
20
|
+
|
21
|
+
def call(&block)
|
22
|
+
block.(self)
|
23
|
+
|
24
|
+
result
|
25
|
+
end
|
26
|
+
|
27
|
+
def path(path)
|
28
|
+
self.ran = true
|
29
|
+
|
30
|
+
paths << path
|
31
|
+
end
|
32
|
+
alias :<< :path
|
33
|
+
|
34
|
+
def path?(path)
|
35
|
+
paths.include?(path)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|