rspec-buildkite-analytics 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ca7801b3e7bc48f52a372df29c553c9e2dad5bffdab1bf8dff0b20f0173b987
|
4
|
+
data.tar.gz: 22d6197b37f465afa1a2a309ba4f3780bafef928d626768a5d4d3fa6d214a809
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0380c462ae87c2dd2dbb830bbcdc93bef621b74f2f516c465b37e633679e9e0c887fe8557356aaf85abd8e7fe179110b86aabceb339057cd89e37c00afcac107'
|
7
|
+
data.tar.gz: 9b6810ff8529454f543b70f521b34906223e2ee02ad1f0d4cd261d4bfe6e2c4ed21eb76c8eddfb08818c9c8a07d07cb62c3c206c958c48743a47c1dfde83f9b3
|
data/Gemfile.lock
CHANGED
@@ -18,6 +18,7 @@ module RSpec::Buildkite::Analytics
|
|
18
18
|
|
19
19
|
if trace
|
20
20
|
trace.example = example
|
21
|
+
trace.failure_reason, trace.failure_expanded = failure_info(notification) if example.execution_result.status == :failed
|
21
22
|
RSpec::Buildkite::Analytics.session&.write_result(trace)
|
22
23
|
end
|
23
24
|
end
|
@@ -45,9 +46,54 @@ module RSpec::Buildkite::Analytics
|
|
45
46
|
end
|
46
47
|
end
|
47
48
|
end
|
48
|
-
|
49
|
+
|
49
50
|
alias_method :example_passed, :handle_example
|
50
51
|
alias_method :example_failed, :handle_example
|
51
52
|
alias_method :example_pending, :handle_example
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def failure_info(notification)
|
57
|
+
failure_expanded = []
|
58
|
+
|
59
|
+
if notification.exception.class == RSpec::Expectations::MultipleExpectationsNotMetError
|
60
|
+
failure_reason = notification.exception.summary
|
61
|
+
notification.exception.all_exceptions.each do |exception|
|
62
|
+
# an example with multiple failures doesn't give us a
|
63
|
+
# separate message lines and backtrace object to send, so
|
64
|
+
# I've reached into RSpec internals and duplicated the
|
65
|
+
# construction of these
|
66
|
+
message_lines = RSpec::Core::Formatters::ExceptionPresenter.new(exception, notification.example).colorized_message_lines
|
67
|
+
|
68
|
+
failure_expanded << {
|
69
|
+
expanded: format_message_lines(message_lines),
|
70
|
+
backtrace: RSpec.configuration.backtrace_formatter.format_backtrace(exception.backtrace)
|
71
|
+
}
|
72
|
+
end
|
73
|
+
else
|
74
|
+
failure_reason = strip_diff_colors(notification.colorized_message_lines[0])
|
75
|
+
|
76
|
+
# the second line is always whitespace padding
|
77
|
+
message_lines = notification.colorized_message_lines[2..]
|
78
|
+
|
79
|
+
failure_expanded << {
|
80
|
+
expanded: format_message_lines(message_lines),
|
81
|
+
backtrace: notification.formatted_backtrace
|
82
|
+
}
|
83
|
+
end
|
84
|
+
|
85
|
+
return failure_reason, failure_expanded
|
86
|
+
end
|
87
|
+
|
88
|
+
def format_message_lines(message_lines)
|
89
|
+
message_lines.map! { |l| strip_diff_colors(l) }
|
90
|
+
# the last line is sometimes blank, depending on the error reported
|
91
|
+
message_lines.pop if message_lines.last.blank?
|
92
|
+
message_lines
|
93
|
+
end
|
94
|
+
|
95
|
+
def strip_diff_colors(string)
|
96
|
+
string.gsub(/\e\[([;\d]+)?m/, '')
|
97
|
+
end
|
52
98
|
end
|
53
99
|
end
|
@@ -22,22 +22,15 @@ require "securerandom"
|
|
22
22
|
module RSpec::Buildkite::Analytics
|
23
23
|
class Uploader
|
24
24
|
class Trace
|
25
|
-
attr_accessor :example
|
25
|
+
attr_accessor :example, :failure_reason, :failure_expanded
|
26
26
|
attr_reader :id, :history
|
27
27
|
|
28
28
|
def initialize(example, history)
|
29
29
|
@id = SecureRandom.uuid
|
30
30
|
@example = example
|
31
31
|
@history = history
|
32
|
-
|
33
|
-
|
34
|
-
def failure_message
|
35
|
-
case example.exception
|
36
|
-
when RSpec::Expectations::ExpectationNotMetError
|
37
|
-
example.exception.message
|
38
|
-
when Exception
|
39
|
-
"#{example.exception.class}: #{example.exception.message}"
|
40
|
-
end
|
32
|
+
@failure_reason = nil
|
33
|
+
@failure_expanded = []
|
41
34
|
end
|
42
35
|
|
43
36
|
def result_state
|
@@ -57,9 +50,10 @@ module RSpec::Buildkite::Analytics
|
|
57
50
|
location: example.location,
|
58
51
|
file_name: generate_file_name(example),
|
59
52
|
result: result_state,
|
60
|
-
|
53
|
+
failure_reason: failure_reason,
|
54
|
+
failure_expanded: failure_expanded,
|
61
55
|
history: history,
|
62
|
-
}.with_indifferent_access
|
56
|
+
}.with_indifferent_access.compact
|
63
57
|
end
|
64
58
|
|
65
59
|
private
|
@@ -121,7 +115,8 @@ module RSpec::Buildkite::Analytics
|
|
121
115
|
"Content-Type" => "application/json",
|
122
116
|
})
|
123
117
|
contact.body = {
|
124
|
-
run_env: CI.env
|
118
|
+
run_env: CI.env,
|
119
|
+
format: "websocket"
|
125
120
|
}.to_json
|
126
121
|
|
127
122
|
response = begin
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-buildkite-analytics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Buildkite
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-12-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|