test-prof 1.0.9 → 1.0.11
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 +20 -0
- data/lib/test_prof/before_all/adapters/active_record.rb +1 -1
- data/lib/test_prof/event_prof/monitor.rb +10 -3
- data/lib/test_prof/event_prof.rb +1 -1
- data/lib/test_prof/factory_doctor/minitest.rb +2 -2
- data/lib/test_prof/factory_doctor/rspec.rb +1 -1
- data/lib/test_prof/logging.rb +1 -1
- data/lib/test_prof/recipes/logging.rb +33 -8
- data/lib/test_prof/rspec_stamp.rb +2 -2
- data/lib/test_prof/stack_prof.rb +3 -2
- data/lib/test_prof/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1cd40e8800d63a753008f4d9b27418db0015bd052ae3b12eb773c7d7380bc1af
|
4
|
+
data.tar.gz: 48cc4a7c0c5105e7b23bf4793419dffa049d1154ebbf124f0a24f83ec2a4d79a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: abdda954d6dce088d9dd015394ebfdca5904973244f2a0c194a2203e8a2ef0a565b2926831770deb4f6e957781a635c2d302860e59148967bf9bc8c10439cd72
|
7
|
+
data.tar.gz: 0db8384bf621fb4a1857dabc02e6e516d99d702ee81a8f1f777c2ffd9e9890dc8f312be1f55172b942b93385168e432bb1f5df0ad03779e21f80f96f868a9889
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,24 @@
|
|
2
2
|
|
3
3
|
## master (unreleased)
|
4
4
|
|
5
|
+
## 1.0.11 (2022-10-27)
|
6
|
+
|
7
|
+
- Fix monitoring methods with keyword args in Ruby 3+. ([@palkan][])
|
8
|
+
|
9
|
+
- Disable garbage collection frames when `TEST_STACK_PROF_IGNORE_GC` env variable is set ([@cbliard][])
|
10
|
+
|
11
|
+
- Fixed restoring lock_thread value in nested contexts ([@ygelfand][])
|
12
|
+
|
13
|
+
## 1.0.10 (2022-08-12)
|
14
|
+
|
15
|
+
- Allow overriding global logger. ([@palkan][])
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
require "test_prof/recipes/logging"
|
19
|
+
|
20
|
+
TestProf::Rails::LoggingHelpers.logger = CustomLogger.new
|
21
|
+
```
|
22
|
+
|
5
23
|
## 1.0.9 (2022-05-05)
|
6
24
|
|
7
25
|
- Add `AnyFixture.before_fixtures_reset` and `AnyFixture.after_fixtures_reset` callbacks. ([@ruslanshakirov][])
|
@@ -284,3 +302,5 @@ See [changelog](https://github.com/test-prof/test-prof/blob/v0.8.0/CHANGELOG.md)
|
|
284
302
|
[@grillermo]: https://github.com/grillermo
|
285
303
|
[@cou929]: https://github.com/cou929
|
286
304
|
[@ruslanshakirov]: https://github.com/ruslanshakirov
|
305
|
+
[@ygelfand]: https://github.com/ygelfand
|
306
|
+
[@cbliard]: https://github.com/cbliard
|
@@ -47,7 +47,7 @@ module TestProf
|
|
47
47
|
# might lead to leaking connections
|
48
48
|
config.before(:begin) do
|
49
49
|
next unless ::ActiveRecord::Base.connection.pool.respond_to?(:lock_thread=)
|
50
|
-
instance_variable_set("#{PREFIX_RESTORE_LOCK_THREAD}_orig_lock_thread", ::ActiveRecord::Base.connection.pool.instance_variable_get(:@lock_thread))
|
50
|
+
instance_variable_set("#{PREFIX_RESTORE_LOCK_THREAD}_orig_lock_thread", ::ActiveRecord::Base.connection.pool.instance_variable_get(:@lock_thread)) unless instance_variable_defined? "#{PREFIX_RESTORE_LOCK_THREAD}_orig_lock_thread"
|
51
51
|
::ActiveRecord::Base.connection.pool.lock_thread = true
|
52
52
|
end
|
53
53
|
|
@@ -48,9 +48,16 @@ module TestProf
|
|
48
48
|
|
49
49
|
patch = Module.new do
|
50
50
|
mids.each do |mid|
|
51
|
-
|
52
|
-
|
53
|
-
|
51
|
+
if RUBY_VERSION >= "2.7.0"
|
52
|
+
define_method(mid) do |*args, **kwargs, &block|
|
53
|
+
next super(*args, **kwargs, &block) unless guard.nil? || instance_exec(*args, **kwargs, &guard)
|
54
|
+
tracker.track { super(*args, **kwargs, &block) }
|
55
|
+
end
|
56
|
+
else
|
57
|
+
define_method(mid) do |*args, &block|
|
58
|
+
next super(*args, &block) unless guard.nil? || instance_exec(*args, &guard)
|
59
|
+
tracker.track { super(*args, &block) }
|
60
|
+
end
|
54
61
|
end
|
55
62
|
end
|
56
63
|
end
|
data/lib/test_prof/event_prof.rb
CHANGED
@@ -8,7 +8,7 @@ require "test_prof/utils/sized_ordered_set"
|
|
8
8
|
|
9
9
|
module TestProf
|
10
10
|
# EventProf profiles your tests and suites against custom events,
|
11
|
-
# such as ActiveSupport::
|
11
|
+
# such as ActiveSupport::Notifications.
|
12
12
|
#
|
13
13
|
# It works very similar to `rspec --profile` but can track arbitrary events.
|
14
14
|
#
|
@@ -74,8 +74,8 @@ module Minitest
|
|
74
74
|
@example_groups.each do |group, examples|
|
75
75
|
msgs << "#{group[:description]} (#{group[:location]})\n"
|
76
76
|
examples.each do |ex|
|
77
|
-
msgs << " #{ex[:description]} (#{ex[:location]}) "\
|
78
|
-
"– #{pluralize_records(ex[:factories])} created, "\
|
77
|
+
msgs << " #{ex[:description]} (#{ex[:location]}) " \
|
78
|
+
"– #{pluralize_records(ex[:factories])} created, " \
|
79
79
|
"#{ex[:time].duration}\n"
|
80
80
|
end
|
81
81
|
msgs << "\n"
|
@@ -67,7 +67,7 @@ module TestProf
|
|
67
67
|
|
68
68
|
examples.each do |ex|
|
69
69
|
msgs << " #{ex.description} (#{ex.metadata[:location]}) " \
|
70
|
-
"– #{pluralize_records(ex.metadata[:factories])} created, "\
|
70
|
+
"– #{pluralize_records(ex.metadata[:factories])} created, " \
|
71
71
|
"#{ex.metadata[:time].duration}\n"
|
72
72
|
end
|
73
73
|
msgs << "\n"
|
data/lib/test_prof/logging.rb
CHANGED
@@ -7,12 +7,38 @@ module TestProf
|
|
7
7
|
# Add `with_logging` and `with_ar_logging helpers`
|
8
8
|
module LoggingHelpers
|
9
9
|
class << self
|
10
|
-
|
10
|
+
def logger=(logger)
|
11
|
+
@logger = logger
|
12
|
+
|
13
|
+
# swap global loggers
|
14
|
+
global_loggables.each do |loggable|
|
15
|
+
loggable.logger = logger
|
16
|
+
end
|
17
|
+
end
|
11
18
|
|
12
19
|
def logger
|
13
20
|
return @logger if instance_variable_defined?(:@logger)
|
14
21
|
|
15
|
-
@logger =
|
22
|
+
@logger = if defined?(ActiveSupport::TaggedLogging)
|
23
|
+
ActiveSupport::TaggedLogging.new(ActiveSupport::Logger.new($stdout))
|
24
|
+
elsif defined?(ActiveSupport::Logger)
|
25
|
+
ActiveSupport::Logger.new($stdout)
|
26
|
+
else
|
27
|
+
Logger.new($stdout)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def global_loggables
|
32
|
+
return @global_loggables if instance_variable_defined?(:@global_loggables)
|
33
|
+
|
34
|
+
@global_loggables = []
|
35
|
+
end
|
36
|
+
|
37
|
+
def swap_logger!(loggables)
|
38
|
+
loggables.each do |loggable|
|
39
|
+
loggable.logger = logger
|
40
|
+
global_loggables << loggable
|
41
|
+
end
|
16
42
|
end
|
17
43
|
|
18
44
|
def ar_loggables
|
@@ -77,7 +103,9 @@ end
|
|
77
103
|
if TestProf.rspec?
|
78
104
|
RSpec.shared_context "logging:verbose" do
|
79
105
|
around(:each) do |ex|
|
80
|
-
with_logging(&ex)
|
106
|
+
next with_logging(&ex) if ex.metadata[:log] == true || ex.metadata[:log] == :all
|
107
|
+
|
108
|
+
ex.call
|
81
109
|
end
|
82
110
|
end
|
83
111
|
|
@@ -96,13 +124,10 @@ end
|
|
96
124
|
|
97
125
|
TestProf.activate("LOG", "all") do
|
98
126
|
TestProf.log :info, "Rails verbose logging enabled"
|
99
|
-
|
100
|
-
Rails.logger =
|
101
|
-
ActiveRecord::Base.logger = TestProf::Rails::LoggingHelpers.logger
|
127
|
+
TestProf::Rails::LoggingHelpers.swap_logger!(TestProf::Rails::LoggingHelpers.all_loggables)
|
102
128
|
end
|
103
129
|
|
104
130
|
TestProf.activate("LOG", "ar") do
|
105
131
|
TestProf.log :info, "Active Record verbose logging enabled"
|
106
|
-
|
107
|
-
ActiveRecord::Base.logger = TestProf::Rails::LoggingHelpers.logger
|
132
|
+
TestProf::Rails::LoggingHelpers.swap_logger!(TestProf::Rails::LoggingHelpers.ar_loggables)
|
108
133
|
end
|
@@ -153,8 +153,8 @@ module TestProf
|
|
153
153
|
end
|
154
154
|
end
|
155
155
|
|
156
|
-
replacement = "\\1#{parsed.fname}#{need_parens ? "(" : " "}"\
|
157
|
-
"#{[desc, tags_str, htags_str].compact.join(", ")}"\
|
156
|
+
replacement = "\\1#{parsed.fname}#{need_parens ? "(" : " "}" \
|
157
|
+
"#{[desc, tags_str, htags_str].compact.join(", ")}" \
|
158
158
|
"#{need_parens ? ") " : " "}\\3"
|
159
159
|
|
160
160
|
if config.dry_run?
|
data/lib/test_prof/stack_prof.rb
CHANGED
@@ -24,8 +24,7 @@ module TestProf
|
|
24
24
|
class Configuration
|
25
25
|
FORMATS = %w[html json].freeze
|
26
26
|
|
27
|
-
attr_accessor :mode, :
|
28
|
-
|
27
|
+
attr_accessor :mode, :raw, :target, :format, :interval, :ignore_gc
|
29
28
|
def initialize
|
30
29
|
@mode = ENV.fetch("TEST_STACK_PROF_MODE", :wall).to_sym
|
31
30
|
@target = ENV["TEST_STACK_PROF"] == "boot" ? :boot : :suite
|
@@ -39,6 +38,7 @@ module TestProf
|
|
39
38
|
|
40
39
|
sample_interval = ENV["TEST_STACK_PROF_INTERVAL"].to_i
|
41
40
|
@interval = sample_interval > 0 ? sample_interval : nil
|
41
|
+
@ignore_gc = !ENV["TEST_STACK_PROF_IGNORE_GC"].nil?
|
42
42
|
end
|
43
43
|
|
44
44
|
def raw?
|
@@ -96,6 +96,7 @@ module TestProf
|
|
96
96
|
}
|
97
97
|
|
98
98
|
options[:interval] = config.interval if config.interval
|
99
|
+
options[:ignore_gc] = true if config.ignore_gc
|
99
100
|
|
100
101
|
if block_given?
|
101
102
|
options[:out] = build_path(name)
|
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: 1.0.
|
4
|
+
version: 1.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vladimir Dementyev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-10-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -237,7 +237,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
237
237
|
- !ruby/object:Gem::Version
|
238
238
|
version: '0'
|
239
239
|
requirements: []
|
240
|
-
rubygems_version: 3.3.
|
240
|
+
rubygems_version: 3.3.11
|
241
241
|
signing_key:
|
242
242
|
specification_version: 4
|
243
243
|
summary: Ruby applications tests profiling tools
|