test-prof 1.0.7 → 1.0.8
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 +11 -1
- data/lib/test_prof/any_fixture/dump/postgresql.rb +1 -1
- data/lib/test_prof/any_fixture/dump/sqlite.rb +1 -1
- data/lib/test_prof/any_fixture.rb +1 -0
- data/lib/test_prof/before_all/adapters/active_record.rb +9 -0
- data/lib/test_prof/before_all.rb +2 -0
- data/lib/test_prof/cops/rspec/aggregate_examples/matchers_with_side_effects.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 +5 -5
- data/lib/test_prof/factory_all_stub.rb +1 -0
- data/lib/test_prof/factory_default.rb +5 -3
- data/lib/test_prof/factory_prof.rb +9 -3
- data/lib/test_prof/recipes/logging.rb +0 -2
- data/lib/test_prof/recipes/rspec/let_it_be.rb +2 -2
- data/lib/test_prof/rspec_dissect/collectors/before.rb +1 -1
- data/lib/test_prof/rspec_dissect/collectors/let.rb +1 -1
- data/lib/test_prof/rspec_stamp/parser.rb +0 -2
- data/lib/test_prof/rspec_stamp.rb +0 -2
- data/lib/test_prof/rubocop.rb +1 -1
- data/lib/test_prof/stack_prof.rb +2 -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: 9e1623dde5386ea71184b81cf99eb67ac377613d46b2ebac3ce874164103fcbd
|
4
|
+
data.tar.gz: 1b9fa94cb2616226019cbc57ee8dbefa5c03db8f42f0be277352884ab6dfdb48
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7eeec86920c82c3afb8b89478b3992bf1750fdacd949913c0a6c18a684bcefb5998880e4da2cecec1c8d5866dcc89b8a16de31e7e881713f8a4707aa08b25fd6
|
7
|
+
data.tar.gz: 793ec788e3cb95c29b8b3b1a9026db05e64d1ae828ca2ce8a180ffc460cf3d653710b2c4356e47d0dbc3aa8a3fd5ea633502fa5c0f0114a467a5dd01ae99b5b5
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,14 @@
|
|
1
1
|
# Change log
|
2
2
|
|
3
|
-
## master (
|
3
|
+
## master (unreleased)
|
4
|
+
|
5
|
+
## 1.0.8 (2022-03-11)
|
6
|
+
|
7
|
+
- Restore the lock_thread value after rollback. ([@cou929][])
|
8
|
+
|
9
|
+
- Fixes the configuration of a printer for factory_prof runs
|
10
|
+
|
11
|
+
- Ensure that defaults are stored in a threadsafe manner
|
4
12
|
|
5
13
|
## 1.0.7 (2021-08-30)
|
6
14
|
|
@@ -267,3 +275,5 @@ See [changelog](https://github.com/test-prof/test-prof/blob/v0.8.0/CHANGELOG.md)
|
|
267
275
|
[@stefkin]: https://github.com/stefkin
|
268
276
|
[@jaimerson]: https://github.com/jaimerson
|
269
277
|
[@alexvko]: https://github.com/alexvko
|
278
|
+
[@grillermo]: https://github.com/grillermo
|
279
|
+
[@cou929]: https://github.com/cou929
|
@@ -37,6 +37,9 @@ module TestProf
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
+
# avoid instance variable collisions with cats
|
41
|
+
PREFIX_RESTORE_LOCK_THREAD = "@😺"
|
42
|
+
|
40
43
|
configure do |config|
|
41
44
|
# Make sure ActiveRecord uses locked thread.
|
42
45
|
# It only gets locked in `before` / `setup` hook,
|
@@ -44,8 +47,14 @@ module TestProf
|
|
44
47
|
# might lead to leaking connections
|
45
48
|
config.before(:begin) do
|
46
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))
|
47
51
|
::ActiveRecord::Base.connection.pool.lock_thread = true
|
48
52
|
end
|
53
|
+
|
54
|
+
config.after(:rollback) do
|
55
|
+
next unless ::ActiveRecord::Base.connection.pool.respond_to?(:lock_thread=)
|
56
|
+
::ActiveRecord::Base.connection.pool.lock_thread = instance_variable_get("#{PREFIX_RESTORE_LOCK_THREAD}_orig_lock_thread")
|
57
|
+
end
|
49
58
|
end
|
50
59
|
end
|
51
60
|
end
|
data/lib/test_prof/before_all.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
require "test_prof/cops/rspec/aggregate_examples/line_range_helpers"
|
4
|
+
require "test_prof/cops/rspec/aggregate_examples/metadata_helpers"
|
5
|
+
require "test_prof/cops/rspec/aggregate_examples/node_matchers"
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
require "test_prof/cops/rspec/aggregate_examples/its"
|
8
|
+
require "test_prof/cops/rspec/aggregate_examples/matchers_with_side_effects"
|
9
9
|
|
10
10
|
module RuboCop
|
11
11
|
module Cop
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "test_prof"
|
3
4
|
require "test_prof/factory_bot"
|
4
5
|
require "test_prof/factory_default/factory_bot_patch"
|
5
6
|
|
@@ -31,7 +32,6 @@ module TestProf
|
|
31
32
|
TestProf::FactoryBot::Strategy::Build.prepend StrategyExt
|
32
33
|
TestProf::FactoryBot::Strategy::Stub.prepend StrategyExt
|
33
34
|
|
34
|
-
@store = {}
|
35
35
|
# default is false to retain backward compatibility
|
36
36
|
@preserve_traits = false
|
37
37
|
end
|
@@ -57,12 +57,14 @@ module TestProf
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def reset
|
60
|
-
|
60
|
+
store.clear
|
61
61
|
end
|
62
62
|
|
63
63
|
private
|
64
64
|
|
65
|
-
|
65
|
+
def store
|
66
|
+
Thread.current[:testprof_factory_store] ||= {}
|
67
|
+
end
|
66
68
|
end
|
67
69
|
end
|
68
70
|
end
|
@@ -100,15 +100,21 @@ module TestProf
|
|
100
100
|
def run
|
101
101
|
init
|
102
102
|
|
103
|
-
printer = config.printer
|
104
|
-
|
105
103
|
started_at = TestProf.now
|
106
104
|
|
107
|
-
at_exit
|
105
|
+
at_exit do
|
106
|
+
print(started_at)
|
107
|
+
end
|
108
108
|
|
109
109
|
start
|
110
110
|
end
|
111
111
|
|
112
|
+
def print(started_at)
|
113
|
+
printer = config.printer
|
114
|
+
|
115
|
+
printer.dump(result, start_time: started_at)
|
116
|
+
end
|
117
|
+
|
112
118
|
def start
|
113
119
|
reset!
|
114
120
|
@running = true
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "test_prof"
|
4
|
-
|
4
|
+
require "test_prof/recipes/rspec/before_all"
|
5
5
|
|
6
6
|
module TestProf
|
7
7
|
# Just like `let`, but persist the result for the whole group.
|
@@ -75,7 +75,7 @@ module TestProf
|
|
75
75
|
# Use uniq prefix for instance variables to avoid collisions
|
76
76
|
# We want to use the power of Ruby's unicode support)
|
77
77
|
# And we love cats!)
|
78
|
-
PREFIX =
|
78
|
+
PREFIX = "@😸"
|
79
79
|
|
80
80
|
FROZEN_ERROR_HINT = "\nIf you are using `let_it_be`, you may want to pass `reload: true` or `refind: true` modifier to it."
|
81
81
|
|
data/lib/test_prof/rubocop.rb
CHANGED
data/lib/test_prof/stack_prof.rb
CHANGED
@@ -162,13 +162,13 @@ module TestProf
|
|
162
162
|
log :info, <<~MSG
|
163
163
|
Run the following command to generate a flame graph report:
|
164
164
|
|
165
|
-
stackprof --flamegraph #{path} > #{html_path} && stackprof --flamegraph-viewer=#{html_path}
|
165
|
+
stackprof --d3-flamegraph #{path} > #{html_path} && stackprof --flamegraph-viewer=#{html_path}
|
166
166
|
MSG
|
167
167
|
end
|
168
168
|
|
169
169
|
def dump_json_report(path)
|
170
170
|
report = ::StackProf::Report.new(
|
171
|
-
Marshal.load(IO.binread(path))
|
171
|
+
Marshal.load(IO.binread(path))
|
172
172
|
)
|
173
173
|
json_path = path.gsub(/\.dump$/, ".json")
|
174
174
|
File.write(json_path, JSON.generate(report.data))
|
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.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vladimir Dementyev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-04-05 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.
|
240
|
+
rubygems_version: 3.3.7
|
241
241
|
signing_key:
|
242
242
|
specification_version: 4
|
243
243
|
summary: Ruby applications tests profiling tools
|