test-prof 0.11.3 → 0.12.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 +4 -4
- data/CHANGELOG.md +97 -448
- data/LICENSE.txt +1 -1
- data/README.md +9 -13
- data/lib/minitest/test_prof_plugin.rb +3 -0
- data/lib/test_prof/before_all.rb +0 -4
- data/lib/test_prof/cops/rspec/aggregate_examples/its.rb +1 -1
- data/lib/test_prof/cops/rspec/aggregate_examples/line_range_helpers.rb +1 -1
- data/lib/test_prof/cops/rspec/aggregate_examples/matchers_with_side_effects.rb +1 -1
- data/lib/test_prof/cops/rspec/aggregate_examples/metadata_helpers.rb +1 -1
- data/lib/test_prof/cops/rspec/aggregate_examples/node_matchers.rb +1 -1
- data/lib/test_prof/cops/rspec/aggregate_examples.rb +2 -2
- data/lib/test_prof/event_prof/instrumentations/active_support.rb +22 -4
- data/lib/test_prof/ext/active_record_3.rb +1 -1
- data/lib/test_prof/recipes/minitest/sample.rb +6 -10
- data/lib/test_prof/recipes/rspec/before_all.rb +1 -9
- data/lib/test_prof/recipes/rspec/let_it_be.rb +108 -11
- data/lib/test_prof/recipes/rspec/sample.rb +4 -2
- data/lib/test_prof/stack_prof.rb +3 -0
- data/lib/test_prof/version.rb +1 -1
- metadata +15 -15
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 89c1d2f72a772c731bcb32ee68a21129e82a003a40a194f6a503a31e5b445954
|
|
4
|
+
data.tar.gz: 6ed48924861ec8523a083ba853bf5de43579df0624f95e003ca6d417c9b4e076
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7c62484546cda02e28ce819790cb3479004a970dc1c88849eb7ff3e55114b71710774f0dbc2ce7d4874036a5513f10585c3c4d805db05a75c93acb69a36436cb
|
|
7
|
+
data.tar.gz: 4b6d8438fff041a84975c52428f50a03d9f4519a08a2884a35ae45bb43df4c11fa7f375a041477928a1009610dd0dc96d1e702ba6728eb4a2db8a6e147c3119b
|
data/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,47 @@
|
|
|
1
1
|
# Change log
|
|
2
2
|
|
|
3
|
-
## master (
|
|
3
|
+
## master (unrealeased)
|
|
4
|
+
|
|
5
|
+
## 0.12.1 (2020-09-01)
|
|
6
|
+
|
|
7
|
+
- Minor improvements.
|
|
8
|
+
|
|
9
|
+
## 0.12.0 (2020-07-17)
|
|
10
|
+
|
|
11
|
+
- Add state leakage detection for `let_it_be`. ([@pirj][], [@jaimerson][], [@alexvko][])
|
|
12
|
+
|
|
13
|
+
- Add default let_it_be modifiers configuration. ([@palkan][])
|
|
14
|
+
|
|
15
|
+
You can configure global modifiers:
|
|
16
|
+
|
|
17
|
+
```ruby
|
|
18
|
+
TestProf::LetItBe.configure do |config|
|
|
19
|
+
# Make refind activated by default
|
|
20
|
+
config.default_modifiers[:refind] = true
|
|
21
|
+
end
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Or for specific contexts via tags:
|
|
25
|
+
|
|
26
|
+
```ruby
|
|
27
|
+
context "with let_it_be reload", let_it_be_modifiers: {reload: true} do
|
|
28
|
+
# examples
|
|
29
|
+
end
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
- **Drop Ruby 2.4 support.** ([@palkan][])
|
|
33
|
+
|
|
34
|
+
- SAMPLE and SAMPLE_GROUP work consistently with seed in RSpec and Minitest. ([@stefkin][])
|
|
35
|
+
|
|
36
|
+
- Make sure EventProf is not affected by time freezing. ([@palkan][])
|
|
37
|
+
|
|
38
|
+
EventProf results now is not affected by `Timecop.freeze` or similar.
|
|
39
|
+
|
|
40
|
+
See more in [#181](https://github.com/test-prof/test-prof/issues/181).
|
|
41
|
+
|
|
42
|
+
- Adds the ability to define stackprof's interval sampling by using `TEST_STACK_PROF_INTERVAL` env variable ([@LynxEyes][])
|
|
43
|
+
|
|
44
|
+
Now you can use `$ TEST_STACK_PROF=1 TEST_STACK_PROF_INTERVAL=10000 rspec` to define a custom interval (in microseconds).
|
|
4
45
|
|
|
5
46
|
## 0.11.3 (2020-02-11)
|
|
6
47
|
|
|
@@ -14,7 +55,7 @@
|
|
|
14
55
|
|
|
15
56
|
- Add `config/` to the gem contents. ([@palkan][])
|
|
16
57
|
|
|
17
|
-
|
|
58
|
+
Fixes RuboCop integration regression from 0.11.0.
|
|
18
59
|
|
|
19
60
|
## 0.11.0 (2020-02-09)
|
|
20
61
|
|
|
@@ -40,33 +81,33 @@
|
|
|
40
81
|
|
|
41
82
|
- Use RSpec example ID instead of full description for RubyProf/Stackprof report names. ([@palkan][])
|
|
42
83
|
|
|
43
|
-
|
|
84
|
+
For more complex scenarios feel free to use your own report name generator:
|
|
44
85
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
86
|
+
```ruby
|
|
87
|
+
# for RubyProf
|
|
88
|
+
TestProf::RubyProf::Listener.report_name_generator = ->(example) { "..." }
|
|
89
|
+
# for Stackprof
|
|
90
|
+
TestProf::StackProf::Listener.report_name_generator = ->(example) { "..." }
|
|
91
|
+
```
|
|
51
92
|
|
|
52
93
|
- Support arrays in `let_it_be` with modifiers. ([@palkan][])
|
|
53
94
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
95
|
+
```ruby
|
|
96
|
+
# Now you can use modifiers with arrays
|
|
97
|
+
let_it_be(:posts, reload: true) { create_pair(:post) }
|
|
98
|
+
```
|
|
58
99
|
|
|
59
100
|
- Refactor `let_it_be` modifiers and allow adding custom modifiers. ([@palkan][])
|
|
60
101
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
102
|
+
```ruby
|
|
103
|
+
TestProf::LetItBe.config.register_modifier :reload do |record, val|
|
|
104
|
+
# ignore when `reload: false`
|
|
105
|
+
next record unless val
|
|
106
|
+
# ignore non-ActiveRecord objects
|
|
107
|
+
next record unless record.is_a?(::ActiveRecord::Base)
|
|
108
|
+
record.reload
|
|
109
|
+
end
|
|
110
|
+
```
|
|
70
111
|
|
|
71
112
|
- Print warning when `ActiveRecordSharedConnection` is used in the version of Rails
|
|
72
113
|
supporting `lock_threads` (5.1+). ([@palkan][])
|
|
@@ -75,450 +116,54 @@ supporting `lock_threads` (5.1+). ([@palkan][])
|
|
|
75
116
|
|
|
76
117
|
- Add threshold and custom event support to FactoryDoctor. ([@palkan][])
|
|
77
118
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
119
|
+
```sh
|
|
120
|
+
$ FDOC=1 FDOC_EVENT="sql.rom" FDOC_THRESHOLD=0.1 rspec
|
|
121
|
+
```
|
|
81
122
|
|
|
82
123
|
- Add Fabrication support to FactoryDoctor. ([@palkan][])
|
|
83
124
|
|
|
84
125
|
- Add `guard` and `top_level` options to `EventProf::Monitor`. ([@palkan][])
|
|
85
126
|
|
|
86
|
-
|
|
127
|
+
For example:
|
|
87
128
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
129
|
+
```ruby
|
|
130
|
+
TestProf::EventProf.monitor(
|
|
131
|
+
Sidekiq::Client,
|
|
132
|
+
"sidekiq.inline",
|
|
133
|
+
:raw_push,
|
|
134
|
+
top_level: true,
|
|
135
|
+
guard: ->(*) { Sidekiq::Testing.inline? }
|
|
136
|
+
)
|
|
137
|
+
```
|
|
97
138
|
|
|
98
139
|
- Add global `before_all` hooks. ([@danielwaterworth][], [@palkan][])
|
|
99
140
|
|
|
100
|
-
|
|
101
|
-
|
|
141
|
+
Now you can run additional code before and after every `before_all` transaction
|
|
142
|
+
begins and rollbacks:
|
|
102
143
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
144
|
+
```ruby
|
|
145
|
+
TestProf::BeforeAll.configure do |config|
|
|
146
|
+
config.before(:begin) do
|
|
147
|
+
# do something before transaction opens
|
|
148
|
+
end
|
|
108
149
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
end
|
|
150
|
+
config.after(:rollback) do
|
|
151
|
+
# do something after transaction closes
|
|
112
152
|
end
|
|
113
|
-
|
|
153
|
+
end
|
|
154
|
+
```
|
|
114
155
|
|
|
115
156
|
- Add ability to use `let_it_be` aliases with predefined options. ([@danielwaterworth][])
|
|
116
157
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
158
|
+
```ruby
|
|
159
|
+
TestProf::LetItBe.configure do |config|
|
|
160
|
+
config.alias_to :let_it_be_with_refind, refind: true
|
|
161
|
+
end
|
|
162
|
+
```
|
|
122
163
|
|
|
123
164
|
- Made FactoryProf measure and report on timing ([@danielwaterworth][])
|
|
124
165
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
- **Ruby 2.4+ is requiered** ([@palkan][])
|
|
128
|
-
|
|
129
|
-
- **RSpec 3.5+ is requiered for RSpec features** ([@palkan][])
|
|
130
|
-
|
|
131
|
-
- Make `before_all` compatible with [`isolator`](https://github.com/palkan/isolator). ([@palkan][])
|
|
132
|
-
|
|
133
|
-
- Add `with_logging` and `with_ar_logging` helpers to logging recipe. ([@palkan][])
|
|
134
|
-
|
|
135
|
-
- Make `before_all` for Active Record `lock_thread` aware. ([@palkan][])
|
|
136
|
-
|
|
137
|
-
`before_all` can went crazy if you open multiple connections within it
|
|
138
|
-
(since it tracks the number of open transactions).
|
|
139
|
-
Rails 5+ `lock_thread` feature only locks the connection thread in
|
|
140
|
-
`before`/`setup` hook thus making it possible to have multiple connections/transactions
|
|
141
|
-
in `before_all` (e.g. performing jobs with Active Job async adapter).
|
|
142
|
-
|
|
143
|
-
## 0.7.5 (2019-02-22)
|
|
144
|
-
|
|
145
|
-
- Make `let_it_be` and `before_all` work with `include_context`. ([@palkan][])
|
|
146
|
-
|
|
147
|
-
Fixes [#117](https://github.com/palkan/test-prof/issues/117)
|
|
148
|
-
|
|
149
|
-
## 0.7.4 (2019-02-16)
|
|
150
|
-
|
|
151
|
-
- Add JSON report support for StackProf. ([@palkan][])
|
|
152
|
-
|
|
153
|
-
- Add ability to specify report/artifact name suffixes. ([@palkan][])
|
|
154
|
-
|
|
155
|
-
## 0.7.3 (2018-11-07)
|
|
156
|
-
|
|
157
|
-
- Add a header with the general information on factories usage [#99](https://github.com/palkan/test-prof/issues/99) ([@szemek][])
|
|
158
|
-
|
|
159
|
-
- Improve test sampling.([@mkldon][])
|
|
160
|
-
|
|
161
|
-
```bash
|
|
162
|
-
$ SAMPLE=10 rake test # runs 10 random test examples
|
|
163
|
-
$ SAMPLE_GROUPS=10 rake test # runs 10 random example groups
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
- Extend Event Prof formatter to include the absolute run time and the percentage of the event tim [#100](https://github.com/palkan/test-prof/issues/100) ([@dmagro][])
|
|
167
|
-
|
|
168
|
-
## 0.7.2 (2018-10-08)
|
|
169
|
-
|
|
170
|
-
- Add `RSpec/AggregateFailures` support for non-regular 'its' examples. ([@broels][])
|
|
171
|
-
|
|
172
|
-
## 0.7.1 (2018-08-20)
|
|
173
|
-
|
|
174
|
-
- Add ability to ignore connection configurations in shared connection.([@palkan][])
|
|
175
|
-
|
|
176
|
-
Example:
|
|
177
|
-
|
|
178
|
-
```ruby
|
|
179
|
-
# Do not use shared connection for sqlite db
|
|
180
|
-
TestProf::ActiveRecordSharedConnection.ignore { |config| config[:adapter] == "sqlite3" }
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
## 0.7.0 (2018-08-12)
|
|
184
|
-
|
|
185
|
-
- **Ruby 2.3+ is required**. ([@palkan][])
|
|
186
|
-
|
|
187
|
-
Ruby 2.2 EOL was on 2018-03-31.
|
|
188
|
-
|
|
189
|
-
- Upgrade RubyProf integration to `ruby-prof >= 0.17`. ([@palkan][])
|
|
190
|
-
|
|
191
|
-
Use `exclude_common_methods!` instead of the deprecated `eliminate_methods!`.
|
|
192
|
-
|
|
193
|
-
Add RSpec specific exclusions.
|
|
194
|
-
|
|
195
|
-
Add ability to specify custom exclusions through `config.custom_exclusions`, e.g.:
|
|
196
|
-
|
|
197
|
-
```ruby
|
|
198
|
-
TestProf::RubyProf.configure do |config|
|
|
199
|
-
config.custom_exclusions = {User => %i[save save!]}
|
|
200
|
-
end
|
|
201
|
-
```
|
|
202
|
-
|
|
203
|
-
## 0.6.0 (2018-06-29)
|
|
204
|
-
|
|
205
|
-
### Features
|
|
206
|
-
|
|
207
|
-
- Add `EventProf.monitor` to instrument arbitrary methods. ([@palkan][])
|
|
208
|
-
|
|
209
|
-
Add custom instrumetation easily:
|
|
210
|
-
|
|
211
|
-
```ruby
|
|
212
|
-
class Work
|
|
213
|
-
def do
|
|
214
|
-
# ...
|
|
215
|
-
end
|
|
216
|
-
end
|
|
217
|
-
|
|
218
|
-
# Instrument Work#do calls with "my.work" event
|
|
219
|
-
TestProf::EventProf.monitor(Work, "my.work", :do)
|
|
220
|
-
```
|
|
221
|
-
|
|
222
|
-
[📝 Docs](https://test-prof.evilmartians.io/#/event_prof?id=profile-arbitrary-methods)
|
|
223
|
-
|
|
224
|
-
- Adapterize `before_all`. ([@palkan][])
|
|
225
|
-
|
|
226
|
-
Now it's possible to write your own adapter for `before_all` to manage transactions.
|
|
227
|
-
|
|
228
|
-
[📝 Docs](https://test-prof.evilmartians.io/#/before_all?id=database-adapters)
|
|
229
|
-
|
|
230
|
-
- Add `before_all` for Minitest. ([@palkan][])
|
|
231
|
-
|
|
232
|
-
[📝 Docs](https://test-prof.evilmartians.io/#/before_all?id=minitest-experimental)
|
|
233
|
-
|
|
234
|
-
### Fixes & Improvements
|
|
235
|
-
|
|
236
|
-
- Show top `let` declarations per example group in RSpecDissect profiler. ([@palkan][])
|
|
237
|
-
|
|
238
|
-
The output now includes the following information:
|
|
239
|
-
|
|
240
|
-
```
|
|
241
|
-
Top 5 slowest suites (by `let` time):
|
|
242
|
-
|
|
243
|
-
FunnelsController (./spec/controllers/funnels_controller_spec.rb:3) – 00:38.532 of 00:43.649 (133)
|
|
244
|
-
↳ user – 3
|
|
245
|
-
↳ funnel – 2
|
|
246
|
-
ApplicantsController (./spec/controllers/applicants_controller_spec.rb:3) – 00:33.252 of 00:41.407 (222)
|
|
247
|
-
↳ user – 10
|
|
248
|
-
↳ funnel – 5
|
|
249
|
-
```
|
|
250
|
-
|
|
251
|
-
Enabled by default. Disable it with:
|
|
252
|
-
|
|
253
|
-
```ruby
|
|
254
|
-
TestProf::RSpecDissect.configure do |config|
|
|
255
|
-
config.let_stats_enabled = false
|
|
256
|
-
end
|
|
257
|
-
```
|
|
258
|
-
|
|
259
|
-
- [Fix [#80](https://github.com/palkan/test-prof/issues/80)] Added ability to preserve traits. ([@Vasfed][])
|
|
260
|
-
|
|
261
|
-
Disabled by default for compatibility. Enable globally by `FactoryDefault.preserve_traits = true` or for single `create_default`: `create_default(:user, preserve_traits: true)`
|
|
262
|
-
|
|
263
|
-
When enabled - default object will be used only when there's no [traits](https://github.com/thoughtbot/factory_bot/blob/master/GETTING_STARTED.md#traits) in association.
|
|
264
|
-
|
|
265
|
-
- Add ability to run only `let` or `before` profiler with RSpecDissect. ([@palkan][])
|
|
266
|
-
|
|
267
|
-
- Collect _raw_ data with StackProf by default. ([@palkan][])
|
|
268
|
-
|
|
269
|
-
- Refactor `:with_clean_fixture` to clean data once per group. ([@palkan][])
|
|
270
|
-
|
|
271
|
-
- [Fix [#75](https://github.com/palkan/test-prof/issues/75)] Fix `RSpec/Aggregate` failures with non-regular examples. ([@palkan][])
|
|
272
|
-
|
|
273
|
-
Do not take into account `xit`, `pending`, `its`, etc. examples,
|
|
274
|
-
only consider regular `it`, `specify`, `scenario`, `example`.
|
|
275
|
-
|
|
276
|
-
## 0.5.0 (2018-04-25)
|
|
277
|
-
|
|
278
|
-
### Features
|
|
279
|
-
|
|
280
|
-
- Add events support to TagProf. ([@palkan][])
|
|
281
|
-
|
|
282
|
-
Example usage:
|
|
283
|
-
|
|
284
|
-
```sh
|
|
285
|
-
TAG_PROF=type TAG_PROF_EVENT=sql.active_record rspec
|
|
286
|
-
```
|
|
287
|
-
|
|
288
|
-
[📝 Docs](https://test-prof.evilmartians.io/#/tag_prof?id=profiling-events)
|
|
289
|
-
|
|
290
|
-
- Add logging helpers for Rails. ([@palkan][])
|
|
291
|
-
|
|
292
|
-
Enable verbose logging globally:
|
|
293
|
-
|
|
294
|
-
```sh
|
|
295
|
-
LOG=all rspec
|
|
296
|
-
```
|
|
297
|
-
|
|
298
|
-
Or per example (group):
|
|
299
|
-
|
|
300
|
-
```ruby
|
|
301
|
-
it "does smth weird", :log do
|
|
302
|
-
# ...
|
|
303
|
-
end
|
|
304
|
-
```
|
|
305
|
-
|
|
306
|
-
[📝 Docs](https://test-prof.evilmartians.io/#/logging)
|
|
307
|
-
|
|
308
|
-
- Add HTML report for `TagProf`. ([@palkan][])
|
|
309
|
-
|
|
310
|
-
Generate HTML report by setting `TAG_PROF_FORMAT` to `html`.
|
|
311
|
-
|
|
312
|
-
- Add ability to track multiple events at the same time with `EventProf`. ([@palkan][])
|
|
313
|
-
|
|
314
|
-
- Add `AnyFixture` DSL. ([@palkan][])
|
|
315
|
-
|
|
316
|
-
Example:
|
|
317
|
-
|
|
318
|
-
```ruby
|
|
319
|
-
# Enable DSL
|
|
320
|
-
using TestProf::AnyFixture::DSL
|
|
321
|
-
|
|
322
|
-
# and then you can use `fixture` method (which is just an alias for `TestProf::AnyFixture.register`)
|
|
323
|
-
before(:all) { fixture(:account) }
|
|
324
|
-
|
|
325
|
-
# You can also use it to fetch the record (instead of storing it in instance variable)
|
|
326
|
-
let(:account) { fixture(:account) }
|
|
327
|
-
```
|
|
328
|
-
|
|
329
|
-
[📝 Docs](https://test-prof.evilmartians.io/#/any_fixture?id=dsl)
|
|
330
|
-
|
|
331
|
-
- Add `AnyFixture` usage report. ([@palkan][])
|
|
332
|
-
|
|
333
|
-
Enable `AnyFixture` usage reporting with `ANYFIXTURE_REPORTING=1` or with:
|
|
334
|
-
|
|
335
|
-
```ruby
|
|
336
|
-
TestProf::AnyFixture.reporting_enabled = true
|
|
337
|
-
```
|
|
338
|
-
|
|
339
|
-
[📝 Docs](https://test-prof.evilmartians.io/#/any_fixture?id=usage-report)
|
|
340
|
-
|
|
341
|
-
- Add `ActiveRecordSharedConnection` recipe. ([@palkan][])
|
|
342
|
-
|
|
343
|
-
Force ActiveRecord to use the same connection between threads (to avoid database cleaning in browser tests).
|
|
344
|
-
|
|
345
|
-
[📝 Docs](https://test-prof.evilmartians.io/#/active_record_shared_connection)
|
|
346
|
-
|
|
347
|
-
- [#70](https://github.com/palkan/test-prof/pull/70) Add `FactoryAllStub` recipe. ([@palkan][])
|
|
348
|
-
|
|
349
|
-
[📝 Docs](https://test-prof.evilmartians.io/#/factory_all_stub)
|
|
350
|
-
|
|
351
|
-
- Add `ActiveRecordRefind` refinement. ([@palkan][])
|
|
352
|
-
|
|
353
|
-
[📝 Docs](https://test-prof.evilmartians.io/#/any_fixture?id=activerecordrefind)
|
|
354
|
-
|
|
355
|
-
### Fixes & Improvements
|
|
356
|
-
|
|
357
|
-
- **Brand new documentatation website: https://test-prof.evilmartians.io/**
|
|
358
|
-
|
|
359
|
-
- Disable referential integrity when cleaning AnyFixture. ([@palkan][])
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
## 0.4.9 (2018-03-20)
|
|
363
|
-
|
|
364
|
-
- [Fix [#64](https://github.com/palkan/test-prof/issues/64)] Fix dependencies requiring for FactoryDefault. ([@palkan][])
|
|
365
|
-
|
|
366
|
-
- [Fix [#60](https://github.com/palkan/test-prof/issues/60)] Fix RSpecDissect reporter hooks. ([@palkan][])
|
|
367
|
-
|
|
368
|
-
Consider only `example_failed` and `example_passed` to ensure that the `run_time`
|
|
369
|
-
is available.
|
|
370
|
-
|
|
371
|
-
## 0.4.8 (2018-01-17)
|
|
372
|
-
|
|
373
|
-
- Add `minitest` 5.11 support. ([@palkan][])
|
|
374
|
-
|
|
375
|
-
- Fix `spring` detection. ([@palkan][])
|
|
376
|
-
|
|
377
|
-
Some `spring`-related gems do not check whether Spring is running and load
|
|
378
|
-
Spring modules. Thus we have `Spring` defined (and even `Spring.after_fork` defined) but no-op.
|
|
379
|
-
|
|
380
|
-
Now we require that `Spring::Applcation` is defined in order to rely on Spring.
|
|
381
|
-
|
|
382
|
-
Possibly fixes [#47](https://github.com/palkan/test-prof/issues/47).
|
|
383
|
-
|
|
384
|
-
## 0.4.7 (2017-12-25)
|
|
385
|
-
|
|
386
|
-
- [#57](https://github.com/palkan/test-prof/pull/57) Fix RubyProf Printers Support ([@rabotyaga][])
|
|
387
|
-
|
|
388
|
-
## 0.4.6 (2017-12-17)
|
|
389
|
-
|
|
390
|
-
- Upgrade RSpec/AggregateFailures to RuboCop 0.52.0. ([@palkan][])
|
|
391
|
-
|
|
392
|
-
RuboCop < 0.51.0 is not supported anymore.
|
|
393
|
-
|
|
394
|
-
- [Fixes [#49](https://github.com/palkan/test-prof/issues/49)] Correctly detect RSpec version in `let_it_be`. ([@desoleary][])
|
|
395
|
-
|
|
396
|
-
## 0.4.5 (2017-12-09)
|
|
397
|
-
|
|
398
|
-
- Fix circular require in `lib/factory_doctor/minitest`. ([@palkan][])
|
|
399
|
-
|
|
400
|
-
## 0.4.4 (2017-11-08)
|
|
401
|
-
|
|
402
|
-
- [Fixes [#48](https://github.com/palkan/test-prof/issues/48)] Respect RubyProf reports files extensions. ([@palkan][])
|
|
403
|
-
|
|
404
|
-
## 0.4.3 (2017-10-26)
|
|
405
|
-
|
|
406
|
-
- [#46](https://github.com/palkan/test-prof/pull/46) Support FactoryBot, which is [former FactoryGirl](https://github.com/thoughtbot/factory_bot/pull/1051),
|
|
407
|
-
while maintaining compatibility with latter. ([@Shkrt][])
|
|
408
|
-
|
|
409
|
-
## 0.4.2 (2017-10-23)
|
|
410
|
-
|
|
411
|
-
- Fix bug with multiple `before_all` within one group. ([@palkan][])
|
|
412
|
-
|
|
413
|
-
## 0.4.1 (2017-10-18)
|
|
414
|
-
|
|
415
|
-
- [#44](https://github.com/palkan/test-prof/pull/44) Support older versions of RSpec. ([@palkan][])
|
|
416
|
-
|
|
417
|
-
Support RSpec 3.1.0+ in general.
|
|
418
|
-
|
|
419
|
-
`let_it_be` supports only RSpec 3.3.0+.
|
|
420
|
-
|
|
421
|
-
RSpecDissect `let` tracking supports only RSpec 3.3.0+.
|
|
422
|
-
|
|
423
|
-
- [#38](https://github.com/palkan/test-prof/pull/38) Factory Doctor Minitest integration. ([@IDolgirev][])
|
|
424
|
-
|
|
425
|
-
It is possible now to use Factory Doctor with Minitest
|
|
426
|
-
|
|
427
|
-
## 0.4.0 (2017-10-03)
|
|
428
|
-
|
|
429
|
-
### Features:
|
|
430
|
-
|
|
431
|
-
- [#29](https://github.com/palkan/test-prof/pull/29) EventProf Minitest integration. ([@IDolgirev][])
|
|
432
|
-
|
|
433
|
-
It is possible now to use Event Prof with Minitest
|
|
434
|
-
|
|
435
|
-
- [#30](https://github.com/palkan/test-prof/pull/30) Fabrication support for FactoryProf. ([@Shkrt][])
|
|
436
|
-
|
|
437
|
-
FactoryProf now also accounts objects created by Fabrication gem (in addition to FactoryGirl)
|
|
438
|
-
|
|
439
|
-
## 0.3.0 (2017-09-21)
|
|
440
|
-
|
|
441
|
-
### Features:
|
|
442
|
-
|
|
443
|
-
- Combine RSpecStamp with FactoryDoctor. ([@palkan][])
|
|
444
|
-
|
|
445
|
-
Automatically mark _bad_ examples with custom tags.
|
|
446
|
-
|
|
447
|
-
- [#17](https://github.com/palkan/test-prof/pull/17) Combine RSpecStamp with EventProf and RSpecDissect. ([@palkan][])
|
|
448
|
-
|
|
449
|
-
It is possible now to automatically mark _slow_ examples and groups with custom tags. For example:
|
|
450
|
-
|
|
451
|
-
```sh
|
|
452
|
-
$ EVENT_PROF="sql.active_record" EVENT_PROF_STAMP="slow:sql" rspec ...
|
|
453
|
-
```
|
|
454
|
-
|
|
455
|
-
After running the command above the top 5 slowest example groups would be marked with `slow: :sql` tag.
|
|
456
|
-
|
|
457
|
-
- [#14](https://github.com/palkan/test-prof/pull/14) RSpecDissect profiler. ([@palkan][])
|
|
458
|
-
|
|
459
|
-
RSpecDissect tracks how much time do you spend in `before` hooks and memoization helpers (i.e. `let`) in your tests.
|
|
460
|
-
|
|
461
|
-
- [#13](https://github.com/palkan/test-prof/pull/13) RSpec `let_it_be` method. ([@palkan][])
|
|
462
|
-
|
|
463
|
-
Just like `let`, but persist the result for the whole group (i.e. `let` + `before_all`).
|
|
464
|
-
|
|
465
|
-
### Improvements:
|
|
466
|
-
|
|
467
|
-
- Add ability to specify RubyProf report through `TEST_RUBY_PROF` env variable. ([@palkan][])
|
|
468
|
-
|
|
469
|
-
- Add ability to specify StackProf raw mode through `TEST_STACK_PROF` env variable. ([@palkan][])
|
|
470
|
-
|
|
471
|
-
### Changes
|
|
472
|
-
|
|
473
|
-
- Use RubyProf `FlatPrinter` by default (was `CallStackPrinter`). ([@palkan][])
|
|
474
|
-
|
|
475
|
-
## 0.2.5 (2017-08-30)
|
|
476
|
-
|
|
477
|
-
- [#16](https://github.com/palkan/test-prof/pull/16) Support Ruby >= 2.2.0 (was >= 2.3.0). ([@palkan][])
|
|
478
|
-
|
|
479
|
-
## 0.2.4 (2017-08-29)
|
|
480
|
-
|
|
481
|
-
- EventProf: Fix regression bug with examples profiling. ([@palkan][])
|
|
482
|
-
|
|
483
|
-
There was a bug when an event occurs before the example has started (e.g. in `before(:context)` hook).
|
|
484
|
-
|
|
485
|
-
## 0.2.3 (2017-08-28)
|
|
486
|
-
|
|
487
|
-
- Minor improvements. ([@palkan][])
|
|
488
|
-
|
|
489
|
-
## 0.2.2 (2017-08-23)
|
|
490
|
-
|
|
491
|
-
- Fix time calculation when Time class is monkey-patched. ([@palkan][])
|
|
492
|
-
|
|
493
|
-
Add `TestProf.now` method which is just a copy of original `Time.now` and use it everywhere.
|
|
494
|
-
|
|
495
|
-
Fixes [#10](https://github.com/palkan/test-prof/issues/10).
|
|
496
|
-
|
|
497
|
-
## 0.2.1 (2017-08-19)
|
|
498
|
-
|
|
499
|
-
- Detect `RSpec` by checking the presence of `RSpec::Core`. ([@palkan][])
|
|
500
|
-
|
|
501
|
-
Fixes [#8](https://github.com/palkan/test-prof/issues/8).
|
|
502
|
-
|
|
503
|
-
## 0.2.0 (2017-08-18)
|
|
504
|
-
|
|
505
|
-
- Ensure output directory exists. ([@danielwestendorf][])
|
|
506
|
-
|
|
507
|
-
**Change default output dir** to "tmp/test_prof".
|
|
508
|
-
|
|
509
|
-
Rename `#artefact_path` to `#artifact_path` to be more US-like
|
|
510
|
-
|
|
511
|
-
Ensure output dir exists in `#artifact_path` method.
|
|
512
|
-
|
|
513
|
-
- FactoryDoctor: print success message when no bad examples found. ([@palkan][])
|
|
514
|
-
|
|
515
|
-
## 0.1.1 (2017-08-17)
|
|
516
|
-
|
|
517
|
-
- AnyFixture: clean tables in reverse order to not fail when foreign keys exist. ([@marshall-lee][])
|
|
518
|
-
|
|
519
|
-
## 0.1.0 (2017-08-15)
|
|
520
|
-
|
|
521
|
-
- Initial version. ([@palkan][])
|
|
166
|
+
See [changelog](https://github.com/test-prof/test-prof/blob/v0.8.0/CHANGELOG.md) for versions <0.9.0.
|
|
522
167
|
|
|
523
168
|
[@palkan]: https://github.com/palkan
|
|
524
169
|
[@marshall-lee]: https://github.com/marshall-lee
|
|
@@ -536,3 +181,7 @@ Fixes [#10](https://github.com/palkan/test-prof/issues/10).
|
|
|
536
181
|
[@tyleriguchi]: https://github.com/tyleriguchi
|
|
537
182
|
[@lostie]: https://github.com/lostie
|
|
538
183
|
[@pirj]: https://github.com/pirj
|
|
184
|
+
[@LynxEyes]: https://github.com/LynxEyes
|
|
185
|
+
[@stefkin]: https://github.com/stefkin
|
|
186
|
+
[@jaimerson]: https://github.com/jaimerson
|
|
187
|
+
[@alexvko]: https://github.com/alexvko
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
[](
|
|
2
|
-
[](https://rubygems.org/gems/test-prof) [](https://cultofmartians.com)
|
|
2
|
+
[](https://rubygems.org/gems/test-prof) [](https://github.com/test-prof/test-prof/actions)
|
|
3
|
+
[](https://github.com/test-prof/test-prof/actions)
|
|
4
|
+
[](https://www.codetriage.com/test-prof/test-prof)
|
|
5
5
|
[](https://test-prof.evilmartians.io)
|
|
6
6
|
|
|
7
7
|
# Ruby Tests Profiling Toolbox
|
|
@@ -47,11 +47,11 @@ TestProf toolbox aims to help you identify bottlenecks in your test suite. It co
|
|
|
47
47
|
## Who uses TestProf
|
|
48
48
|
|
|
49
49
|
- [Discourse](https://github.com/discourse/discourse) reduced [~27% of their test suite time](https://twitter.com/samsaffron/status/1125602558024699904)
|
|
50
|
-
- [Gitlab](https://gitlab.com/gitlab-org/gitlab-ce) reduced [39% of their API tests time](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/14370)
|
|
50
|
+
- [Gitlab](https://gitlab.com/gitlab-org/gitlab-ce) reduced [39% of their API tests time](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/14370) and [improved factories usage](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/26810)
|
|
51
51
|
- [CodeTriage](https://github.com/codetriage/codetriage)
|
|
52
52
|
- [Dev.to](https://github.com/thepracticaldev/dev.to)
|
|
53
53
|
- [Open Project](https://github.com/opf/openproject)
|
|
54
|
-
- [...and others](https://github.com/
|
|
54
|
+
- [...and others](https://github.com/test-prof/test-prof/issues/73)
|
|
55
55
|
|
|
56
56
|
## Resources
|
|
57
57
|
|
|
@@ -83,7 +83,7 @@ And that's it)
|
|
|
83
83
|
|
|
84
84
|
Supported Ruby versions:
|
|
85
85
|
|
|
86
|
-
- Ruby (MRI) >= 2.
|
|
86
|
+
- Ruby (MRI) >= 2.5.0 (**NOTE:** for Ruby 2.2 use TestProf < 0.7.0, Ruby 2.3 use TestProf ~> 0.7.0, Ruby 2.4 use TestProf <0.12.0)
|
|
87
87
|
|
|
88
88
|
- JRuby >= 9.1.0.0 (**NOTE:** refinements-dependent features might require 9.2.7+)
|
|
89
89
|
|
|
@@ -95,16 +95,12 @@ Check out our [docs][].
|
|
|
95
95
|
|
|
96
96
|
## What's next?
|
|
97
97
|
|
|
98
|
-
Have an idea? [Propose](https://github.com/
|
|
98
|
+
Have an idea? [Propose](https://github.com/test-prof/test-prof/issues/new) a feature request!
|
|
99
99
|
|
|
100
|
-
Already using TestProf? [Share your story!](https://github.com/
|
|
100
|
+
Already using TestProf? [Share your story!](https://github.com/test-prof/test-prof/issues/73)
|
|
101
101
|
|
|
102
102
|
## License
|
|
103
103
|
|
|
104
104
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
|
105
105
|
|
|
106
106
|
[docs]: https://test-prof.evilmartians.io
|
|
107
|
-
|
|
108
|
-
## Security Contact
|
|
109
|
-
|
|
110
|
-
To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure.
|
|
@@ -12,6 +12,7 @@ module Minitest # :nodoc:
|
|
|
12
12
|
opts[:top_count] = ENV["EVENT_PROF_TOP"].to_i if ENV["EVENT_PROF_TOP"]
|
|
13
13
|
opts[:per_example] = true if ENV["EVENT_PROF_EXAMPLES"]
|
|
14
14
|
opts[:fdoc] = true if ENV["FDOC"]
|
|
15
|
+
opts[:sample] = true if ENV["SAMPLE"] || ENV["SAMPLE_GROUPS"]
|
|
15
16
|
end
|
|
16
17
|
end
|
|
17
18
|
end
|
|
@@ -39,5 +40,7 @@ module Minitest # :nodoc:
|
|
|
39
40
|
|
|
40
41
|
reporter << TestProf::EventProfReporter.new(options[:io], options) if options[:event]
|
|
41
42
|
reporter << TestProf::FactoryDoctorReporter.new(options[:io], options) if options[:fdoc]
|
|
43
|
+
|
|
44
|
+
::TestProf::MinitestSample.call if options[:sample]
|
|
42
45
|
end
|
|
43
46
|
end
|
data/lib/test_prof/before_all.rb
CHANGED
|
@@ -5,7 +5,7 @@ require_relative "../language"
|
|
|
5
5
|
module RuboCop
|
|
6
6
|
module Cop
|
|
7
7
|
module RSpec
|
|
8
|
-
class AggregateExamples < Cop
|
|
8
|
+
class AggregateExamples < ::RuboCop::Cop::Cop
|
|
9
9
|
# When aggregated, the expectations will fail when not supposed to or
|
|
10
10
|
# have a risk of not failing when expected to. One example is
|
|
11
11
|
# `validate_presence_of :comment` as it leaves an empty comment after
|
|
@@ -12,7 +12,7 @@ module RuboCop
|
|
|
12
12
|
module RSpec
|
|
13
13
|
# Checks if example groups contain two or more aggregatable examples.
|
|
14
14
|
#
|
|
15
|
-
# @see https://github.com/rubocop-hq/rspec-style-guide#
|
|
15
|
+
# @see https://github.com/rubocop-hq/rspec-style-guide#expectation-per-example
|
|
16
16
|
#
|
|
17
17
|
# This cop is primarily for reducing the cost of repeated expensive
|
|
18
18
|
# context initialization.
|
|
@@ -108,7 +108,7 @@ module RuboCop
|
|
|
108
108
|
# expect(number).to be_odd
|
|
109
109
|
# end
|
|
110
110
|
#
|
|
111
|
-
class AggregateExamples < Cop
|
|
111
|
+
class AggregateExamples < ::RuboCop::Cop::Cop
|
|
112
112
|
include LineRangeHelpers
|
|
113
113
|
include MetadataHelpers
|
|
114
114
|
include NodeMatchers
|
|
@@ -4,13 +4,31 @@ module TestProf::EventProf
|
|
|
4
4
|
module Instrumentations
|
|
5
5
|
# Wrapper over ActiveSupport::Notifications
|
|
6
6
|
module ActiveSupport
|
|
7
|
+
class Subscriber
|
|
8
|
+
attr_reader :block, :started_at
|
|
9
|
+
|
|
10
|
+
def initialize(block)
|
|
11
|
+
@block = block
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def start(*)
|
|
15
|
+
@started_at = TestProf.now
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def publish(_name, started_at, finished_at, *)
|
|
19
|
+
block.call(finished_at - started_at)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def finish(*)
|
|
23
|
+
block.call(TestProf.now - started_at)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
7
27
|
class << self
|
|
8
|
-
def subscribe(event)
|
|
28
|
+
def subscribe(event, &block)
|
|
9
29
|
raise ArgumentError, "Block is required!" unless block_given?
|
|
10
30
|
|
|
11
|
-
::ActiveSupport::Notifications.subscribe(event
|
|
12
|
-
yield (finish - start)
|
|
13
|
-
end
|
|
31
|
+
::ActiveSupport::Notifications.subscribe(event, Subscriber.new(block))
|
|
14
32
|
end
|
|
15
33
|
|
|
16
34
|
def instrument(event)
|
|
@@ -5,8 +5,8 @@ module TestProf
|
|
|
5
5
|
module ActiveRecord3Transactions
|
|
6
6
|
refine ::ActiveRecord::ConnectionAdapters::AbstractAdapter do
|
|
7
7
|
def begin_transaction(joinable: true)
|
|
8
|
-
increment_open_transactions
|
|
9
8
|
if open_transactions > 0
|
|
9
|
+
increment_open_transactions
|
|
10
10
|
create_savepoint
|
|
11
11
|
else
|
|
12
12
|
begin_db_transaction
|
|
@@ -35,18 +35,14 @@ module TestProf
|
|
|
35
35
|
end
|
|
36
36
|
end
|
|
37
37
|
end
|
|
38
|
-
end
|
|
39
38
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
39
|
+
def call
|
|
40
|
+
if ENV["SAMPLE"]
|
|
41
|
+
::TestProf::MinitestSample.sample_examples(ENV["SAMPLE"].to_i)
|
|
42
|
+
elsif ENV["SAMPLE_GROUPS"]
|
|
43
|
+
::TestProf::MinitestSample.sample_groups(ENV["SAMPLE_GROUPS"].to_i)
|
|
44
|
+
end
|
|
46
45
|
end
|
|
47
|
-
super
|
|
48
46
|
end
|
|
49
47
|
end
|
|
50
48
|
end
|
|
51
|
-
|
|
52
|
-
Minitest.singleton_class.prepend(TestProf::MinitestSample)
|
|
@@ -9,7 +9,7 @@ module TestProf
|
|
|
9
9
|
def before_all(&block)
|
|
10
10
|
raise ArgumentError, "Block is required!" unless block_given?
|
|
11
11
|
|
|
12
|
-
return
|
|
12
|
+
return before(:all, &block) if within_before_all?
|
|
13
13
|
|
|
14
14
|
@__before_all_activated__ = true
|
|
15
15
|
|
|
@@ -24,14 +24,6 @@ module TestProf
|
|
|
24
24
|
end
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
-
def within_before_all(&block)
|
|
28
|
-
before(:all) do
|
|
29
|
-
BeforeAll.within_transaction do
|
|
30
|
-
instance_eval(&block)
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
|
|
35
27
|
def within_before_all?
|
|
36
28
|
instance_variable_defined?(:@__before_all_activated__)
|
|
37
29
|
end
|
|
@@ -22,6 +22,10 @@ module TestProf
|
|
|
22
22
|
|
|
23
23
|
LetItBe.modifiers[key] = block
|
|
24
24
|
end
|
|
25
|
+
|
|
26
|
+
def default_modifiers
|
|
27
|
+
@default_modifiers ||= {}
|
|
28
|
+
end
|
|
25
29
|
end
|
|
26
30
|
|
|
27
31
|
class << self
|
|
@@ -75,6 +79,8 @@ module TestProf
|
|
|
75
79
|
# And we love cats!)
|
|
76
80
|
PREFIX = RUBY_ENGINE == "jruby" ? "@__jruby_is_not_cat_friendly__" : "@😸"
|
|
77
81
|
|
|
82
|
+
FROZEN_ERROR_HINT = "\nIf you are using `let_it_be`, you may want to pass `reload: true` or `refind: true` modifier to it."
|
|
83
|
+
|
|
78
84
|
def self.define_let_it_be_alias(name, **default_args)
|
|
79
85
|
define_method(name) do |identifier, **options, &blk|
|
|
80
86
|
let_it_be(identifier, **default_args.merge(options), &blk)
|
|
@@ -83,20 +89,20 @@ module TestProf
|
|
|
83
89
|
|
|
84
90
|
def let_it_be(identifier, **options, &block)
|
|
85
91
|
initializer = proc do
|
|
86
|
-
instance_variable_set(:"#{PREFIX}#{identifier}", instance_exec(&block))
|
|
92
|
+
instance_variable_set(:"#{TestProf::LetItBe::PREFIX}#{identifier}", instance_exec(&block))
|
|
93
|
+
rescue FrozenError => e
|
|
94
|
+
e.message << TestProf::LetItBe::FROZEN_ERROR_HINT
|
|
95
|
+
raise
|
|
87
96
|
end
|
|
88
97
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
else
|
|
92
|
-
before_all(&initializer)
|
|
93
|
-
end
|
|
98
|
+
default_options = LetItBe.config.default_modifiers.dup
|
|
99
|
+
default_options.merge!(metadata[:let_it_be_modifiers]) if metadata[:let_it_be_modifiers]
|
|
94
100
|
|
|
95
|
-
|
|
96
|
-
|
|
101
|
+
options = default_options.merge(options)
|
|
102
|
+
|
|
103
|
+
before_all(&initializer)
|
|
97
104
|
|
|
98
|
-
|
|
99
|
-
let_accessor = LetItBe.wrap_with_modifiers(modifiers) do
|
|
105
|
+
let_accessor = LetItBe.wrap_with_modifiers(options) do
|
|
100
106
|
instance_variable_get(:"#{PREFIX}#{identifier}")
|
|
101
107
|
end
|
|
102
108
|
|
|
@@ -114,16 +120,78 @@ module TestProf
|
|
|
114
120
|
|
|
115
121
|
let(identifier, &let_accessor)
|
|
116
122
|
end
|
|
123
|
+
|
|
124
|
+
module Freezer
|
|
125
|
+
# Stoplist to prevent freezing objects and theirs associations that are defined
|
|
126
|
+
# with `let_it_be`'s `freeze: false` options during deep freezing.
|
|
127
|
+
#
|
|
128
|
+
# To only keep track of objects that are available in current example group,
|
|
129
|
+
# `begin` adds a new layer, and `rollback` removes a layer of unrelated objects
|
|
130
|
+
# along with rolling back the transaction where they were created.
|
|
131
|
+
#
|
|
132
|
+
# Stoplist holds records declared with `freeze: false` (so we do not freeze them even if they're used as
|
|
133
|
+
# associated records for frozen objects)
|
|
134
|
+
module Stoplist
|
|
135
|
+
class << self
|
|
136
|
+
def stop?(record)
|
|
137
|
+
@stoplist.any? { |layer| layer.include?(record) }
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
def stop!(record)
|
|
141
|
+
@stoplist.last.push(record)
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
def begin
|
|
145
|
+
@stoplist.push([])
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
def rollback
|
|
149
|
+
@stoplist.pop
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
# Stack of example group-related variable definitions
|
|
154
|
+
@stoplist = []
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
class << self
|
|
158
|
+
# Rerucsively freezes the object to detect modifications
|
|
159
|
+
def deep_freeze(record)
|
|
160
|
+
return if record.frozen?
|
|
161
|
+
return if Stoplist.stop?(record)
|
|
162
|
+
|
|
163
|
+
record.freeze
|
|
164
|
+
|
|
165
|
+
# Support `let_it_be` with `create_list`
|
|
166
|
+
return record.each { |rec| deep_freeze(rec) } if record.respond_to?(:each)
|
|
167
|
+
|
|
168
|
+
# Freeze associations as well.
|
|
169
|
+
return unless defined?(::ActiveRecord::Base)
|
|
170
|
+
return unless record.is_a?(::ActiveRecord::Base)
|
|
171
|
+
|
|
172
|
+
record.class.reflections.keys.each do |reflection|
|
|
173
|
+
# But only if they are already loaded. If not yet loaded, they weren't
|
|
174
|
+
# created by factories, and it's ok to mutate them.
|
|
175
|
+
|
|
176
|
+
next unless record.association(reflection.to_sym).loaded?
|
|
177
|
+
|
|
178
|
+
target = record.association(reflection.to_sym).target
|
|
179
|
+
deep_freeze(target) if target.is_a?(::ActiveRecord::Base) || target.respond_to?(:each)
|
|
180
|
+
end
|
|
181
|
+
end
|
|
182
|
+
end
|
|
183
|
+
end
|
|
117
184
|
end
|
|
118
185
|
end
|
|
119
186
|
|
|
120
|
-
if defined?(::ActiveRecord)
|
|
187
|
+
if defined?(::ActiveRecord::Base)
|
|
121
188
|
require "test_prof/ext/active_record_refind"
|
|
122
189
|
using TestProf::Ext::ActiveRecordRefind
|
|
123
190
|
|
|
124
191
|
TestProf::LetItBe.configure do |config|
|
|
125
192
|
config.register_modifier :reload do |record, val|
|
|
126
193
|
next record unless val
|
|
194
|
+
|
|
127
195
|
next record.reload if record.is_a?(::ActiveRecord::Base)
|
|
128
196
|
|
|
129
197
|
if record.respond_to?(:map)
|
|
@@ -136,6 +204,7 @@ if defined?(::ActiveRecord)
|
|
|
136
204
|
|
|
137
205
|
config.register_modifier :refind do |record, val|
|
|
138
206
|
next record unless val
|
|
207
|
+
|
|
139
208
|
next record.refind if record.is_a?(::ActiveRecord::Base)
|
|
140
209
|
|
|
141
210
|
if record.respond_to?(:map)
|
|
@@ -145,7 +214,35 @@ if defined?(::ActiveRecord)
|
|
|
145
214
|
end
|
|
146
215
|
record
|
|
147
216
|
end
|
|
217
|
+
|
|
218
|
+
config.register_modifier :freeze do |record, val|
|
|
219
|
+
if val == false
|
|
220
|
+
TestProf::LetItBe::Freezer::Stoplist.stop!(record)
|
|
221
|
+
next record
|
|
222
|
+
end
|
|
223
|
+
|
|
224
|
+
TestProf::LetItBe::Freezer.deep_freeze(record)
|
|
225
|
+
record
|
|
226
|
+
end
|
|
148
227
|
end
|
|
149
228
|
end
|
|
150
229
|
|
|
151
230
|
RSpec::Core::ExampleGroup.extend TestProf::LetItBe
|
|
231
|
+
|
|
232
|
+
TestProf::BeforeAll.configure do |config|
|
|
233
|
+
config.before(:begin) do
|
|
234
|
+
TestProf::LetItBe::Freezer::Stoplist.begin
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
config.after(:rollback) do
|
|
238
|
+
TestProf::LetItBe::Freezer::Stoplist.rollback
|
|
239
|
+
end
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
RSpec.configure do |config|
|
|
243
|
+
config.after(:example) do |example|
|
|
244
|
+
if example.exception&.is_a?(FrozenError)
|
|
245
|
+
example.exception.message << TestProf::LetItBe::FROZEN_ERROR_HINT
|
|
246
|
+
end
|
|
247
|
+
end
|
|
248
|
+
end
|
|
@@ -15,7 +15,8 @@ if ENV["SAMPLE"]
|
|
|
15
15
|
RSpec.configure do |config|
|
|
16
16
|
config.before(:suite) do
|
|
17
17
|
filtered_examples = RSpec.world.filtered_examples.values.flatten
|
|
18
|
-
|
|
18
|
+
random = Random.new(RSpec.configuration.seed)
|
|
19
|
+
sample = filtered_examples.sample(ENV["SAMPLE"].to_i, random: random)
|
|
19
20
|
RSpec.world.filtered_examples = Hash.new do |hash, group|
|
|
20
21
|
hash[group] = group.examples & sample
|
|
21
22
|
end
|
|
@@ -31,7 +32,8 @@ if ENV["SAMPLE_GROUPS"]
|
|
|
31
32
|
filtered_groups = RSpec.world.filtered_examples.reject do |_group, examples|
|
|
32
33
|
examples.empty?
|
|
33
34
|
end.keys
|
|
34
|
-
|
|
35
|
+
random = Random.new(RSpec.configuration.seed)
|
|
36
|
+
sample = filtered_groups.sample(ENV["SAMPLE_GROUPS"].to_i, random: random)
|
|
35
37
|
RSpec.world.filtered_examples = Hash.new do |hash, group|
|
|
36
38
|
hash[group] = sample.include?(group) ? group.examples : []
|
|
37
39
|
end
|
data/lib/test_prof/stack_prof.rb
CHANGED
data/lib/test_prof/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: test-prof
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.12.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Vladimir Dementyev
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2020-
|
|
11
|
+
date: 2020-09-01 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -30,14 +30,14 @@ dependencies:
|
|
|
30
30
|
requirements:
|
|
31
31
|
- - "~>"
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: '
|
|
33
|
+
version: '13.0'
|
|
34
34
|
type: :development
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
38
|
- - "~>"
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: '
|
|
40
|
+
version: '13.0'
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
42
|
name: rspec
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -56,42 +56,42 @@ dependencies:
|
|
|
56
56
|
name: isolator
|
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
|
58
58
|
requirements:
|
|
59
|
-
- - "
|
|
59
|
+
- - ">="
|
|
60
60
|
- !ruby/object:Gem::Version
|
|
61
61
|
version: '0.6'
|
|
62
62
|
type: :development
|
|
63
63
|
prerelease: false
|
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
65
|
requirements:
|
|
66
|
-
- - "
|
|
66
|
+
- - ">="
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
68
|
version: '0.6'
|
|
69
69
|
- !ruby/object:Gem::Dependency
|
|
70
70
|
name: minitest
|
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
|
72
72
|
requirements:
|
|
73
|
-
- - "
|
|
73
|
+
- - ">="
|
|
74
74
|
- !ruby/object:Gem::Version
|
|
75
75
|
version: '5.9'
|
|
76
76
|
type: :development
|
|
77
77
|
prerelease: false
|
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
79
|
requirements:
|
|
80
|
-
- - "
|
|
80
|
+
- - ">="
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
82
|
version: '5.9'
|
|
83
83
|
- !ruby/object:Gem::Dependency
|
|
84
84
|
name: rubocop
|
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
|
86
86
|
requirements:
|
|
87
|
-
- - "
|
|
87
|
+
- - ">="
|
|
88
88
|
- !ruby/object:Gem::Version
|
|
89
89
|
version: 0.77.0
|
|
90
90
|
type: :development
|
|
91
91
|
prerelease: false
|
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
|
93
93
|
requirements:
|
|
94
|
-
- - "
|
|
94
|
+
- - ">="
|
|
95
95
|
- !ruby/object:Gem::Version
|
|
96
96
|
version: 0.77.0
|
|
97
97
|
description: "\n Ruby applications tests profiling tools.\n\n Contains tools
|
|
@@ -208,15 +208,15 @@ files:
|
|
|
208
208
|
- lib/test_prof/utils/rspec.rb
|
|
209
209
|
- lib/test_prof/utils/sized_ordered_set.rb
|
|
210
210
|
- lib/test_prof/version.rb
|
|
211
|
-
homepage: http://github.com/
|
|
211
|
+
homepage: http://github.com/test-prof/test-prof
|
|
212
212
|
licenses:
|
|
213
213
|
- MIT
|
|
214
214
|
metadata:
|
|
215
|
-
bug_tracker_uri: http://github.com/
|
|
216
|
-
changelog_uri: https://github.com/
|
|
215
|
+
bug_tracker_uri: http://github.com/test-prof/test-prof/issues
|
|
216
|
+
changelog_uri: https://github.com/test-prof/test-prof/blob/master/CHANGELOG.md
|
|
217
217
|
documentation_uri: https://test-prof.evilmartians.io/
|
|
218
218
|
homepage_uri: https://test-prof.evilmartians.io/
|
|
219
|
-
source_code_uri: http://github.com/
|
|
219
|
+
source_code_uri: http://github.com/test-prof/test-prof
|
|
220
220
|
post_install_message:
|
|
221
221
|
rdoc_options: []
|
|
222
222
|
require_paths:
|
|
@@ -225,7 +225,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
225
225
|
requirements:
|
|
226
226
|
- - ">="
|
|
227
227
|
- !ruby/object:Gem::Version
|
|
228
|
-
version: 2.
|
|
228
|
+
version: 2.5.0
|
|
229
229
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
230
230
|
requirements:
|
|
231
231
|
- - ">="
|