test-prof 0.6.0.pre1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +22 -1
- data/README.md +1 -1
- data/lib/test_prof/factory_default.rb +22 -13
- data/lib/test_prof/factory_default/factory_bot_patch.rb +5 -2
- data/lib/test_prof/ruby_prof/rspec.rb +40 -7
- data/lib/test_prof/stack_prof.rb +1 -2
- data/lib/test_prof/stack_prof/rspec.rb +38 -7
- data/lib/test_prof/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 03ab3753dd924402ef2d09973165d82d17d2e72c26ad317e6513111ff1b93166
|
4
|
+
data.tar.gz: 93cbd1952a5054e0c2f76058e227a6e03c0bb6b050f20a74d54fd57b85401e69
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f6a2ed0ba54bf9c4e0633b842fa5c961ab832f4a45013e44ae68804c1714b6708be22505c7b6de38a6e90a2661f64c684efefbb07d1569ef22cbdf17d5cef57
|
7
|
+
data.tar.gz: 79fa0b40361b533cde8f26c45ed66add0a70cad73f59c5ddcabe6f2997fb944293b36a33f557e4870667a7f023e84219216ef6d4e1ee9d54b316ac038cb281e3
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
## master
|
4
4
|
|
5
|
+
## 0.6.0 (2018-06-29)
|
6
|
+
|
7
|
+
### Features
|
8
|
+
|
5
9
|
- Add `EventProf.monitor` to instrument arbitrary methods. ([@palkan][])
|
6
10
|
|
7
11
|
Add custom instrumetation easily:
|
@@ -17,14 +21,20 @@ end
|
|
17
21
|
TestProf::EventProf.monitor(Work, "my.work", :do)
|
18
22
|
```
|
19
23
|
|
24
|
+
[📝 Docs](https://test-prof.evilmartians.io/#/event_prof?id=profile-arbitrary-methods)
|
25
|
+
|
20
26
|
- Adapterize `before_all`. ([@palkan][])
|
21
27
|
|
22
28
|
Now it's possible to write your own adapter for `before_all` to manage
|
23
29
|
transactions.
|
24
30
|
|
31
|
+
[📝 Docs](https://test-prof.evilmartians.io/#/before_all?id=database-adapters)
|
32
|
+
|
25
33
|
- Add `before_all` for Minitest. ([@palkan][])
|
26
34
|
|
27
|
-
-
|
35
|
+
[📝 Docs](https://test-prof.evilmartians.io/#/before_all?id=minitest-experimental)
|
36
|
+
|
37
|
+
### Fixes & Improvements
|
28
38
|
|
29
39
|
- Show top `let` declarations per example group in RSpecDissect profiler. ([@palkan][])
|
30
40
|
|
@@ -49,8 +59,18 @@ TestProf::RSpecDissect.configure do |config|
|
|
49
59
|
end
|
50
60
|
```
|
51
61
|
|
62
|
+
- [Fix [#80](https://github.com/palkan/test-prof/issues/80)] Added ability to preserve traits. ([@Vasfed][])
|
63
|
+
|
64
|
+
Disabled by default for compatibility. Enable globally by `FactoryDefault.preserve_traits = true` or for single `create_default`: `create_default(:user, preserve_traits: true)`
|
65
|
+
|
66
|
+
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.
|
67
|
+
|
52
68
|
- Add ability to run only `let` or `before` profiler with RSpecDissect. ([@palkan][])
|
53
69
|
|
70
|
+
- Collect _raw_ data with StackProf by default. ([@palkan][])
|
71
|
+
|
72
|
+
- Refactor `:with_clean_fixture` to clean data once per group. ([@palkan][])
|
73
|
+
|
54
74
|
- [Fix [#75](https://github.com/palkan/test-prof/issues/75)] Fix `RSpec/Aggregate` failures with non-regular examples. ([@palkan][])
|
55
75
|
|
56
76
|
Do not take into account `xit`, `pending`, `its`, etc. examples,
|
@@ -312,3 +332,4 @@ Ensure output dir exists in `#artifact_path` method.
|
|
312
332
|
[@IDolgirev]: https://github.com/IDolgirev
|
313
333
|
[@desoleary]: https://github.com/desoleary
|
314
334
|
[@rabotyaga]: https://github.com/rabotyaga
|
335
|
+
[@Vasfed]: https://github.com/Vasfed
|
data/README.md
CHANGED
@@ -9,18 +9,21 @@ module TestProf
|
|
9
9
|
module FactoryDefault
|
10
10
|
module DefaultSyntax # :nodoc:
|
11
11
|
def create_default(name, *args, &block)
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
)
|
12
|
+
options = args.extract_options!
|
13
|
+
preserve = options.delete(:preserve_traits)
|
14
|
+
|
15
|
+
obj = TestProf::FactoryBot.create(name, *args, options, &block)
|
16
|
+
set_factory_default(name, obj, preserve_traits: preserve)
|
16
17
|
end
|
17
18
|
|
18
|
-
def set_factory_default(name, obj)
|
19
|
-
FactoryDefault.register(name, obj)
|
19
|
+
def set_factory_default(name, obj, preserve_traits: nil)
|
20
|
+
FactoryDefault.register(name, obj, preserve_traits: preserve_traits)
|
20
21
|
end
|
21
22
|
end
|
22
23
|
|
23
24
|
class << self
|
25
|
+
attr_accessor :preserve_traits
|
26
|
+
|
24
27
|
def init
|
25
28
|
TestProf::FactoryBot::Syntax::Methods.include DefaultSyntax
|
26
29
|
TestProf::FactoryBot.extend DefaultSyntax
|
@@ -29,18 +32,24 @@ module TestProf
|
|
29
32
|
TestProf::FactoryBot::Strategy::Stub.prepend StrategyExt
|
30
33
|
|
31
34
|
@store = {}
|
35
|
+
# default is false to retain backward compatibility
|
36
|
+
@preserve_traits = false
|
32
37
|
end
|
33
38
|
|
34
|
-
def register(name, obj)
|
35
|
-
|
39
|
+
def register(name, obj, **options)
|
40
|
+
options[:preserve_traits] = true if FactoryDefault.preserve_traits
|
41
|
+
store[name] = { object: obj, **options }
|
42
|
+
obj
|
36
43
|
end
|
37
44
|
|
38
|
-
def get(name)
|
39
|
-
store[name]
|
40
|
-
|
45
|
+
def get(name, traits = nil)
|
46
|
+
record = store[name]
|
47
|
+
return unless record
|
41
48
|
|
42
|
-
|
43
|
-
|
49
|
+
if traits && !traits.empty?
|
50
|
+
return if FactoryDefault.preserve_traits || record[:preserve_traits]
|
51
|
+
end
|
52
|
+
record[:object]
|
44
53
|
end
|
45
54
|
|
46
55
|
def remove(name)
|
@@ -7,6 +7,10 @@ module TestProf
|
|
7
7
|
def name
|
8
8
|
@name
|
9
9
|
end
|
10
|
+
|
11
|
+
def traits
|
12
|
+
@traits
|
13
|
+
end
|
10
14
|
end
|
11
15
|
end
|
12
16
|
|
@@ -14,8 +18,7 @@ module TestProf
|
|
14
18
|
|
15
19
|
module StrategyExt
|
16
20
|
def association(runner)
|
17
|
-
|
18
|
-
FactoryDefault.get(runner.name)
|
21
|
+
FactoryDefault.get(runner.name, runner.traits) || super
|
19
22
|
end
|
20
23
|
end
|
21
24
|
end
|
@@ -1,13 +1,46 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
module TestProf
|
4
|
+
module RubyProf
|
5
|
+
# Reporter for RSpec to profile specific examples with RubyProf
|
6
|
+
class Listener # :nodoc:
|
7
|
+
NOTIFICATIONS = %i[
|
8
|
+
example_started
|
9
|
+
example_failed
|
10
|
+
example_passed
|
11
|
+
].freeze
|
12
|
+
|
13
|
+
def example_started(notification)
|
14
|
+
return unless profile?(notification.example)
|
15
|
+
notification.example.metadata[:rprof_report] =
|
16
|
+
TestProf::RubyProf.profile
|
17
|
+
end
|
18
|
+
|
19
|
+
def example_finished(notification)
|
20
|
+
return unless profile?(notification.example)
|
21
|
+
notification.example.metadata[:rprof_report].dump(
|
22
|
+
notification.example.full_description.parameterize
|
23
|
+
)
|
24
|
+
end
|
25
|
+
|
26
|
+
alias example_passed example_finished
|
27
|
+
alias example_failed example_finished
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def profile?(example)
|
32
|
+
example.metadata.key?(:rprof)
|
33
|
+
end
|
34
|
+
end
|
7
35
|
end
|
36
|
+
end
|
37
|
+
|
38
|
+
RSpec.configure do |config|
|
39
|
+
config.before(:suite) do
|
40
|
+
listener = TestProf::RubyProf::Listener.new
|
8
41
|
|
9
|
-
|
10
|
-
|
11
|
-
|
42
|
+
config.reporter.register_listener(
|
43
|
+
listener, *TestProf::RubyProf::Listener::NOTIFICATIONS
|
44
|
+
)
|
12
45
|
end
|
13
46
|
end
|
data/lib/test_prof/stack_prof.rb
CHANGED
@@ -29,8 +29,7 @@ module TestProf
|
|
29
29
|
def initialize
|
30
30
|
@mode = ENV.fetch('TEST_STACK_PROF_MODE', :wall).to_sym
|
31
31
|
@target = ENV['TEST_STACK_PROF'] == 'boot' ? :boot : :suite
|
32
|
-
@raw = ENV['
|
33
|
-
@raw = true if boot?
|
32
|
+
@raw = ENV['TEST_STACK_PROF_RAW'] != '0'
|
34
33
|
end
|
35
34
|
|
36
35
|
def raw?
|
@@ -1,14 +1,45 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
module TestProf
|
4
|
+
module StackProf
|
5
|
+
# Reporter for RSpec to profile specific examples with StackProf
|
6
|
+
class Listener # :nodoc:
|
7
|
+
NOTIFICATIONS = %i[
|
8
|
+
example_started
|
9
|
+
example_failed
|
10
|
+
example_passed
|
11
|
+
].freeze
|
12
|
+
|
13
|
+
def example_started(notification)
|
14
|
+
TestProf::StackProf.profile if profile?(notification.example)
|
15
|
+
end
|
16
|
+
|
17
|
+
def example_finished(notification)
|
18
|
+
return unless profile?(notification.example)
|
19
|
+
TestProf::StackProf.dump(
|
20
|
+
notification.example.full_description.parameterize
|
21
|
+
)
|
22
|
+
end
|
23
|
+
|
24
|
+
alias example_passed example_finished
|
25
|
+
alias example_failed example_finished
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def profile?(example)
|
30
|
+
example.metadata.key?(:sprof)
|
31
|
+
end
|
32
|
+
end
|
7
33
|
end
|
34
|
+
end
|
35
|
+
|
36
|
+
RSpec.configure do |config|
|
37
|
+
config.before(:suite) do
|
38
|
+
listener = TestProf::StackProf::Listener.new
|
8
39
|
|
9
|
-
|
10
|
-
|
11
|
-
|
40
|
+
config.reporter.register_listener(
|
41
|
+
listener, *TestProf::StackProf::Listener::NOTIFICATIONS
|
42
|
+
)
|
12
43
|
end
|
13
44
|
end
|
14
45
|
|
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.6.0
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vladimir Dementyev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-06-
|
11
|
+
date: 2018-06-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -209,9 +209,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
209
209
|
version: 2.2.0
|
210
210
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
211
211
|
requirements:
|
212
|
-
- - "
|
212
|
+
- - ">="
|
213
213
|
- !ruby/object:Gem::Version
|
214
|
-
version:
|
214
|
+
version: '0'
|
215
215
|
requirements: []
|
216
216
|
rubyforge_project:
|
217
217
|
rubygems_version: 2.7.6
|