rspec-tracer 1.0.1 → 1.1.0
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/CHANGELOG.md +47 -76
- data/README.md +152 -161
- data/lib/rspec_tracer/cache.rb +32 -13
- data/lib/rspec_tracer/configuration.rb +169 -30
- data/lib/rspec_tracer/coverage_merger.rb +1 -2
- data/lib/rspec_tracer/coverage_reporter.rb +1 -1
- data/lib/rspec_tracer/coverage_writer.rb +2 -2
- data/lib/rspec_tracer/defaults.rb +0 -11
- data/lib/rspec_tracer/html_reporter/reporter.rb +2 -2
- data/lib/rspec_tracer/load_config.rb +15 -0
- data/lib/rspec_tracer/load_default_config.rb +38 -0
- data/lib/rspec_tracer/load_global_config.rb +33 -0
- data/lib/rspec_tracer/load_local_config.rb +17 -0
- data/lib/rspec_tracer/logger.rb +25 -0
- data/lib/rspec_tracer/remote_cache/Rakefile +8 -9
- data/lib/rspec_tracer/remote_cache/aws.rb +11 -19
- data/lib/rspec_tracer/remote_cache/cache.rb +7 -11
- data/lib/rspec_tracer/remote_cache/repo.rb +86 -51
- data/lib/rspec_tracer/remote_cache/validator.rb +2 -4
- data/lib/rspec_tracer/report_generator.rb +2 -2
- data/lib/rspec_tracer/report_merger.rb +2 -15
- data/lib/rspec_tracer/report_writer.rb +21 -21
- data/lib/rspec_tracer/reporter.rb +1 -1
- data/lib/rspec_tracer/rspec_reporter.rb +2 -4
- data/lib/rspec_tracer/rspec_runner.rb +24 -6
- data/lib/rspec_tracer/runner.rb +15 -39
- data/lib/rspec_tracer/source_file.rb +1 -9
- data/lib/rspec_tracer/version.rb +1 -1
- data/lib/rspec_tracer.rb +42 -58
- metadata +12 -19
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b7f283b4a6ab3d0d2616f7dca4bac721906d36b4296ba1d64446937db1503dd5
|
|
4
|
+
data.tar.gz: 2922f96420e344603a472b4e67bb5f2c58c16e8bf798e13098eec8f8096434c5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 222031b5d7b0a6b01cad104fda83347a9e10af957c7a5d1dfede9f46cf8a275435c3e0c9dfb02ad7788b3dfc2d4c3b9513a60ee3ccf0d3bfd68a692758a38f1e
|
|
7
|
+
data.tar.gz: f2828567b26b580ffc66568f8b14581cb160f4bdf14a61622b605b5832d5d3bc86cff211190628c5480604f0ec1c758609ec8aa490b357016e3565615c635be2
|
data/CHANGELOG.md
CHANGED
|
@@ -1,83 +1,54 @@
|
|
|
1
|
-
## [1.0
|
|
1
|
+
## [1.1.0] - 2026-04-20
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
3.
|
|
3
|
+
### Added
|
|
4
|
+
|
|
5
|
+
- Ruby 3.1, 3.2, 3.3, 3.4, 4.0 are now CI-gated.
|
|
6
|
+
- Rails 7.0, 7.1, 7.2 are CI-gated via a reference sample app.
|
|
7
|
+
- Regression specs for four crash bugs (B1–B4) under
|
|
8
|
+
`spec/lib/rspec_tracer/`.
|
|
6
9
|
|
|
7
10
|
### Fixed
|
|
8
11
|
|
|
9
|
-
- `Cache#cached_examples_coverage` returns `{}` (not `nil`)
|
|
10
|
-
is present but `examples_coverage.json` is
|
|
11
|
-
|
|
12
|
-
- `Runner#generate_missed_coverage` tolerates a nil cached
|
|
13
|
-
nil
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
`.json.backup`) no longer match as cache files. (from v1.2.0)
|
|
50
|
-
- `RemoteCache::Repo#initialize` guards `ENV['GIT_BRANCH']` for nil
|
|
51
|
-
before calling `.chomp`; previously a `NoMethodError: undefined
|
|
52
|
-
method 'chomp' for nil:NilClass` crashed the init path and masked
|
|
53
|
-
the intended `RepoError` message when `GIT_BRANCH` was not set in
|
|
54
|
-
the environment. (from v1.1.0 PR #51)
|
|
55
|
-
- `RemoteCache::Repo#download_branch_refs` uses `FileUtils.rm_f`
|
|
56
|
-
(not `File.rm_f`) to clean up a partial `branch_refs.json` on a
|
|
57
|
-
failed AWS download. `File.rm_f` is undefined — `rm_f` is a
|
|
58
|
-
FileUtils method — so the failing-download branch would crash with
|
|
59
|
-
`NoMethodError` instead of cleaning up and logging. (from v1.1.0
|
|
60
|
-
PR #65)
|
|
61
|
-
|
|
62
|
-
### Note on exclusions
|
|
63
|
-
|
|
64
|
-
The following items from 1.1.x / 1.2.0 are intentionally NOT in this
|
|
65
|
-
release to preserve the 1.0.0 cache-format contract and Ruby 2.5+ floor:
|
|
66
|
-
|
|
67
|
-
- Default-filter expansion (1.1.0 — adds `/lib/rspec_tracer/`,
|
|
68
|
-
`/usr/local/lib/ruby/`, etc. to the default filters). Changing the
|
|
69
|
-
default filter set shifts the files present in `all_files.json` for
|
|
70
|
-
most users, which would invalidate existing caches on upgrade.
|
|
71
|
-
- `USE_TEST_SUITE_ID_CACHE` opt-in ENV flag (1.2.0). This is a new
|
|
72
|
-
feature, not a bug fix; users who want it can upgrade to 1.2.x.
|
|
73
|
-
- The 1.1+ configuration DSL refactor (anonymous block forwarding,
|
|
74
|
-
alias_method wrapping, ENV.fetch normalizations). These are
|
|
75
|
-
Ruby-3.1-exclusive in places and orthogonal to the crash-fix scope.
|
|
76
|
-
|
|
77
|
-
### Ruby support
|
|
78
|
-
|
|
79
|
-
Gemspec `required_ruby_version` unchanged at `>= 2.5.0`. CI gates
|
|
80
|
-
Ruby 2.5 - 4.0 inclusive on `ubuntu-latest`.
|
|
12
|
+
- **B1** — `Cache#cached_examples_coverage` returns `{}` (not `nil`)
|
|
13
|
+
when `last_run.json` is present but `examples_coverage.json` is
|
|
14
|
+
missing; previously this leaked nil into the missed-coverage merge.
|
|
15
|
+
- **B2** — `Runner#generate_missed_coverage` tolerates a nil cached
|
|
16
|
+
coverage map and nil line-strength entries; both are treated as
|
|
17
|
+
empty / zero.
|
|
18
|
+
- **B3** — `Runner#register_{file,example_file}_dependency` skips
|
|
19
|
+
(logs debug, returns false) when `SourceFile.from_path` /
|
|
20
|
+
`.from_name` cannot resolve the file (e.g. gem-generated examples
|
|
21
|
+
or files deleted between runs).
|
|
22
|
+
- **B4** — `CoverageReporter#merge_coverage` treats nil existing
|
|
23
|
+
line coverage as 0 when summing skipped-test contributions.
|
|
24
|
+
- Custom filter and coverage-filter blocks now reach
|
|
25
|
+
`RSpecTracer::Filter.register` — the DSL wrappers were dropping
|
|
26
|
+
the block, causing `add_filter { |sf| … }` to raise
|
|
27
|
+
`ArgumentError`.
|
|
28
|
+
- `load_global_config.rb` wraps `Dir.home` / `Etc.getpwuid.dir` /
|
|
29
|
+
`File.expand_path("~user")` in `rescue ArgumentError` so gem
|
|
30
|
+
load never crashes in minimal containers where HOME is unset and
|
|
31
|
+
the passwd database has no matching entry.
|
|
32
|
+
|
|
33
|
+
### Changed
|
|
34
|
+
|
|
35
|
+
- **Behavior change (default filters)** — the default dependency
|
|
36
|
+
and coverage filter lists now exclude Ruby installation /
|
|
37
|
+
toolchain paths: `/lib/rspec_tracer/`, `/lib/rspec_tracer.rb`,
|
|
38
|
+
`/usr/local/lib/ruby/`, `/usr/local/bundle/`,
|
|
39
|
+
`/opt/hostedtoolcache/`, `/.rbenv/versions/`,
|
|
40
|
+
`/.asdf/installs/ruby/`, `/.rvm/`. Previously only
|
|
41
|
+
`/vendor/bundle/` was filtered. A test that previously recorded
|
|
42
|
+
a dependency on a gem file or Ruby stdlib file (because of a
|
|
43
|
+
custom install path like rbenv or asdf) will no longer record
|
|
44
|
+
that dependency — those paths are handled by `Gemfile.lock` /
|
|
45
|
+
the Ruby version file, not by coverage tracking. If you relied
|
|
46
|
+
on the old narrow default, add your own `add_filter` /
|
|
47
|
+
`add_coverage_filter` to clear the extras.
|
|
48
|
+
|
|
49
|
+
### Removed
|
|
50
|
+
|
|
51
|
+
- Support for Ruby ≤ 3.0 and Rails ≤ 6.x (EOL).
|
|
81
52
|
|
|
82
53
|
## [1.0.0] - 2021-10-21
|
|
83
54
|
|
data/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|

|
|
2
2
|
|
|
3
|
-
[](https://codeclimate.com/github/avmnu-sng/rspec-tracer/maintainability)
|
|
5
|
-
[](https://codeclimate.com/github/avmnu-sng/rspec-tracer/test_coverage)
|
|
3
|
+
[](https://www.codetriage.com/avmnu-sng/rspec-tracer)
|
|
6
4
|
[](https://badge.fury.io/rb/rspec-tracer)
|
|
7
5
|
|
|
6
|
+

|
|
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.
|
|
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)**
|
|
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
|
|
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
|
-

|
|
50
|
-
|
|
51
|
-
**Next Run**
|
|
52
|
-

|
|
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
|
-

|
|
63
|
-
|
|
64
|
-
**Next Run**
|
|
65
|
-
|
|
66
|
-

|
|
67
|
-
|
|
68
|
-
### Duplicate Examples Report
|
|
69
|
-
|
|
70
|
-
These reports provide duplicate tests information.
|
|
71
|
-
|
|
72
|
-

|
|
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
|
-

|
|
82
|
-
|
|
83
|
-
**Another Run**
|
|
84
|
-
|
|
85
|
-

|
|
86
|
-
|
|
87
|
-
### Examples Dependency Report
|
|
88
|
-
|
|
89
|
-
These reports show a list of dependent files for each test.
|
|
90
|
-
|
|
91
|
-

|
|
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
|
-

|
|
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
|
|
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
|
-
|
|
110
|
-
/
|
|
111
|
-
/
|
|
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
|
|
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
|
|
109
|
+
rm -f rspec_tracer.lock && bundle exec parallel_rspec
|
|
161
110
|
```
|
|
162
111
|
|
|
163
|
-
## Configuring CI
|
|
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
|
|
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
|
-
|
|
137
|
+
|
|
138
|
+
- **`TEST_SUITES`** is the total number of different test suites you are running.
|
|
187
139
|
```sh
|
|
188
|
-
export
|
|
140
|
+
export TEST_SUITES=8
|
|
189
141
|
```
|
|
190
142
|
|
|
191
|
-
|
|
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
|
-
|
|
152
|
+
## Advanced Configuration
|
|
194
153
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
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
|
-
|
|
207
|
-
|
|
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
|
-
|
|
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
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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
|
+

|
|
423
|
+
|
|
424
|
+
**Next Run**
|
|
425
|
+

|
|
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
|
+

|
|
436
|
+
|
|
437
|
+
**Next Run**
|
|
438
|
+
|
|
439
|
+

|
|
440
|
+
|
|
441
|
+
### Duplicate Examples Report
|
|
442
|
+
|
|
443
|
+
These reports provide duplicate tests information.
|
|
444
|
+
|
|
445
|
+

|
|
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
|
+

|
|
455
|
+
|
|
456
|
+
**Another Run**
|
|
457
|
+
|
|
458
|
+

|
|
459
|
+
|
|
460
|
+
### Examples Dependency Report
|
|
461
|
+
|
|
462
|
+
These reports show a list of dependent files for each test.
|
|
463
|
+
|
|
464
|
+

|
|
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
|
+

|
|
471
|
+
|
|
481
472
|
## Contributing
|
|
482
473
|
|
|
483
474
|
Read the [contribution guide](https://github.com/avmnu-sng/rspec-tracer/blob/main/.github/CONTRIBUTING.md).
|