test_bench-run 0 → 2.0.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/run/controls/events/finished.rb +10 -4
- data/lib/test_bench/run/controls/events/started.rb +10 -4
- data/lib/test_bench/run/events.rb +2 -2
- data/lib/test_bench/run/executor/serial.rb +4 -1
- data/lib/test_bench/run/file.rb +8 -0
- data/lib/test_bench/run/output/summary/error.rb +1 -1
- data/lib/test_bench/run/output/summary.rb +8 -5
- data/lib/test_bench/run/run.rb +61 -8
- data/lib/test_bench/run.rb +0 -1
- metadata +3 -4
- data/lib/test_bench/run/file/substitute.rb +0 -41
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b56bc55bbd16b542a2501f29b93e1ae894d78b81304e3ae29eecb0141c59fa8a
|
4
|
+
data.tar.gz: bb66aa5f2cb14fd5f6415a77bcb9f9b6570152d1cb9b83c9902953dbccee7813
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1aae81bfb6e8069cbbd7a5f91b00edeb6f68a6103eba641ed71afe2ad525f3dfc3c7eb5148eabd2a6acf0ead639f27529cfb740847144184b23ebfe78a4c7a2b
|
7
|
+
data.tar.gz: 21f4ddae91338fc7338e1fb72640ad750b953418d392637db200b573171fe23342c546bd3be9124cfabc176fe1b072deb0e25a03b4f6b8e0b65976b6f15a6876
|
@@ -5,18 +5,23 @@ module TestBench
|
|
5
5
|
module Finished
|
6
6
|
extend EventData
|
7
7
|
|
8
|
-
def self.example(result: nil, process_id: nil, time: nil)
|
8
|
+
def self.example(result: nil, random_seed: nil, process_id: nil, time: nil)
|
9
|
+
random_seed ||= self.random_seed
|
9
10
|
result = self.result if result.nil?
|
10
11
|
process_id ||= self.process_id
|
11
12
|
time ||= self.time
|
12
13
|
|
13
|
-
Run::Events::Finished.build(result, process_id:, time:)
|
14
|
+
Run::Events::Finished.build(random_seed, result, process_id:, time:)
|
14
15
|
end
|
15
16
|
|
16
17
|
def self.random
|
17
18
|
Random.example
|
18
19
|
end
|
19
20
|
|
21
|
+
def self.random_seed
|
22
|
+
Started.random_seed
|
23
|
+
end
|
24
|
+
|
20
25
|
def self.result
|
21
26
|
Result.example
|
22
27
|
end
|
@@ -32,7 +37,8 @@ module TestBench
|
|
32
37
|
module Random
|
33
38
|
extend EventData
|
34
39
|
|
35
|
-
def self.example(result: nil, process_id: nil, time: nil)
|
40
|
+
def self.example(result: nil, random_seed: nil, process_id: nil, time: nil)
|
41
|
+
random_seed ||= Controls::Random.integer
|
36
42
|
process_id ||= ProcessID.random
|
37
43
|
time ||= Time.random
|
38
44
|
|
@@ -40,7 +46,7 @@ module TestBench
|
|
40
46
|
result = Result.random
|
41
47
|
end
|
42
48
|
|
43
|
-
Finished.example(result:, process_id:, time:)
|
49
|
+
Finished.example(result:, random_seed:, process_id:, time:)
|
44
50
|
end
|
45
51
|
end
|
46
52
|
end
|
@@ -5,17 +5,22 @@ module TestBench
|
|
5
5
|
module Started
|
6
6
|
extend EventData
|
7
7
|
|
8
|
-
def self.example(process_id: nil, time: nil)
|
8
|
+
def self.example(random_seed: nil, process_id: nil, time: nil)
|
9
|
+
random_seed ||= self.random_seed
|
9
10
|
process_id ||= self.process_id
|
10
11
|
time ||= self.time
|
11
12
|
|
12
|
-
Run::Events::Started.build(process_id:, time:)
|
13
|
+
Run::Events::Started.build(random_seed, process_id:, time:)
|
13
14
|
end
|
14
15
|
|
15
16
|
def self.random
|
16
17
|
Random.example
|
17
18
|
end
|
18
19
|
|
20
|
+
def self.random_seed
|
21
|
+
1
|
22
|
+
end
|
23
|
+
|
19
24
|
def self.process_id
|
20
25
|
ProcessID.example
|
21
26
|
end
|
@@ -27,11 +32,12 @@ module TestBench
|
|
27
32
|
module Random
|
28
33
|
extend EventData
|
29
34
|
|
30
|
-
def self.example(process_id: nil, time: nil)
|
35
|
+
def self.example(random_seed: nil, process_id: nil, time: nil)
|
36
|
+
random_seed ||= Controls::Random.integer
|
31
37
|
process_id ||= ProcessID.random
|
32
38
|
time ||= Time.random
|
33
39
|
|
34
|
-
Started.example(process_id:, time:)
|
40
|
+
Started.example(random_seed:, process_id:, time:)
|
35
41
|
end
|
36
42
|
end
|
37
43
|
end
|
@@ -5,8 +5,8 @@ module TestBench
|
|
5
5
|
FileFinished = Telemetry::Event.define(:file, :result)
|
6
6
|
FileCrashed = Telemetry::Event.define(:file, :error_message, :error_text)
|
7
7
|
|
8
|
-
Started = Telemetry::Event.define
|
9
|
-
Finished = Telemetry::Event.define(:result)
|
8
|
+
Started = Telemetry::Event.define(:random_seed)
|
9
|
+
Finished = Telemetry::Event.define(:random_seed, :result)
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
@@ -70,14 +70,17 @@ module TestBench
|
|
70
70
|
|
71
71
|
session = session_store.fetch
|
72
72
|
|
73
|
+
session_projection = Session::Projection.new(session)
|
74
|
+
|
73
75
|
loop do
|
74
76
|
event_text = telemetry_reader.gets
|
75
77
|
|
76
78
|
event_data = Telemetry::EventData.load(event_text)
|
77
79
|
session.telemetry.record(event_data)
|
78
80
|
|
81
|
+
session_projection.(event_data)
|
82
|
+
|
79
83
|
if event_data.type == :FileCrashed
|
80
|
-
session.record_failure
|
81
84
|
dump_exception_text(event_data)
|
82
85
|
break
|
83
86
|
end
|
data/lib/test_bench/run/file.rb
CHANGED
@@ -13,13 +13,21 @@ module TestBench
|
|
13
13
|
end
|
14
14
|
attr_writer :session
|
15
15
|
|
16
|
+
def random
|
17
|
+
@random ||= Random::Substitute.build
|
18
|
+
end
|
19
|
+
attr_writer :random
|
20
|
+
|
16
21
|
def self.build(session: nil)
|
17
22
|
instance = new
|
18
23
|
Session.configure(instance, session:)
|
24
|
+
Random.configure(instance)
|
19
25
|
instance
|
20
26
|
end
|
21
27
|
|
22
28
|
def call(file)
|
29
|
+
random.reset(file)
|
30
|
+
|
23
31
|
begin
|
24
32
|
source = ::File.read(file)
|
25
33
|
rescue SystemCallError => error
|
@@ -57,19 +57,19 @@ module TestBench
|
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
-
handle TestSkipped do
|
60
|
+
handle TestSkipped do
|
61
61
|
self.tests_skipped += 1
|
62
62
|
end
|
63
63
|
|
64
|
-
handle ContextSkipped do
|
64
|
+
handle ContextSkipped do
|
65
65
|
self.contexts_skipped += 1
|
66
66
|
end
|
67
67
|
|
68
|
-
handle FileFinished do
|
68
|
+
handle FileFinished do
|
69
69
|
self.files_finished += 1
|
70
70
|
end
|
71
71
|
|
72
|
-
handle FileCrashed do
|
72
|
+
handle FileCrashed do
|
73
73
|
self.files_crashed += 1
|
74
74
|
end
|
75
75
|
|
@@ -146,7 +146,10 @@ module TestBench
|
|
146
146
|
writer.style(:reset_intensity)
|
147
147
|
end
|
148
148
|
else
|
149
|
-
writer
|
149
|
+
writer
|
150
|
+
.style(:bold, :faint, :italic)
|
151
|
+
.print("0 passed")
|
152
|
+
.style(:reset_italic, :reset_intensity)
|
150
153
|
end
|
151
154
|
writer.print(", ")
|
152
155
|
|
data/lib/test_bench/run/run.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
module TestBench
|
2
2
|
class Run
|
3
|
-
|
3
|
+
Error = Class.new(RuntimeError)
|
4
|
+
|
4
5
|
include Events
|
5
6
|
|
6
7
|
def telemetry
|
@@ -23,20 +24,25 @@ module TestBench
|
|
23
24
|
end
|
24
25
|
attr_writer :executor
|
25
26
|
|
27
|
+
def random
|
28
|
+
@random ||= Random::Substitute.build
|
29
|
+
end
|
30
|
+
attr_writer :random
|
31
|
+
|
26
32
|
def path_sequence
|
27
33
|
@path_sequence ||= 0
|
28
34
|
end
|
29
35
|
attr_writer :path_sequence
|
30
36
|
|
31
|
-
def self.build(exclude_file_pattern: nil
|
32
|
-
session_store ||= Session::Store.instance
|
33
|
-
|
37
|
+
def self.build(exclude_file_pattern: nil)
|
34
38
|
instance = new
|
35
39
|
|
36
40
|
GetFiles.configure(instance, exclude_file_pattern:)
|
37
41
|
|
38
42
|
Executor::Serial.configure(instance)
|
39
43
|
|
44
|
+
Random.configure(instance)
|
45
|
+
|
40
46
|
session = Session.build do |telemetry|
|
41
47
|
Output::File.register(telemetry)
|
42
48
|
Output::Summary::Error.register(telemetry)
|
@@ -46,16 +52,27 @@ module TestBench
|
|
46
52
|
end
|
47
53
|
|
48
54
|
Session.configure(instance, session:)
|
49
|
-
session_store.put(session)
|
50
55
|
|
51
56
|
instance
|
52
57
|
end
|
53
58
|
|
54
|
-
def self.call(path, exclude_file_pattern: nil)
|
59
|
+
def self.call(path, session_store: nil, exclude_file_pattern: nil)
|
60
|
+
session_store ||= Session::Store.instance
|
61
|
+
|
55
62
|
instance = build(exclude_file_pattern:)
|
63
|
+
|
64
|
+
session_store.reset(instance.session)
|
65
|
+
|
56
66
|
instance.(path)
|
57
67
|
end
|
58
68
|
|
69
|
+
def self.configure(receiver, exclude_file_pattern: nil, attr_name: nil)
|
70
|
+
attr_name ||= :run
|
71
|
+
|
72
|
+
instance = build(exclude_file_pattern:)
|
73
|
+
receiver.public_send(:"#{attr_name}=", instance)
|
74
|
+
end
|
75
|
+
|
59
76
|
def call(path)
|
60
77
|
run do
|
61
78
|
path(path)
|
@@ -63,12 +80,20 @@ module TestBench
|
|
63
80
|
end
|
64
81
|
|
65
82
|
def run(&block)
|
66
|
-
|
83
|
+
if ran?
|
84
|
+
raise Error, "Already ran"
|
85
|
+
end
|
86
|
+
|
87
|
+
telemetry.record(Started.build(random.seed))
|
67
88
|
|
68
89
|
executor.start
|
69
90
|
|
70
91
|
if not block.nil?
|
71
92
|
block.(self)
|
93
|
+
|
94
|
+
if not ran?
|
95
|
+
raise Error, "No paths were supplied"
|
96
|
+
end
|
72
97
|
end
|
73
98
|
|
74
99
|
executor.finish
|
@@ -79,7 +104,7 @@ module TestBench
|
|
79
104
|
result = false
|
80
105
|
end
|
81
106
|
|
82
|
-
telemetry.record(Finished.build(result))
|
107
|
+
telemetry.record(Finished.build(random.seed, result))
|
83
108
|
result
|
84
109
|
end
|
85
110
|
alias :! :run
|
@@ -97,5 +122,33 @@ module TestBench
|
|
97
122
|
session.record_failure
|
98
123
|
end
|
99
124
|
alias :<< :path
|
125
|
+
|
126
|
+
def ran?
|
127
|
+
path_sequence > 0
|
128
|
+
end
|
129
|
+
|
130
|
+
module Substitute
|
131
|
+
def self.build
|
132
|
+
Run.build
|
133
|
+
end
|
134
|
+
|
135
|
+
class Run < Run
|
136
|
+
def self.build
|
137
|
+
new
|
138
|
+
end
|
139
|
+
|
140
|
+
def path?(path)
|
141
|
+
get_files.path?(path)
|
142
|
+
end
|
143
|
+
|
144
|
+
def set_result(result)
|
145
|
+
if result
|
146
|
+
session.record_assertion
|
147
|
+
else
|
148
|
+
session.record_failure
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
100
153
|
end
|
101
154
|
end
|
data/lib/test_bench/run.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: test_bench-run
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Ladd
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-07-
|
11
|
+
date: 2023-07-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: test_bench-fixture
|
@@ -25,7 +25,7 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name: test_bench-
|
28
|
+
name: test_bench-isolated
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
@@ -70,7 +70,6 @@ files:
|
|
70
70
|
- lib/test_bench/run/executor/serial.rb
|
71
71
|
- lib/test_bench/run/executor/substitute.rb
|
72
72
|
- lib/test_bench/run/file.rb
|
73
|
-
- lib/test_bench/run/file/substitute.rb
|
74
73
|
- lib/test_bench/run/get_files.rb
|
75
74
|
- lib/test_bench/run/get_files/substitute.rb
|
76
75
|
- lib/test_bench/run/output/file.rb
|
@@ -1,41 +0,0 @@
|
|
1
|
-
module TestBench
|
2
|
-
class Run
|
3
|
-
class File
|
4
|
-
module Substitute
|
5
|
-
def self.build
|
6
|
-
File.new
|
7
|
-
end
|
8
|
-
|
9
|
-
class File
|
10
|
-
def result
|
11
|
-
@result.nil? ? @result = true : @result
|
12
|
-
end
|
13
|
-
attr_writer :result
|
14
|
-
alias :set_result :result=
|
15
|
-
|
16
|
-
attr_accessor :exception
|
17
|
-
alias :set_exception :exception=
|
18
|
-
def exception? = !!exception
|
19
|
-
|
20
|
-
def files
|
21
|
-
@files ||= []
|
22
|
-
end
|
23
|
-
|
24
|
-
def call(file)
|
25
|
-
files << file
|
26
|
-
|
27
|
-
if exception?
|
28
|
-
raise exception
|
29
|
-
end
|
30
|
-
|
31
|
-
result
|
32
|
-
end
|
33
|
-
|
34
|
-
def file?(file)
|
35
|
-
files.include?(file)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|