rspec-tracer 0.9.1 → 0.9.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bbe5a34cf76bcf55ded1f0a9c8067d682dc9eaf7b4d4827a9fc153c19afa25a3
4
- data.tar.gz: d17e0522f2c5cb064029121a3cb8786034664121394eef3f73bdc0b8a181f691
3
+ metadata.gz: 3f76c84eee2926bd06511fc4e92112653dd9515a7a486c5c90102e94d1001ba7
4
+ data.tar.gz: 8b64c63ba96ade735ec0cd1c2982075ece274fc88e4f76eb0bff2a6bd1c4f545
5
5
  SHA512:
6
- metadata.gz: ec7251d9c7d450327e870d25c482e1c90bdbb40c38e41202ed1b95b98806691e6d02259c4f61f7ae333451224d0e6662b5994db2cd05c10efd9eda31157562de
7
- data.tar.gz: e46dd0d565c75a8f8569db87dfec53fe32e2bf3e31bb2a6f31c4a460dd497ce45fc0dde5ede8bd417bd3866a1d594c41a3528713923139e3bbdbfe6d71fd3582
6
+ metadata.gz: b296c0812b1b223186eb3e3a789cf2eefb9a035216ef83b7b0ebd98828f64f9c358ca435cd68461f2baf96c710d2fe02547e1eb1f25a4219cc92da4bd59ab7c8
7
+ data.tar.gz: eb899ae2a04ceb7bd0b6a99af710750a98c03282b431d86e2c038376a76120d1ad794ee917e866638732099a8966a039cbebc5e17514062a262e6ab733700137
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## [0.9.2] - 2021-09-30
2
+
3
+ ### Fixed
4
+
5
+ Caches getting corrupted on interrupts (#39)
6
+
1
7
  ## [0.9.1] - 2021-09-23
2
8
 
3
9
  ### Fixed
data/README.md CHANGED
@@ -28,9 +28,7 @@ recommended to use **simplecov >= 0.12.0**. To use RSpec Tracer **cache on CI**,
28
28
  need to have an **S3 bucket** and **[AWS CLI](https://aws.amazon.com/cli/)**
29
29
  installed.
30
30
 
31
- You should take some time and go through the **[document](./RSPEC_TRACER.md)**
32
- describing the **intention** and implementation details of **managing dependency**,
33
- **managing flaky tests**, **skipping tests**, and **caching on CI**.
31
+ ### You should take some time and go through the **[document](./RSPEC_TRACER.md)** describing the **intention** and implementation details of **managing dependency**, **managing flaky tests**, **skipping tests**, and **caching on CI**.
34
32
 
35
33
  ## Table of Contents
36
34
 
@@ -2,8 +2,8 @@
2
2
 
3
3
  module RSpecTracer
4
4
  class Cache
5
- attr_reader :all_examples, :flaky_examples, :failed_examples, :pending_examples,
6
- :all_files, :dependency, :run_id
5
+ attr_reader :all_examples, :interrupted_examples, :flaky_examples, :failed_examples,
6
+ :pending_examples, :all_files, :dependency, :run_id
7
7
 
8
8
  def initialize
9
9
  @run_id = last_run_id
@@ -12,6 +12,7 @@ module RSpecTracer
12
12
  @cached = false
13
13
 
14
14
  @all_examples = {}
15
+ @interrupted_examples = Set.new
15
16
  @flaky_examples = Set.new
16
17
  @failed_examples = Set.new
17
18
  @pending_examples = Set.new
@@ -74,7 +75,11 @@ module RSpecTracer
74
75
  end
75
76
 
76
77
  @all_examples.each_value do |example|
77
- example[:execution_result].transform_keys!(&:to_sym)
78
+ if example.key?(:execution_result)
79
+ example[:execution_result].transform_keys!(&:to_sym)
80
+ else
81
+ @interrupted_examples << example[:example_id]
82
+ end
78
83
 
79
84
  example[:run_reason] = nil
80
85
  end
@@ -60,7 +60,19 @@ module RSpecTracer
60
60
  id: example_id,
61
61
  description: example[:full_description],
62
62
  location: example_location(example[:rerun_file_name], example[:rerun_line_number]),
63
- status: example[:run_reason] || 'Skipped',
63
+ status: example[:run_reason] || 'Skipped'
64
+ }.merge(example_result(example_id, example))
65
+ end
66
+ end
67
+
68
+ def example_result(example_id, example)
69
+ if example[:execution_result].nil?
70
+ {
71
+ result: @reporter.example_interrupted?(example_id) ? 'Interrupted' : '_',
72
+ last_run: '_'
73
+ }
74
+ else
75
+ {
64
76
  result: example[:execution_result][:status].capitalize,
65
77
  last_run: example_run_local_time(example[:execution_result][:finished_at])
66
78
  }
@@ -176,7 +188,7 @@ module RSpecTracer
176
188
 
177
189
  def example_status_css_class(example_status)
178
190
  case example_status.split.first
179
- when 'Failed', 'Flaky'
191
+ when 'Failed', 'Flaky', 'Interrupted'
180
192
  'red'
181
193
  when 'Pending'
182
194
  'yellow'
@@ -189,7 +201,7 @@ module RSpecTracer
189
201
  case example_result
190
202
  when 'Passed'
191
203
  'green'
192
- when 'Failed'
204
+ when 'Failed', 'Interrupted'
193
205
  'red'
194
206
  when 'Pending'
195
207
  'yellow'
@@ -2,9 +2,10 @@
2
2
 
3
3
  module RSpecTracer
4
4
  class Reporter
5
- attr_reader :all_examples, :possibly_flaky_examples, :flaky_examples, :pending_examples,
6
- :all_files, :modified_files, :deleted_files, :dependency, :reverse_dependency,
7
- :examples_coverage, :last_run
5
+ attr_reader :all_examples, :interrupted_examples, :possibly_flaky_examples,
6
+ :flaky_examples, :pending_examples, :all_files, :modified_files,
7
+ :deleted_files, :dependency, :reverse_dependency, :examples_coverage,
8
+ :last_run
8
9
 
9
10
  def initialize
10
11
  initialize_examples
@@ -37,8 +38,21 @@ module RSpecTracer
37
38
  @all_examples[example_id][:execution_result] = formatted_execution_result(result)
38
39
  end
39
40
 
41
+ def register_interrupted_examples
42
+ @all_examples.each_pair do |example_id, example|
43
+ next if example.key?(:execution_result)
44
+
45
+ @interrupted_examples << example_id
46
+ end
47
+
48
+ return if @interrupted_examples.empty?
49
+
50
+ puts "RSpec tracer is not processing #{@interrupted_examples.count} interrupted examples"
51
+ end
52
+
40
53
  def register_deleted_examples(seen_examples)
41
54
  @deleted_examples = seen_examples.keys.to_set - (@skipped_examples | @all_examples.keys)
55
+ @deleted_examples -= @interrupted_examples
42
56
 
43
57
  @deleted_examples.select! do |example_id|
44
58
  example = seen_examples[example_id]
@@ -63,6 +77,10 @@ module RSpecTracer
63
77
  @pending_examples << example_id
64
78
  end
65
79
 
80
+ def example_interrupted?(example_id)
81
+ @interrupted_examples.include?(example_id)
82
+ end
83
+
66
84
  def example_passed?(example_id)
67
85
  @passed_examples.include?(example_id)
68
86
  end
@@ -128,6 +146,8 @@ module RSpecTracer
128
146
 
129
147
  def generate_reverse_dependency_report
130
148
  @dependency.each_pair do |example_id, files|
149
+ next if @interrupted_examples.include?(example_id)
150
+
131
151
  example_file = @all_examples[example_id][:rerun_file_name]
132
152
 
133
153
  files.each do |file_name|
@@ -145,9 +165,11 @@ module RSpecTracer
145
165
  pid: RSpecTracer.pid,
146
166
  actual_count: RSpec.world.example_count + @skipped_examples.count,
147
167
  example_count: RSpec.world.example_count,
168
+ interrupted_examples: @interrupted_examples.count,
148
169
  failed_examples: @failed_examples.count,
149
170
  skipped_examples: @skipped_examples.count,
150
- pending_examples: @pending_examples.count
171
+ pending_examples: @pending_examples.count,
172
+ flaky_examples: @flaky_examples.count
151
173
  }
