rspec_trunk_flaky_tests 0.7.2-aarch64-linux → 0.7.6-aarch64-linux
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/context_ruby/3.0/context_ruby.so +0 -0
- data/lib/context_ruby/3.1/context_ruby.so +0 -0
- data/lib/context_ruby/3.2/context_ruby.so +0 -0
- data/lib/context_ruby/3.3/context_ruby.so +0 -0
- data/lib/context_ruby/3.4/context_ruby.so +0 -0
- data/lib/trunk_spec_helper.rb +68 -38
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '036314043582f4d12501984763da8b39cd62a36d9056749eb46ce8eae443655a'
|
4
|
+
data.tar.gz: aae1bacdf05bdd611f77ae62345a2e041eadef4330f0ab1568606d43196fb15c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af47f814fa2a1e7267ba101d72364a0a1904a97fdeedef7fbf730ab71b51f8235bf5965a411165d23d723f1498d6e2d216ea5e8f681a6fc5b075df13d029eed9
|
7
|
+
data.tar.gz: 3d5f0250cbb6e884209dd578208eb0d79b685ba248a727e58ca68283db322da9c62b502c54d5013215967f702cd068ba9b3ed462c39a36b783bec2370fe8ab36
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/lib/trunk_spec_helper.rb
CHANGED
@@ -4,10 +4,49 @@ require 'rspec/core'
|
|
4
4
|
require 'time'
|
5
5
|
require 'context_ruby'
|
6
6
|
|
7
|
+
# String is an override to the main String class that is used to colorize the output
|
8
|
+
# it is used to make the output more readable
|
9
|
+
class String
|
10
|
+
def colorize(color_code)
|
11
|
+
"\e[#{color_code}m#{self}\e[0m"
|
12
|
+
end
|
13
|
+
|
14
|
+
def red
|
15
|
+
colorize(31)
|
16
|
+
end
|
17
|
+
|
18
|
+
def green
|
19
|
+
colorize(32)
|
20
|
+
end
|
21
|
+
|
22
|
+
def yellow
|
23
|
+
colorize(33)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
7
27
|
def escape(str)
|
8
28
|
str.dump[1..-2]
|
9
29
|
end
|
10
30
|
|
31
|
+
def description_generated?(example)
|
32
|
+
auto_generated_exp = /^\s?is expected to .*$/
|
33
|
+
full_description = example.full_description
|
34
|
+
parent_description = example.example_group.description
|
35
|
+
checked_description = full_description.sub(parent_description, '')
|
36
|
+
!auto_generated_exp.match(checked_description).nil? || full_description.empty?
|
37
|
+
end
|
38
|
+
|
39
|
+
def generate_id(example)
|
40
|
+
return "trunk:#{example.id}-#{example.location}" if description_generated?(example)
|
41
|
+
end
|
42
|
+
|
43
|
+
def trunk_disabled
|
44
|
+
ENV['DISABLE_RSPEC_TRUNK_FLAKY_TESTS'] == 'true' || ENV['TRUNK_ORG_URL_SLUG'].nil? || ENV['TRUNK_API_TOKEN'].nil?
|
45
|
+
end
|
46
|
+
|
47
|
+
# we want to cache the test report so we can add to it as we go and reduce the number of API calls
|
48
|
+
$test_report = TestReport.new('rspec', "#{$PROGRAM_NAME} #{ARGV.join(' ')}")
|
49
|
+
|
11
50
|
module RSpec
|
12
51
|
module Core
|
13
52
|
# Example is the class that represents a test case
|
@@ -17,16 +56,25 @@ module RSpec
|
|
17
56
|
# RSpec uses the existance of an exception to determine if the test failed
|
18
57
|
# We need to override this to allow us to capture the exception and then
|
19
58
|
# decide if we want to fail the test or not
|
20
|
-
# trunk-ignore(rubocop/Naming/AccessorMethodName)
|
59
|
+
# trunk-ignore(rubocop/Naming/AccessorMethodName,rubocop/Metrics/MethodLength,rubocop/Metrics/AbcSize)
|
21
60
|
def set_exception(exception)
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
61
|
+
return set_exception_core(exception) if trunk_disabled
|
62
|
+
|
63
|
+
id = generate_id(self)
|
64
|
+
name = full_description
|
65
|
+
parent_name = example_group.metadata[:description]
|
66
|
+
parent_name = parent_name.empty? ? 'rspec' : parent_name
|
67
|
+
file = escape(metadata[:file_path])
|
68
|
+
classname = file.sub(%r{\.[^/.]+\Z}, '').gsub('/', '.').gsub(/\A\.+|\.+\Z/, '')
|
69
|
+
puts "Test failed, checking if it can be quarantined: `#{location}`".yellow
|
70
|
+
if $test_report.is_quarantined(id, name, parent_name, classname, file)
|
27
71
|
# monitor the override in the metadata
|
28
72
|
metadata[:quarantined_exception] = exception
|
73
|
+
puts "Test is quarantined, overriding exception: #{exception}".green
|
29
74
|
nil
|
75
|
+
else
|
76
|
+
puts 'Test is not quarantined, continuing'.red
|
77
|
+
set_exception_core(exception)
|
30
78
|
end
|
31
79
|
end
|
32
80
|
|
@@ -45,7 +93,7 @@ module RSpec
|
|
45
93
|
class Trunk
|
46
94
|
def self.setup
|
47
95
|
RSpec.configure do |config|
|
48
|
-
if
|
96
|
+
if trunk_disabled
|
49
97
|
config.around(:each, &:run)
|
50
98
|
else
|
51
99
|
config.around(:each, &:run_with_trunk)
|
@@ -70,10 +118,6 @@ module RSpec
|
|
70
118
|
else
|
71
119
|
@example.metadata[:attempt_number] = 0
|
72
120
|
end
|
73
|
-
|
74
|
-
# add the test to the report
|
75
|
-
# return the report
|
76
|
-
@testreport
|
77
121
|
end
|
78
122
|
end
|
79
123
|
end
|
@@ -82,7 +126,7 @@ end
|
|
82
126
|
# it generates and submits the final test reports
|
83
127
|
class TrunkAnalyticsListener
|
84
128
|
def initialize
|
85
|
-
@testreport =
|
129
|
+
@testreport = $test_report
|
86
130
|
end
|
87
131
|
|
88
132
|
def example_finished(notification)
|
@@ -90,34 +134,18 @@ class TrunkAnalyticsListener
|
|
90
134
|
end
|
91
135
|
|
92
136
|
def close(_notification)
|
93
|
-
@testreport.publish
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
full_description = example.full_description
|
99
|
-
parent_description = example.example_group.description
|
100
|
-
checked_description = full_description.sub(parent_description, '')
|
101
|
-
auto_generated_exp.match(checked_description) != nil
|
102
|
-
end
|
103
|
-
|
104
|
-
def generate_id(example)
|
105
|
-
if description_generated?(example)
|
106
|
-
# trunk-ignore(rubocop/Style/SoleNestedConditional)
|
107
|
-
return "trunk:#{example.id}-#{example.location}" if description_generated?(example)
|
137
|
+
res = @testreport.publish
|
138
|
+
if res
|
139
|
+
puts 'Flaky tests report upload complete'.green
|
140
|
+
else
|
141
|
+
puts 'Failed to publish flaky tests report'.red
|
108
142
|
end
|
109
|
-
nil
|
110
143
|
end
|
111
144
|
|
112
145
|
# trunk-ignore(rubocop/Metrics/AbcSize,rubocop/Metrics/MethodLength,rubocop/Metrics/CyclomaticComplexity)
|
113
146
|
def add_test_case(example)
|
114
|
-
if example.exception
|
115
|
-
|
116
|
-
# failure details is far more robust than the message, but noiser
|
117
|
-
# if example.exception.backtrace
|
118
|
-
# failure_details = example.exception.backtrace.join('\n')
|
119
|
-
# end
|
120
|
-
end
|
147
|
+
failure_message = example.exception.to_s if example.exception
|
148
|
+
failure_message = example.metadata[:quarantined_exception].to_s if example.metadata[:quarantined_exception]
|
121
149
|
# TODO: should we use concatenated string or alias when auto-generated description?
|
122
150
|
name = example.full_description
|
123
151
|
file = escape(example.metadata[:file_path])
|
@@ -129,9 +157,11 @@ class TrunkAnalyticsListener
|
|
129
157
|
|
130
158
|
attempt_number = example.metadata[:attempt_number] || 0
|
131
159
|
status = example.execution_result.status.to_s
|
160
|
+
# set the status to failure, but mark it as quarantined
|
161
|
+
is_quarantined = example.metadata[:quarantined_exception] ? true : false
|
132
162
|
case example.execution_result.status
|
133
163
|
when :passed
|
134
|
-
status = Status.new('success')
|
164
|
+
status = is_quarantined ? Status.new('failure') : Status.new('success')
|
135
165
|
when :failed
|
136
166
|
status = Status.new('failure')
|
137
167
|
when :pending
|
@@ -140,12 +170,12 @@ class TrunkAnalyticsListener
|
|
140
170
|
parent_name = example.example_group.metadata[:description]
|
141
171
|
parent_name = parent_name.empty? ? 'rspec' : parent_name
|
142
172
|
@testreport.add_test(id, name, classname, file, parent_name, line, status, attempt_number,
|
143
|
-
started_at, finished_at, failure_message || '')
|
173
|
+
started_at, finished_at, failure_message || '', is_quarantined)
|
144
174
|
end
|
145
175
|
end
|
146
176
|
|
147
177
|
RSpec.configure do |c|
|
148
|
-
next if
|
178
|
+
next if trunk_disabled
|
149
179
|
|
150
180
|
c.reporter.register_listener TrunkAnalyticsListener.new, :example_finished, :close
|
151
181
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec_trunk_flaky_tests
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.6
|
5
5
|
platform: aarch64-linux
|
6
6
|
authors:
|
7
7
|
- Trunk Technologies, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-04-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec-core
|