rspec-tracer 1.0.0 → 1.1.1

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: 9aaeb8a00f4cebc311367e6a61d59526014849df9f7fe890455d64cef16d435f
4
- data.tar.gz: b803d5104a0a35f783bdd15b7a43252a1cfddcdd56d9f0a26c5a07bb8c36ef5e
3
+ metadata.gz: 5e89ead4a61c2b6d881fe8ca3fbcfec3ab94e7d8b78f759de5fe64e4e22b693d
4
+ data.tar.gz: 8993bc089a6185bdd7f0e20f71ad69b13fbd96c679bf67878c69b4f52dacd12f
5
5
  SHA512:
6
- metadata.gz: 56acd78d6d4bf7b6270e8517a82d0bb1237dd78518a22d1a84a96de29e00c59379092cd725cc276d3f59ca2916306835c38426917747dcaf278e45d611c99389
7
- data.tar.gz: a4e026b2c6fdaad653bd48063c9d0b771e7e7bc8876f653cc2e32279930d6a043b546ab1c7a713e12aac934f1f069497decdb5856246d4ee8033e905577be1db
6
+ metadata.gz: 91dc8066a66b706cfc02e9cb1050c61fc2e6bfa15d7353d056b11edb854ac493a99770516ce57e9ef4649494a0d99573b9dc8e441ead128b9e28abce9e2e21c1
7
+ data.tar.gz: 21a2cceab3b2cd3f1c3051542a1267d03a7cb499417f9501502a8c1bac3ac62e96821a1c07ea977768adca4b806a1fffca13b0e2946db95f031e877bc5bc4ebd
data/CHANGELOG.md CHANGED
@@ -1,3 +1,72 @@
1
+ ## [1.1.1] - 2026-04-23
2
+
3
+ ### Fixed
4
+
5
+ - **parallel_tests at-exit deadlock** — `parallel_tests_last_process?`
6
+ relied on a lock file written during `RSpecTracer.start` to identify
7
+ the last worker. If a fast worker reached `at_exit` before a slower
8
+ peer had loaded `spec_helper` and registered its `TEST_ENV_NUMBER`,
9
+ both workers could self-elect as the last process, both entered
10
+ `::ParallelTests.wait_for_other_processes_to_finish`, and deadlocked
11
+ on each other's pid. The elector now delegates to
12
+ `::ParallelTests.first_process?`, which reads immutable env vars set
13
+ by the parent at worker spawn. Exactly one worker is elected per run,
14
+ regardless of boot-time ordering or runner CPU count. No public-API
15
+ change — the `rspec_tracer.lock` file is still written and cleaned
16
+ up, just no longer consulted.
17
+
18
+ ## [1.1.0] - 2026-04-20
19
+
20
+ ### Added
21
+
22
+ - Ruby 3.1, 3.2, 3.3, 3.4, 4.0 are now CI-gated.
23
+ - Rails 7.0, 7.1, 7.2 are CI-gated via a reference sample app.
24
+ - Regression specs for four crash bugs (B1–B4) under
25
+ `spec/lib/rspec_tracer/`.
26
+
27
+ ### Fixed
28
+
29
+ - **B1** — `Cache#cached_examples_coverage` returns `{}` (not `nil`)
30
+ when `last_run.json` is present but `examples_coverage.json` is
31
+ missing; previously this leaked nil into the missed-coverage merge.
32
+ - **B2** — `Runner#generate_missed_coverage` tolerates a nil cached
33
+ coverage map and nil line-strength entries; both are treated as
34
+ empty / zero.
35
+ - **B3** — `Runner#register_{file,example_file}_dependency` skips
36
+ (logs debug, returns false) when `SourceFile.from_path` /
37
+ `.from_name` cannot resolve the file (e.g. gem-generated examples
38
+ or files deleted between runs).
39
+ - **B4** — `CoverageReporter#merge_coverage` treats nil existing
40
+ line coverage as 0 when summing skipped-test contributions.
41
+ - Custom filter and coverage-filter blocks now reach
42
+ `RSpecTracer::Filter.register` — the DSL wrappers were dropping
43
+ the block, causing `add_filter { |sf| … }` to raise
44
+ `ArgumentError`.
45
+ - `load_global_config.rb` wraps `Dir.home` / `Etc.getpwuid.dir` /
46
+ `File.expand_path("~user")` in `rescue ArgumentError` so gem
47
+ load never crashes in minimal containers where HOME is unset and
48
+ the passwd database has no matching entry.
49
+
50
+ ### Changed
51
+
52
+ - **Behavior change (default filters)** — the default dependency
53
+ and coverage filter lists now exclude Ruby installation /
54
+ toolchain paths: `/lib/rspec_tracer/`, `/lib/rspec_tracer.rb`,
55
+ `/usr/local/lib/ruby/`, `/usr/local/bundle/`,
56
+ `/opt/hostedtoolcache/`, `/.rbenv/versions/`,
57
+ `/.asdf/installs/ruby/`, `/.rvm/`. Previously only
58
+ `/vendor/bundle/` was filtered. A test that previously recorded
59
+ a dependency on a gem file or Ruby stdlib file (because of a
60
+ custom install path like rbenv or asdf) will no longer record
61
+ that dependency — those paths are handled by `Gemfile.lock` /
62
+ the Ruby version file, not by coverage tracking. If you relied
63
+ on the old narrow default, add your own `add_filter` /
64
+ `add_coverage_filter` to clear the extras.
65
+
66
+ ### Removed
67
+
68
+ - Support for Ruby ≤ 3.0 and Rails ≤ 6.x (EOL).
69
+
1
70
  ## [1.0.0] - 2021-10-21
2
71
 
3
72
  ### Added
data/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  ![](./readme_files/rspec_tracer.png)
2
2
 
3
- [![Discord](https://badgen.net/badge/icon/discord?icon=discord&label)](https://discord.gg/H2G9yWeuRZ)
4
- [![Maintainability](https://api.codeclimate.com/v1/badges/eabce2757839c08d8f8d/maintainability)](https://codeclimate.com/github/avmnu-sng/rspec-tracer/maintainability)
5
- [![Test Coverage](https://api.codeclimate.com/v1/badges/eabce2757839c08d8f8d/test_coverage)](https://codeclimate.com/github/avmnu-sng/rspec-tracer/test_coverage)
3
+ [![Open Source Helpers](https://www.codetriage.com/avmnu-sng/rspec-tracer/badges/users.svg)](https://www.codetriage.com/avmnu-sng/rspec-tracer)
6
4
  [![Gem Version](https://badge.fury.io/rb/rspec-tracer.svg)](https://badge.fury.io/rb/rspec-tracer)
7
5
 
6
+ ![](./readme_files/next_run.gif)
7
+
8
8
  RSpec Tracer is a **specs dependency analyzer**, **flaky tests detector**, **tests accelerator**,
9
9
  and **coverage reporter** tool. It maintains a list of files for each test, enabling
10
10
  itself to skip tests in the subsequent runs if none of the dependent files are changed.
@@ -25,90 +25,39 @@ we can also analyze the coupling between different components and much more.
25
25
 
26
26
  RSpec Tracer requires **Ruby 2.5+** and **rspec-core >= 3.6.0**. To use with **Rails 5+**,
27
27
  make sure to use **rspec-rails >= 4.0.0**. If you are using SimpleCov, it is
28
- recommended to use **simplecov >= 0.12.0**. To use RSpec Tracer **cache on CI**, you
28
+ recommended to use **simplecov >= 0.17.0**. To use RSpec Tracer **cache on CI**, you
29
29
  need to have an **S3 bucket** and **[AWS CLI](https://aws.amazon.com/cli/)**
30
30
  installed.
31
31
 
32
- > 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**.
32
+ > You should take some time and go through the **[document](./RSPEC_TRACER.md)**
33
+ describing the **intention** and implementation details of **managing dependency**,
34
+ **managing flaky tests**, **skipping tests**, and **caching on CI**.
33
35
 
34
36
  ## Table of Contents
35
37
 
36
- * [Demo](#demo)
37
38
  * [Getting Started](#getting-started)
38
39
  * [Working with JRuby](#working-with-jruby)
39
40
  * [Working with Parallel Tests](#working-with-parallel-tests)
40
- * [Configuring CI Caching](#configuring-ci-caching)
41
+ * [Configuring CI](#configuring-ci)
41
42
  * [Advanced Configuration](#advanced-configuration)
43
+ * [Available Settings](#available-settings)
42
44
  * [Filters](#filters)
43
- * [Environment Variables](#environment-variables)
44
45
  * [Duplicate Examples](#duplicate-examples)
45
-
46
- ## Demo
47
-
48
- **First Run**
49
- ![](./readme_files/first_run.gif)
50
-
51
- **Next Run**
52
- ![](./readme_files/next_run.gif)
53
-
54
- You get the following three reports:
55
-
56
- ### All Examples Report
57
-
58
- These reports provide basic test information:
59
-
60
- **First Run**
61
-
62
- ![](./readme_files/examples_report_first_run.png)
63
-
64
- **Next Run**
65
-
66
- ![](./readme_files/examples_report_next_run.png)
67
-
68
- ### Duplicate Examples Report
69
-
70
- These reports provide duplicate tests information.
71
-
72
- ![](./readme_files/duplicate_examples_report.png)
73
-
74
- ### Flaky Examples Report
75
-
76
- These reports provide flaky tests information. Assuming **the following two tests
77
- failed in the first run.**
78
-
79
- **Next Run**
80
-
81
- ![](./readme_files/flaky_examples_report_first_run.png)
82
-
83
- **Another Run**
84
-
85
- ![](./readme_files/flaky_examples_report_next_run.png)
86
-
87
- ### Examples Dependency Report
88
-
89
- These reports show a list of dependent files for each test.
90
-
91
- ![](./readme_files/examples_dependency_report.png)
92
-
93
- ### Files Dependency Report
94
-
95
- These reports provide information on the total number of tests that will run after changing this particular file.
96
-
97
- ![](./readme_files/files_dependency_report.png)
98
-
46
+ * [Demo](#demo)
99
47
 
100
48
  ## Getting Started
101
49
 
102
50
  1. Add this line to your `Gemfile` and `bundle install`:
103
51
  ```ruby
104
- gem 'rspec-tracer', '~> 0.9', group: :test, require: false
52
+ gem 'rspec-tracer', '~> 1.0', group: :test, require: false
105
53
  ```
106
54
 
107
55
  And, add the followings to your `.gitignore`:
108
56
  ```
109
- /rspec_tracer_cache/
110
- /rspec_tracer_coverage/
111
- /rspec_tracer_report/
57
+ rspec_tracer.lock
58
+ rspec_tracer_cache/
59
+ rspec_tracer_coverage/
60
+ rspec_tracer_report/
112
61
  ```
113
62
  2. Load and launch RSpec Tracer at the very top of `spec_helper.rb` (or `rails_helper.rb`,
114
63
  `test/test_helper.rb`). Note that `RSpecTracer.start` must be issued **before loading
@@ -151,16 +100,16 @@ objectspace.enabled=true
151
100
  ### Working with Parallel Tests
152
101
 
153
102
  The Rspec tracer, by default, supports working with [parallel_tests](https://github.com/grosser/parallel_tests/)
154
- gem. It maintains a lock file `/tmp/parallel_tests.lock` to identify the last
103
+ gem. It maintains a lock file `rspec_tracer.lock` to identify the last
155
104
  running process. Usually, you are not required to do anything special unless you
156
105
  interrupt the execution in between and the process did not complete correctly.
157
106
  In such a case, you must delete the lock file before the next run.
158
107
 
159
108
  ```sh
160
- rm -f /tmp/parallel_tests.lock && bundle exec parallel_rspec
109
+ rm -f rspec_tracer.lock && bundle exec parallel_rspec
161
110
  ```
162
111
 
163
- ## Configuring CI Caching
112
+ ## Configuring CI
164
113
 
165
114
  To enable RSpec Tracer to share cache between different builds on CI, update the
166
115
  Rakefile in your project to have the following:
@@ -180,52 +129,97 @@ After running tests, upload the local cache using the following rake task:
180
129
  bundle exec rake rspec_tracer:remote_cache:upload
181
130
  ```
182
131
 
183
- You must set the following two environment variables:
132
+ You must set the following environment variables:
133
+
134
+ - **`GIT_DEFAULT_BRANCH`** is the default branch name for the repo, e.g., `main` or `master`.
184
135
 
185
136
  - **`GIT_BRANCH`** is the git branch name you are running the CI build on.
186
- - **`RSPEC_TRACER_S3_URI`** is the S3 bucket path to store the cache files.
137
+
138
+ - **`TEST_SUITES`** is the total number of different test suites you are running.
187
139
  ```sh
188
- export RSPEC_TRACER_S3_URI=s3://ci-artifacts-bucket/rspec-tracer-cache
140
+ export TEST_SUITES=8
189
141
  ```
190
142
 
191
- ## Advanced Configuration
143
+ - **`TEST_SUITE_ID`** is the CI build ID. If you have a large set of tests to run,
144
+ it is recommended to run them in separate groups. This way, RSpec Tracer is not
145
+ overwhelmed with loading massive cached data in the memory. Also, it generates and
146
+ uses cache for specific test suites and not merge them.
147
+ ```sh
148
+ TEST_SUITE_ID=1 bundle exec rspec spec/models
149
+ TEST_SUITE_ID=2 bundle exec rspec spec/helpers
150
+ ```
192
151
 
193
- Configuration settings can be applied in three formats, which are completely equivalent:
152
+ ## Advanced Configuration
194
153
 
195
- - The most common way is to configure it directly in your start block:
196
- ```ruby
197
- RSpecTracer.start do
198
- config_option 'foo'
199
- end
200
- ```
201
- - You can also set all configuration options directly:
202
- ```ruby
203
- RSpecTracer.config_option 'foo'
204
- ```
154
+ Configuration settings must be defined in **`.rspec-tracer`** file:
155
+ ```ruby
156
+ RSpecTracer.configure do
157
+ config_option 'foo'
158
+ end
159
+ ```
205
160
 
206
- - If you do not want to start tracer immediately after launch or want to add
207
- additional configuration later on in a concise way, use:
208
- ```ruby
209
- RSpecTracer.configure do
210
- config_option 'foo'
211
- end
212
- ```
161
+ You can additionally define a global config file `~/.rspec-tracer` to share the
162
+ common settings across projects.
213
163
 
214
- The available configuration options are:
164
+ ### Available Settings
215
165
 
216
166
  - **`root dir`** to set the project root. The default value is the current working
217
167
  directory.
218
- - **`add_filter filter`** to apply [filters](#filters) on the source files to
219
- exclude them from the dependent files list.
220
- - **`filters.clear`** to remove the default configured dependent files filters.
221
- - **`add_coverage_filter filter`** to apply [filters](#filters) on the source files
222
- to exclude them from the coverage report.
223
- - **`coverage_filters.clear`** to remove the default configured coverage files filters.
168
+
169
+ - **`project_name name`** to set the project name. The default value is the last
170
+ part of the project root directory.
171
+
172
+ - **`cache_dir dir`** to set the cache directory. The default value is `./rspec_tracer_cache`.
173
+ You can also set the **`RSPEC_TRACER_CACHE_DIR`** environment variable.
174
+
175
+ - **`coverage_dir dir`** to set the coverage reports directory. The default is the
176
+ `./rspec_tracer_coverage`. You can also set the **`RSPEC_TRACER_COVERAGE_DIR`**
177
+ environment variable.
178
+
179
+ - **`report_dir dir`** to set the HTML reports directory. The default is the
180
+ `./rspec_tracer_report`. You can also set the **`RSPEC_TRACER_REPORT_DIR`**
181
+ environment variable.
182
+
183
+ - **`reports_s3_path uri`** to set the AWS S3 URI for all the reports from the current
184
+ run. You can also set the **`RSPEC_TRACER_REPORTS_S3_PATH`** environment variable.
185
+
186
+ - **`use_local_aws bool_flag`** to use the `awslocal` AWS CLI with `LocalStack`. You can
187
+ also set the **`RSPEC_TRACER_USE_LOCAL_AWS`** environment variable.
188
+
189
+ - **`upload_non_ci_reports bool_flag`** to upload execution reports in a non-CI
190
+ environment. You can also set the **`RSPEC_TRACER_UPLOAD_NON_CI_REPORTS`** environment
191
+ variable.
192
+
193
+ - **`run_all_examples bool_flag`** to always run all the examples irrespective of cache.
194
+ You can also set the **`RSPEC_TRACER_RUN_ALL_EXAMPLES`** environment variable.
195
+
196
+ - **`fail_on_duplicates bool_flag`** to fail with a non-zero exit code in case of
197
+ duplicate examples. The default value is `true`. You can also set the **`RSPEC_TRACER_FAIL_ON_DUPLICATES`**
198
+ environment variable.
199
+
200
+ - **`lock_file file`** to set the lock file when executing with `parallel_tests`. The default
201
+ value is `./rspec_tracer.lock`. You can also set the **`RSPEC_TRACER_LOCK_FILE`** environment
202
+ variable.
203
+
204
+ - **`log_level level`** to set the log level. The default value is `info`. The possible
205
+ values are `off`, `debug`, `info`, `warn`, and `error`. You can also set the
206
+ **`RSPEC_TRACER_LOG_LEVEL`** environment variable.
207
+
208
+ - **`add_filter filter`** to apply filters on the source files to exclude them
209
+ from the dependent files list.
210
+
211
+ - **`filters.clear`** to remove the configured dependent files filters so far.
212
+
213
+ - **`add_coverage_filter filter`** to apply filters on the source files to exclude
214
+ them from the coverage report.
215
+
216
+ - **`coverage_filters.clear`** to remove the configured coverage files filters so far.
217
+
224
218
  - **`coverage_track_files glob`** to include files in the given glob pattern in
225
219
  the coverage report if these files are not already present.
226
220
 
227
221
  ```ruby
228
- RSpecTracer.start do
222
+ RSpecTracer.configure do
229
223
  # Configure project root
230
224
  root '/tmp/my_project'
231
225
 
@@ -244,25 +238,6 @@ RSpecTracer.start do
244
238
  end
245
239
  ```
246
240
 
247
- You can configure the RSpec Tracer reports directories using the following environment
248
- variables:
249
-
250
- - **`RSPEC_TRACER_CACHE_DIR`** to update the default cache directory (`rspec_tracer_cache`).
251
- ```sh
252
- export RSPEC_TRACER_CACHE_DIR=/tmp/rspec_tracer_cache
253
- ```
254
- - **`RSPEC_TRACER_COVERAGE_DIR`** to update the default coverage directory (`rspec_tracer_coverage`).
255
- ```sh
256
- export RSPEC_TRACER_COVERAGE_DIR=/tmp/rspec_tracer_coverage
257
- ```
258
- - **`RSPEC_TRACER_REPORT_DIR`** to update the default html reports directory (`rspec_tracer_report`).
259
- ```sh
260
- export RSPEC_TRACER_REPORT_DIR=/tmp/rspec_tracer_report
261
- ```
262
-
263
- These settings are available through environment variables because the rake tasks
264
- to download and upload the cache files need to use the same directories.
265
-
266
241
  ## Filters
267
242
 
268
243
  By default, RSpec Tracer ignores all the files outside of the project root directory -
@@ -270,6 +245,8 @@ otherwise you would end up with the source files in the gems you are using in th
270
245
  project. It also applies the following filters:
271
246
  ```ruby
272
247
  RSpecTracer.configure do
248
+ log_level 'warn'
249
+
273
250
  add_filter '/vendor/bundle/'
274
251
 
275
252
  add_coverage_filter %w[
@@ -292,7 +269,7 @@ a block or by passing in your own Filter class.
292
269
  in their name. For example, the following string filter will remove all files that
293
270
  have `"/helpers/"` in their name.
294
271
  ```ruby
295
- RSpecTracer.start do
272
+ RSpecTracer.configure do
296
273
  add_filter '/helpers/'
297
274
  end
298
275
  ```
@@ -301,7 +278,7 @@ have `"/helpers/"` in their name.
301
278
  match against the given regex expression. This simple regex filter will remove
302
279
  all files that start with `%r{^/helper/}` in their name:
303
280
  ```ruby
304
- RSpecTracer.start do
281
+ RSpecTracer.configure do
305
282
  add_filter %r{^/helpers/}
306
283
  end
307
284
  ```
@@ -311,7 +288,7 @@ to return either **true** (if the file is to be removed from the result) or **fa
311
288
  (if the result should be kept). In the below example, the filter will remove all
312
289
  files that match `"/helpers/"` in their path.
313
290
  ```ruby
314
- RSpecTracer.start do
291
+ RSpecTracer.configure do
315
292
  add_filter do |source_file|
316
293
  source_file[:file_path].include?('/helpers/')
317
294
  end
@@ -323,50 +300,11 @@ files that match `"/helpers/"` in their path.
323
300
 
324
301
  - **Array Filter**: You can pass in an array containing any of the other filter types:
325
302
  ```ruby
326
- RSpecTracer.start do
303
+ RSpecTracer.configure do
327
304
  add_filter ['/helpers/', %r{^/utils/}]
328
305
  end
329
306
  ```
330
307
 
331
- ## Environment Variables
332
-
333
- To get better control on execution, you can use the following environment variables
334
- whenever required.
335
-
336
- - **`LOCAL_AWS (default: false)`:** In case you want to test out the caching feature in the local
337
- development environment. You can install [localstack](https://github.com/localstack/localstack)
338
- and [awscli-local](https://github.com/localstack/awscli-local) and then invoke the
339
- rake tasks with `LOCAL_AWS=true`.
340
-
341
- - **`RSPEC_TRACER_FAIL_ON_DUPLICATES (default: true)`:** By default, RSpec Tracer
342
- exits with one if there are [duplicate examples](#duplicate-examples).
343
-
344
- - **`RSPEC_TRACER_NO_SKIP (default: false)`:** Use this environment variables to
345
- not skip any tests. Note that it will continue to maintain cache files and generate
346
- reports.
347
-
348
- - **`RSPEC_TRACER_UPLOAD_LOCAL_CACHE (default: false)`:** By default, RSpec Tracer
349
- does not upload local cache files. You can set this environment variable to `true`
350
- to upload the local cache to S3.
351
-
352
- - **`RSPEC_TRACER_VERBOSE (default: false)`:** To print the intermediate steps
353
- and time taken, use this environment variable.
354
-
355
- - **`TEST_SUITES`:** Set this environment variable when running parallel builds
356
- in the CI. It determines the total number of different test suites you are running.
357
- ```sh
358
- export TEST_SUITES=8
359
- ```
360
-
361
- - **`TEST_SUITE_ID`:** If you have a large set of tests to run, it is recommended
362
- to run them in separate groups. This way, RSpec Tracer is not overwhelmed with
363
- loading massive cached data in the memory. Also, it generates and uses cache for
364
- specific test suites and not merge them.
365
- ```sh
366
- TEST_SUITE_ID=1 bundle exec rspec spec/models
367
- TEST_SUITE_ID=2 bundle exec rspec spec/helpers
368
- ```
369
-
370
308
  ## Duplicate Examples
371
309
 
372
310
  To uniquely identify the examples is one of the requirements for the correctness
@@ -478,6 +416,59 @@ RSpec tracer could not uniquely identify the following 10 examples:
478
416
  * Calculator#sub performs subtraction (spec/calculator_spec.rb:24)
479
417
  ```
480
418
 
419
+ ## Demo
420
+
421
+ **First Run**
422
+ ![](./readme_files/first_run.gif)
423
+
424
+ **Next Run**
425
+ ![](./readme_files/next_run.gif)
426
+
427
+ You get the following three reports:
428
+
429
+ ### All Examples Report
430
+
431
+ These reports provide basic test information:
432
+
433
+ **First Run**
434
+
435
+ ![](./readme_files/examples_report_first_run.png)
436
+
437
+ **Next Run**
438
+
439
+ ![](./readme_files/examples_report_next_run.png)
440
+
441
+ ### Duplicate Examples Report
442
+
443
+ These reports provide duplicate tests information.
444
+
445
+ ![](./readme_files/duplicate_examples_report.png)
446
+
447
+ ### Flaky Examples Report
448
+
449
+ These reports provide flaky tests information. Assuming **the following two tests
450
+ failed in the first run.**
451
+
452
+ **Next Run**
453
+
454
+ ![](./readme_files/flaky_examples_report_first_run.png)
455
+
456
+ **Another Run**
457
+
458
+ ![](./readme_files/flaky_examples_report_next_run.png)
459
+
460
+ ### Examples Dependency Report
461
+
462
+ These reports show a list of dependent files for each test.
463
+
464
+ ![](./readme_files/examples_dependency_report.png)
465
+
466
+ ### Files Dependency Report
467
+
468
+ These reports provide information on the total number of tests that will run after changing this particular file.
469
+
470
+ ![](./readme_files/files_dependency_report.png)
471
+
481
472
  ## Contributing
482
473
 
483
474
  Read the [contribution guide](https://github.com/avmnu-sng/rspec-tracer/blob/main/.github/CONTRIBUTING.md).
@@ -15,8 +15,28 @@ module RSpecTracer
15
15
  @flaky_examples = Set.new
16
16
  @failed_examples = Set.new
17
17
  @pending_examples = Set.new
18
+ @skipped_examples = Set.new
18
19
  @all_files = {}
19
20
  @dependency = Hash.new { |hash, key| hash[key] = Set.new }
21
+ @examples_coverage = {}
22
+ end
23
+
24
+ # Public populate-from-disk surface for ReportMerger. Replaces ten
25
+ # separate `cache.send(:load_*_cache, ...)` pokes at the private
26
+ # interface with a single contract.
27
+ def populate_from_disk(cache_dir, discard_run_reason: true)
28
+ load_all_examples_cache(cache_dir, discard_run_reason: discard_run_reason)
29
+ load_duplicate_examples_cache(cache_dir)
30
+ load_interrupted_examples_cache(cache_dir)
31
+ load_flaky_examples_cache(cache_dir)
32
+ load_failed_examples_cache(cache_dir)
33
+ load_pending_examples_cache(cache_dir)
34
+ load_skipped_examples_cache(cache_dir)
35
+ load_all_files_cache(cache_dir)
36
+ load_dependency_cache(cache_dir)
37
+ load_examples_coverage_cache(cache_dir)
38
+
39
+ self
20
40
  end
21
41
 
22
42
  def load_cache_for_run
@@ -46,27 +66,29 @@ module RSpecTracer
46
66
 
47
67
  elapsed = RSpecTracer::TimeFormatter.format_time(ending - starting)
48
68
 
49
- puts "RSpec tracer loaded cache from #{cache_dir} (took #{elapsed})"
69
+ RSpecTracer.logger.debug "RSpec tracer loaded cache from #{cache_dir} (took #{elapsed})"
50
70
  end
51
71
 
52
72
  def cached_examples_coverage
53
- return @examples_coverage if defined?(@examples_coverage)
73
+ return @examples_coverage if @examples_coverage_loaded
74
+
75
+ @examples_coverage_loaded = true
54
76
 
55
77
  cache_path = RSpecTracer.cache_path
56
78
  cache_path = File.dirname(cache_path) if RSpecTracer.parallel_tests?
57
79
  run_id = last_run_id(cache_path)
58
80
 
59
- return @examples_coverage = {} if run_id.nil?
81
+ return @examples_coverage if run_id.nil?
60
82
 
61
83
  starting = Process.clock_gettime(Process::CLOCK_MONOTONIC)
62
84
  cache_dir = File.join(cache_path, run_id)
63
- coverage = load_examples_coverage_cache(cache_dir)
85
+ load_examples_coverage_cache(cache_dir)
64
86
  ending = Process.clock_gettime(Process::CLOCK_MONOTONIC)
65
87
  elapsed = RSpecTracer::TimeFormatter.format_time(ending - starting)
66
88
 
67
- puts "RSpec tracer loaded cached examples coverage (took #{elapsed})" if RSpecTracer.verbose?
89
+ RSpecTracer.logger.debug "RSpec tracer loaded cached examples coverage (took #{elapsed})"
68
90
 
69
- coverage
91
+ @examples_coverage
70
92
  end
71
93
 
72
94
  private