152
174
  end
153
175
 
@@ -182,6 +204,7 @@ module RSpecTracer
182
204
  def initialize_examples
183
205
  @all_examples = {}
184
206
  @duplicate_examples = Hash.new { |examples, example_id| examples[example_id] = [] }
207
+ @interrupted_examples = Set.new
185
208
  @passed_examples = Set.new
186
209
  @possibly_flaky_examples = Set.new
187
210
  @flaky_examples = Set.new
@@ -8,6 +8,7 @@ module RSpecTracer
8
8
  EXAMPLE_RUN_REASON = {
9
9
  explicit_run: 'Explicit run',
10
10
  no_cache: 'No cache',
11
+ interrupted: 'Interrupted previously',
11
12
  flaky_example: 'Flaky example',
12
13
  failed_example: 'Failed previously',
13
14
  pending_example: 'Pending previously',
@@ -59,6 +60,10 @@ module RSpecTracer
59
60
  @reporter.on_example_pending(example_id, execution_result)
60
61
  end
61
62
 
63
+ def register_interrupted_examples
64
+ @reporter.register_interrupted_examples
65
+ end
66
+
62
67
  def register_deleted_examples
63
68
  @reporter.register_deleted_examples(@cache.all_examples)
64
69
  end
@@ -77,6 +82,7 @@ module RSpecTracer
77
82
 
78
83
  @cache.cached_examples_coverage.each_pair do |example_id, example_coverage|
79
84
  example_coverage.each_pair do |file_path, line_coverage|
85
+ next if @reporter.example_interrupted?(example_id)
80
86
  next unless @reporter.example_skipped?(example_id)
81
87
 
82
88
  file_name = RSpecTracer::SourceFile.file_name(file_path)
@@ -97,6 +103,8 @@ module RSpecTracer
97
103
  filtered_files = Set.new
98
104
 
99
105
  examples_coverage.each_pair do |example_id, example_coverage|
106
+ next if @reporter.example_interrupted?(example_id)
107
+
100
108
  register_example_files_dependency(example_id)
101
109
 
102
110
  example_coverage.each_key do |file_path|
@@ -122,6 +130,8 @@ module RSpecTracer
122
130
  @reporter.register_source_file(source_file)
123
131
 
124
132
  @reporter.all_examples.each_key do |example_id|
133
+ next if @reporter.example_interrupted?(example_id)
134
+
125
135
  @reporter.register_dependency(example_id, source_file[:file_name])
126
136
  end
127
137
  end
@@ -169,6 +179,7 @@ module RSpecTracer
169
179
  end
170
180
 
171
181
  def filter_by_example_status
182
+ add_previously_interrupted_examples
172
183
  add_previously_flaky_examples
173
184
  add_previously_failed_examples
174
185
  add_previously_pending_examples
@@ -183,6 +194,12 @@ module RSpecTracer
183
194
  end
184
195
  end
185
196
 
197
+ def add_previously_interrupted_examples
198
+ @cache.interrupted_examples.each do |example_id|
199
+ @filtered_examples[example_id] = EXAMPLE_RUN_REASON[:interrupted]
200
+ end
201
+ end
202
+
186
203
  def add_previously_flaky_examples
187
204
  @cache.flaky_examples.each do |example_id|
188
205
  @filtered_examples[example_id] = EXAMPLE_RUN_REASON[:flaky_example]
@@ -249,6 +266,8 @@ module RSpecTracer
249
266
  end
250
267
 
251
268
  def register_example_files_dependency(example_id)
269
+ return if @reporter.example_interrupted?(example_id)
270
+
252
271
  example = @reporter.all_examples[example_id]
253
272
 
254
273
  register_example_file_dependency(example_id, example[:file_name])
@@ -259,6 +278,8 @@ module RSpecTracer
259
278
  end
260
279
 
261
280
  def register_example_file_dependency(example_id, file_name)
281
+ return if @reporter.example_interrupted?(example_id)
282
+
262
283
  source_file = RSpecTracer::SourceFile.from_name(file_name)
263
284
 
264
285
  @reporter.register_source_file(source_file)
@@ -266,6 +287,8 @@ module RSpecTracer
266
287
  end
267
288
 
268
289
  def register_file_dependency(example_id, file_path)
290
+ return if @reporter.example_interrupted?(example_id)
291
+
269
292
  source_file = RSpecTracer::SourceFile.from_path(file_path)
270
293
 
271
294
  return false if RSpecTracer.filters.any? { |filter| filter.match?(source_file) }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RSpecTracer
4
- VERSION = '0.9.1'
4
+ VERSION = '0.9.2'
5
5
  end
data/lib/rspec_tracer.rb CHANGED
@@ -196,6 +196,7 @@ module RSpecTracer
196
196
  def process_dependency
197
197
  starting = Process.clock_gettime(Process::CLOCK_MONOTONIC)
198
198
 
199
+ runner.register_interrupted_examples
199
200
  runner.register_deleted_examples
200
201
  runner.register_dependency(coverage_reporter.examples_coverage)
201
202
  runner.register_untraced_dependency(@traced_files)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-tracer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Abhimanyu Singh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-23 00:00:00.000000000 Z
11
+ date: 2021-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: docile
@@ -113,7 +113,7 @@ licenses:
113
113
  - MIT
114
114
  metadata:
115
115
  homepage_uri: https://github.com/avmnu-sng/rspec-tracer
116
- source_code_uri: https://github.com/avmnu-sng/rspec-tracer/tree/v0.9.1
116
+ source_code_uri: https://github.com/avmnu-sng/rspec-tracer/tree/v0.9.2
117
117
  changelog_uri: https://github.com/avmnu-sng/rspec-tracer/blob/main/CHANGELOG.md
118
118
  bug_tracker_uri: https://github.com/avmnu-sng/rspec-tracer/issues
119
119
  post_install_message: