test_bench-telemetry 2.0.0.1 → 2.1.0.1
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/telemetry/controls/event/event_data.rb +15 -0
- data/lib/test_bench/telemetry/controls/event/metadata.rb +70 -0
- data/lib/test_bench/telemetry/controls/event.rb +112 -51
- data/lib/test_bench/telemetry/controls/event_data.rb +129 -0
- data/lib/test_bench/telemetry/controls/file.rb +84 -0
- data/lib/test_bench/telemetry/controls/handler.rb +48 -43
- data/lib/test_bench/telemetry/controls/{detail_level.rb → process_id.rb} +7 -3
- data/lib/test_bench/telemetry/controls/projection/receiver.rb +31 -0
- data/lib/test_bench/telemetry/controls/projection.rb +84 -0
- data/lib/test_bench/telemetry/controls/random.rb +1 -1
- data/lib/test_bench/telemetry/controls/sink.rb +23 -1
- data/lib/test_bench/telemetry/controls/time.rb +49 -2
- data/lib/test_bench/telemetry/controls.rb +10 -33
- data/lib/test_bench/telemetry/event.rb +74 -13
- data/lib/test_bench/telemetry/{event → event_data}/serialization.rb +78 -53
- data/lib/test_bench/telemetry/event_data.rb +13 -0
- data/lib/test_bench/telemetry/sink/file.rb +3 -3
- data/lib/test_bench/telemetry/sink/handler/event_registry.rb +42 -0
- data/lib/test_bench/telemetry/sink/handler.rb +54 -30
- data/lib/test_bench/telemetry/sink/projection.rb +132 -0
- data/lib/test_bench/telemetry/sink.rb +11 -0
- data/lib/test_bench/telemetry/substitute/sink.rb +83 -0
- data/lib/test_bench/telemetry/substitute.rb +13 -54
- data/lib/test_bench/telemetry/telemetry.rb +60 -19
- data/lib/test_bench/telemetry.rb +8 -10
- metadata +17 -40
- data/lib/test_bench/telemetry/controls/capture_sink/path.rb +0 -30
- data/lib/test_bench/telemetry/controls/capture_sink/record.rb +0 -21
- data/lib/test_bench/telemetry/controls/comment.rb +0 -19
- data/lib/test_bench/telemetry/controls/error.rb +0 -36
- data/lib/test_bench/telemetry/controls/events/asserted.rb +0 -32
- data/lib/test_bench/telemetry/controls/events/commented.rb +0 -26
- data/lib/test_bench/telemetry/controls/events/context_entered.rb +0 -31
- data/lib/test_bench/telemetry/controls/events/context_exited.rb +0 -34
- data/lib/test_bench/telemetry/controls/events/context_skipped.rb +0 -31
- data/lib/test_bench/telemetry/controls/events/detail_decreased.rb +0 -23
- data/lib/test_bench/telemetry/controls/events/detail_increased.rb +0 -23
- data/lib/test_bench/telemetry/controls/events/error_raised.rb +0 -26
- data/lib/test_bench/telemetry/controls/events/file_entered.rb +0 -29
- data/lib/test_bench/telemetry/controls/events/file_exited.rb +0 -32
- data/lib/test_bench/telemetry/controls/events/fixture_finished.rb +0 -29
- data/lib/test_bench/telemetry/controls/events/fixture_started.rb +0 -26
- data/lib/test_bench/telemetry/controls/events/run_aborted.rb +0 -29
- data/lib/test_bench/telemetry/controls/events/run_finished.rb +0 -32
- data/lib/test_bench/telemetry/controls/events/run_started.rb +0 -29
- data/lib/test_bench/telemetry/controls/events/test_finished.rb +0 -34
- data/lib/test_bench/telemetry/controls/events/test_skipped.rb +0 -31
- data/lib/test_bench/telemetry/controls/events/test_started.rb +0 -31
- data/lib/test_bench/telemetry/controls/events.rb +0 -27
- data/lib/test_bench/telemetry/controls/fixture_name.rb +0 -19
- data/lib/test_bench/telemetry/controls/line_number.rb +0 -10
- data/lib/test_bench/telemetry/controls/path.rb +0 -87
- data/lib/test_bench/telemetry/controls/result.rb +0 -12
- data/lib/test_bench/telemetry/controls/title.rb +0 -43
- data/lib/test_bench/telemetry/event/events.rb +0 -35
- data/lib/test_bench/telemetry/event/type.rb +0 -27
- data/lib/test_bench/telemetry/sink/capture/path.rb +0 -69
- data/lib/test_bench/telemetry/sink/capture/record/generate.rb +0 -49
- data/lib/test_bench/telemetry/sink/capture/record.rb +0 -73
- data/lib/test_bench/telemetry/sink/capture.rb +0 -55
@@ -1,19 +0,0 @@
|
|
1
|
-
module TestBench
|
2
|
-
class Telemetry
|
3
|
-
module Controls
|
4
|
-
module FixtureName
|
5
|
-
def self.example(suffix=nil)
|
6
|
-
suffix = "_#{suffix}" if not suffix.nil?
|
7
|
-
|
8
|
-
"SomeProject::Fixtures::SomeFixture#{suffix}"
|
9
|
-
end
|
10
|
-
|
11
|
-
def self.random
|
12
|
-
suffix = example(Random.string)
|
13
|
-
|
14
|
-
example(suffix)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,87 +0,0 @@
|
|
1
|
-
module TestBench
|
2
|
-
class Telemetry
|
3
|
-
module Controls
|
4
|
-
module Path
|
5
|
-
def self.example(suffix=nil)
|
6
|
-
suffix = "_#{suffix}" if not suffix.nil?
|
7
|
-
|
8
|
-
"path/to/some_file#{suffix}.rb"
|
9
|
-
end
|
10
|
-
|
11
|
-
module Random
|
12
|
-
def random = example(Controls::Random.string)
|
13
|
-
end
|
14
|
-
extend Random
|
15
|
-
|
16
|
-
module Temporary
|
17
|
-
def self.example(suffix=nil, basename: nil, extension: nil)
|
18
|
-
basename ||= self.basename
|
19
|
-
extension ||= self.extension
|
20
|
-
|
21
|
-
suffix = "-#{suffix}" if not suffix.nil?
|
22
|
-
|
23
|
-
filename = "#{basename}#{suffix}#{extension}"
|
24
|
-
|
25
|
-
File.join('tmp', filename)
|
26
|
-
end
|
27
|
-
|
28
|
-
def self.random(basename: nil, extension: nil)
|
29
|
-
suffix = Controls::Random.string
|
30
|
-
|
31
|
-
example(suffix, basename:, extension:)
|
32
|
-
end
|
33
|
-
|
34
|
-
def self.basename
|
35
|
-
'some-file'
|
36
|
-
end
|
37
|
-
|
38
|
-
def self.extension
|
39
|
-
'.some-ext'
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
module Absolute
|
44
|
-
extend Random
|
45
|
-
|
46
|
-
def self.example(suffix=nil)
|
47
|
-
path = Path.example(suffix)
|
48
|
-
|
49
|
-
File.join('/', path)
|
50
|
-
end
|
51
|
-
|
52
|
-
module Local
|
53
|
-
extend Random
|
54
|
-
|
55
|
-
def self.example(suffix=nil)
|
56
|
-
path = Path.example(suffix)
|
57
|
-
|
58
|
-
File.join(current_dir, path)
|
59
|
-
end
|
60
|
-
|
61
|
-
def self.current_dir
|
62
|
-
File.join('/home', 'some-user', 'some-working-dir')
|
63
|
-
end
|
64
|
-
|
65
|
-
module Gem
|
66
|
-
extend Random
|
67
|
-
|
68
|
-
def self.example(path=nil)
|
69
|
-
path ||= Path.example
|
70
|
-
|
71
|
-
path = File.join(gems_path, path)
|
72
|
-
|
73
|
-
Local.example(path)
|
74
|
-
end
|
75
|
-
|
76
|
-
def self.gems_path
|
77
|
-
ruby_version = RbConfig::CONFIG['ruby_version']
|
78
|
-
|
79
|
-
"gems/ruby/#{ruby_version}/gems"
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
module TestBench
|
2
|
-
class Telemetry
|
3
|
-
module Controls
|
4
|
-
module Title
|
5
|
-
def self.example(suffix=nil, text: nil)
|
6
|
-
suffix = " #{suffix}" if not suffix.nil?
|
7
|
-
text ||= self.text
|
8
|
-
|
9
|
-
"#{text}#{suffix}"
|
10
|
-
end
|
11
|
-
|
12
|
-
def self.text = "Some Title"
|
13
|
-
|
14
|
-
module Random
|
15
|
-
def random = example(Controls::Random.string)
|
16
|
-
end
|
17
|
-
extend Random
|
18
|
-
|
19
|
-
module Test
|
20
|
-
extend Random
|
21
|
-
|
22
|
-
def self.example(suffix=nil)
|
23
|
-
Title.example(suffix, text: example_text)
|
24
|
-
end
|
25
|
-
def self.example_text = "Some test"
|
26
|
-
|
27
|
-
def self.other_example = "Some other test"
|
28
|
-
end
|
29
|
-
|
30
|
-
module Context
|
31
|
-
extend Random
|
32
|
-
|
33
|
-
def self.example(suffix=nil)
|
34
|
-
Title.example(suffix, text: example_text)
|
35
|
-
end
|
36
|
-
def self.example_text = "Some Context"
|
37
|
-
|
38
|
-
def self.other_example = "Some Other Context"
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
module TestBench
|
2
|
-
class Telemetry
|
3
|
-
module Event
|
4
|
-
module Events
|
5
|
-
Asserted = Event.define(:result, :path, :line_number)
|
6
|
-
|
7
|
-
ErrorRaised = Event.define(:error_text)
|
8
|
-
|
9
|
-
TestStarted = Event.define(:title)
|
10
|
-
TestFinished = Event.define(:result, :title)
|
11
|
-
TestSkipped = Event.define(:title)
|
12
|
-
|
13
|
-
ContextEntered = Event.define(:title)
|
14
|
-
ContextExited = Event.define(:result, :title)
|
15
|
-
ContextSkipped = Event.define(:title)
|
16
|
-
|
17
|
-
Commented = Event.define(:comment)
|
18
|
-
|
19
|
-
DetailIncreased = Event.define
|
20
|
-
DetailDecreased = Event.define
|
21
|
-
|
22
|
-
RunStarted = Event.define(:random_seed, :executors)
|
23
|
-
RunFinished = Event.define(:result, :random_seed, :executors)
|
24
|
-
RunAborted = Event.define(:random_seed, :executors)
|
25
|
-
|
26
|
-
FileEntered = Event.define(:path, :executor)
|
27
|
-
FileExited = Event.define(:result, :path, :executor)
|
28
|
-
|
29
|
-
FixtureStarted = Event.define(:name)
|
30
|
-
FixtureFinished = Event.define(:result, :name)
|
31
|
-
end
|
32
|
-
include Events
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
module TestBench
|
2
|
-
class Telemetry
|
3
|
-
module Event
|
4
|
-
module Type
|
5
|
-
def self.get(class_name)
|
6
|
-
*, constant_name = class_name.split('::')
|
7
|
-
|
8
|
-
constant_name.to_sym
|
9
|
-
end
|
10
|
-
|
11
|
-
def self.method_cased(event_type)
|
12
|
-
pascal_cased = event_type.to_s
|
13
|
-
|
14
|
-
underscore_cased = pascal_cased.gsub(%r{(?:\A|[a-z])[A-Z]+}) do |match_text|
|
15
|
-
if ('a'..'z').include?(match_text[0])
|
16
|
-
match_text.insert(1, '_')
|
17
|
-
end
|
18
|
-
match_text.downcase!
|
19
|
-
match_text
|
20
|
-
end
|
21
|
-
|
22
|
-
underscore_cased.to_sym
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,69 +0,0 @@
|
|
1
|
-
module TestBench
|
2
|
-
class Telemetry
|
3
|
-
module Sink
|
4
|
-
class Capture
|
5
|
-
class Path
|
6
|
-
def segments
|
7
|
-
@segments ||= []
|
8
|
-
end
|
9
|
-
attr_writer :segments
|
10
|
-
|
11
|
-
def match?(*segments, segment)
|
12
|
-
if not segment == self.segments.last
|
13
|
-
return false
|
14
|
-
end
|
15
|
-
|
16
|
-
segment_iterator = self.segments.to_enum
|
17
|
-
|
18
|
-
control_segments = [*segments, segment]
|
19
|
-
|
20
|
-
control_segments.all? do |control_segment|
|
21
|
-
begin
|
22
|
-
next_segment = segment_iterator.next
|
23
|
-
end until next_segment == control_segment
|
24
|
-
true
|
25
|
-
|
26
|
-
rescue StopIteration
|
27
|
-
false
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def push_segment(segment)
|
32
|
-
segments << segment
|
33
|
-
end
|
34
|
-
alias :push :push_segment
|
35
|
-
alias :<< :push
|
36
|
-
|
37
|
-
def pop_segment(compare_segment=nil)
|
38
|
-
segments.pop
|
39
|
-
end
|
40
|
-
alias :pop :pop_segment
|
41
|
-
|
42
|
-
def copy(receiver)
|
43
|
-
path = self.class.new
|
44
|
-
|
45
|
-
segments.each do |segment|
|
46
|
-
path << segment
|
47
|
-
end
|
48
|
-
|
49
|
-
receiver.path = path
|
50
|
-
path
|
51
|
-
end
|
52
|
-
|
53
|
-
def copy?(compare_path)
|
54
|
-
eql?(compare_path) && !equal?(compare_path)
|
55
|
-
end
|
56
|
-
|
57
|
-
def eql?(compare)
|
58
|
-
if compare.is_a?(self.class)
|
59
|
-
segments == compare.segments
|
60
|
-
else
|
61
|
-
false
|
62
|
-
end
|
63
|
-
end
|
64
|
-
alias :== :eql?
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
@@ -1,49 +0,0 @@
|
|
1
|
-
module TestBench
|
2
|
-
class Telemetry
|
3
|
-
module Sink
|
4
|
-
class Capture
|
5
|
-
class Record
|
6
|
-
class Generate
|
7
|
-
include Event::Events
|
8
|
-
|
9
|
-
def path
|
10
|
-
@path ||= Path.new
|
11
|
-
end
|
12
|
-
attr_writer :path
|
13
|
-
|
14
|
-
def detail_level
|
15
|
-
@detail_level ||= 0
|
16
|
-
end
|
17
|
-
attr_writer :detail_level
|
18
|
-
|
19
|
-
def call(event)
|
20
|
-
case event
|
21
|
-
when TestStarted, ContextEntered
|
22
|
-
path.push(event.title)
|
23
|
-
when TestFinished, ContextExited
|
24
|
-
path.pop(event.title)
|
25
|
-
when DetailIncreased
|
26
|
-
self.detail_level += 1
|
27
|
-
when DetailDecreased
|
28
|
-
self.detail_level -= 1
|
29
|
-
end
|
30
|
-
|
31
|
-
record = Record.build(event, path, detail_level)
|
32
|
-
|
33
|
-
case event
|
34
|
-
when TestFinished, ContextExited
|
35
|
-
title = event.title
|
36
|
-
record.path.push(title)
|
37
|
-
when Commented
|
38
|
-
comment = event.comment
|
39
|
-
record.path.push(comment)
|
40
|
-
end
|
41
|
-
|
42
|
-
record
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
@@ -1,73 +0,0 @@
|
|
1
|
-
module TestBench
|
2
|
-
class Telemetry
|
3
|
-
module Sink
|
4
|
-
class Capture
|
5
|
-
Record = Struct.new(:event, :path, :detail_level) do
|
6
|
-
def self.build(event, path, detail_level)
|
7
|
-
instance = new
|
8
|
-
instance.event = event
|
9
|
-
instance.detail_level = detail_level
|
10
|
-
|
11
|
-
path.copy(instance)
|
12
|
-
|
13
|
-
instance
|
14
|
-
end
|
15
|
-
|
16
|
-
def match?(*path_segments, detail: nil, detail_level: nil, &block)
|
17
|
-
if not path_segments?(*path_segments)
|
18
|
-
false
|
19
|
-
elsif not detail?(detail)
|
20
|
-
false
|
21
|
-
elsif not detail_level?(detail_level)
|
22
|
-
false
|
23
|
-
elsif not block?(&block)
|
24
|
-
false
|
25
|
-
else
|
26
|
-
true
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def detail_match?(match)
|
31
|
-
if match.nil?
|
32
|
-
true
|
33
|
-
elsif match
|
34
|
-
detail_level > 0
|
35
|
-
else
|
36
|
-
detail_level.zero?
|
37
|
-
end
|
38
|
-
end
|
39
|
-
alias :detail? :detail_match?
|
40
|
-
|
41
|
-
def detail_level_match?(detail_level)
|
42
|
-
if detail_level.nil?
|
43
|
-
true
|
44
|
-
else
|
45
|
-
detail_level == self.detail_level
|
46
|
-
end
|
47
|
-
end
|
48
|
-
alias :detail_level? :detail_level_match?
|
49
|
-
|
50
|
-
def path_segments_match?(*segments)
|
51
|
-
if segments.empty?
|
52
|
-
true
|
53
|
-
else
|
54
|
-
path.match?(*segments)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
alias :path_segments? :path_segments_match?
|
58
|
-
|
59
|
-
def block_match?(&block)
|
60
|
-
if block.nil?
|
61
|
-
true
|
62
|
-
elsif block.(event.event_type, *event.values)
|
63
|
-
true
|
64
|
-
else
|
65
|
-
false
|
66
|
-
end
|
67
|
-
end
|
68
|
-
alias :block? :block_match?
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
@@ -1,55 +0,0 @@
|
|
1
|
-
module TestBench
|
2
|
-
class Telemetry
|
3
|
-
module Sink
|
4
|
-
class Capture
|
5
|
-
include Sink
|
6
|
-
|
7
|
-
MatchError = Class.new(RuntimeError)
|
8
|
-
|
9
|
-
def raw_records
|
10
|
-
@raw_records ||= []
|
11
|
-
end
|
12
|
-
|
13
|
-
def generate_record
|
14
|
-
@generate_record ||= Record::Generate.new
|
15
|
-
end
|
16
|
-
attr_writer :generate_record
|
17
|
-
|
18
|
-
def call(event)
|
19
|
-
record = generate_record.(event)
|
20
|
-
|
21
|
-
raw_records.push(record)
|
22
|
-
|
23
|
-
record
|
24
|
-
end
|
25
|
-
|
26
|
-
def one_record?(...)
|
27
|
-
record = one_record(...)
|
28
|
-
|
29
|
-
!record.nil?
|
30
|
-
end
|
31
|
-
|
32
|
-
def one_record(...)
|
33
|
-
records = records(...)
|
34
|
-
|
35
|
-
if records.count > 1
|
36
|
-
raise MatchError, "More than one record matches (Matching Records: #{records.count})"
|
37
|
-
end
|
38
|
-
|
39
|
-
records.first
|
40
|
-
end
|
41
|
-
|
42
|
-
def any_record?(...)
|
43
|
-
records(...).any?
|
44
|
-
end
|
45
|
-
alias :record? :any_record?
|
46
|
-
|
47
|
-
def records(...)
|
48
|
-
raw_records.select do |record|
|
49
|
-
record.match?(...)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|