test-prof 1.0.5 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -6
- data/lib/test_prof.rb +8 -1
- data/lib/test_prof/recipes/minitest/before_all.rb +39 -10
- data/lib/test_prof/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f26a5003d400d430571206914f2f15a94ef4cca220c5f359e315eda7adf7a6b9
|
4
|
+
data.tar.gz: 74d5cfb5e92351e628134dcd51230c6c984bd4b03518b89b4f98d8d20621e46f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea8cd4e7907fceb36874a91240be7baa0bdfb3c43dbddda21dececde541dbe5b9d52738ef3412c9c906e208fe5d33d2b34ce4e13a9063d941f360f2ccb845a30
|
7
|
+
data.tar.gz: b87bec660bcd642dced3582c147317bb575628ef264eb7a33e31b59a1f5f7b740423fbd0a08dddf6c28638ffe266b460b05524cbfabbf95a93105053876aaf05
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,12 @@
|
|
2
2
|
|
3
3
|
## master (unrealeased)
|
4
4
|
|
5
|
+
## 1.0.6 (2021-06-23)
|
6
|
+
|
7
|
+
- Fix Spring detection when `DISABLE_SPRING=1` is used. ([@palkan][])
|
8
|
+
|
9
|
+
- Make `before_all` in Minitest inheritable. ([@palkan][])
|
10
|
+
|
5
11
|
## 1.0.5 (2021-05-13)
|
6
12
|
|
7
13
|
- Fix logging regression when no newline has been added. ([@palkan][])
|
@@ -178,7 +184,7 @@ end
|
|
178
184
|
```
|
179
185
|
|
180
186
|
- Print warning when `ActiveRecordSharedConnection` is used in the version of Rails
|
181
|
-
supporting `lock_threads` (5.1+). ([@palkan][])
|
187
|
+
supporting `lock_threads` (5.1+). ([@palkan][])
|
182
188
|
|
183
189
|
## 0.9.0 (2019-05-14)
|
184
190
|
|
@@ -236,20 +242,20 @@ See [changelog](https://github.com/test-prof/test-prof/blob/v0.8.0/CHANGELOG.md)
|
|
236
242
|
[@palkan]: https://github.com/palkan
|
237
243
|
[@marshall-lee]: https://github.com/marshall-lee
|
238
244
|
[@danielwestendorf]: https://github.com/danielwestendorf
|
239
|
-
[@
|
240
|
-
[@
|
245
|
+
[@shkrt]: https://github.com/Shkrt
|
246
|
+
[@idolgirev]: https://github.com/IDolgirev
|
241
247
|
[@desoleary]: https://github.com/desoleary
|
242
248
|
[@rabotyaga]: https://github.com/rabotyaga
|
243
|
-
[@
|
249
|
+
[@vasfed]: https://github.com/Vasfed
|
244
250
|
[@szemek]: https://github.com/szemek
|
245
251
|
[@mkldon]: https://github.com/mkldon
|
246
252
|
[@dmagro]: https://github.com/dmagro
|
247
253
|
[@danielwaterworth]: https://github.com/danielwaterworth
|
248
|
-
[@
|
254
|
+
[@envek]: https://github.com/Envek
|
249
255
|
[@tyleriguchi]: https://github.com/tyleriguchi
|
250
256
|
[@lostie]: https://github.com/lostie
|
251
257
|
[@pirj]: https://github.com/pirj
|
252
|
-
[@
|
258
|
+
[@lynxeyes]: https://github.com/LynxEyes
|
253
259
|
[@stefkin]: https://github.com/stefkin
|
254
260
|
[@jaimerson]: https://github.com/jaimerson
|
255
261
|
[@alexvko]: https://github.com/alexvko
|
data/lib/test_prof.rb
CHANGED
@@ -46,6 +46,13 @@ module TestProf
|
|
46
46
|
defined?(Minitest)
|
47
47
|
end
|
48
48
|
|
49
|
+
# Returns true if Spring is used and not disabled
|
50
|
+
def spring?
|
51
|
+
# See https://github.com/rails/spring/blob/577cf01f232bb6dbd0ade7df2df2ac209697e741/lib/spring/binstub.rb
|
52
|
+
disabled = ENV["DISABLE_SPRING"]
|
53
|
+
defined?(::Spring::Application) && (disabled.nil? || disabled.empty? || disabled == "0")
|
54
|
+
end
|
55
|
+
|
49
56
|
# Returns the current process time
|
50
57
|
def now
|
51
58
|
Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
@@ -65,7 +72,7 @@ module TestProf
|
|
65
72
|
# equal to the provided value (if any).
|
66
73
|
# Contains workaround for applications using Spring.
|
67
74
|
def activate(env_var, val = nil)
|
68
|
-
if
|
75
|
+
if spring?
|
69
76
|
notify_spring_detected
|
70
77
|
::Spring.after_fork do
|
71
78
|
activate!(env_var, val) do
|
@@ -9,13 +9,15 @@ module TestProf
|
|
9
9
|
module Minitest # :nodoc: all
|
10
10
|
class Executor
|
11
11
|
attr_reader :active, :block, :captured_ivars, :teardown_block, :current_test_object,
|
12
|
-
:setup_fixtures
|
12
|
+
:setup_fixtures, :parent
|
13
13
|
|
14
14
|
alias_method :active?, :active
|
15
15
|
alias_method :setup_fixtures?, :setup_fixtures
|
16
16
|
|
17
|
-
def initialize(setup_fixtures: false, &block)
|
18
|
-
@
|
17
|
+
def initialize(setup_fixtures: false, parent: nil, &block)
|
18
|
+
@parent = parent
|
19
|
+
# Fixtures must be instantiated if any of the executors needs them
|
20
|
+
@setup_fixtures = setup_fixtures || parent&.setup_fixtures
|
19
21
|
@block = block
|
20
22
|
@captured_ivars = []
|
21
23
|
end
|
@@ -28,7 +30,9 @@ module TestProf
|
|
28
30
|
@current_test_object = test_object
|
29
31
|
|
30
32
|
return restore_ivars(test_object) if active?
|
33
|
+
|
31
34
|
@active = true
|
35
|
+
|
32
36
|
BeforeAll.setup_fixtures(test_object) if setup_fixtures?
|
33
37
|
BeforeAll.begin_transaction do
|
34
38
|
capture!(test_object)
|
@@ -36,20 +40,20 @@ module TestProf
|
|
36
40
|
end
|
37
41
|
|
38
42
|
def deactivate!
|
43
|
+
return unless active
|
44
|
+
|
39
45
|
@active = false
|
40
46
|
|
41
|
-
current_test_object
|
47
|
+
perform_teardown(current_test_object)
|
42
48
|
|
43
49
|
@current_test_object = nil
|
44
50
|
BeforeAll.rollback_transaction
|
45
51
|
end
|
46
52
|
|
47
53
|
def capture!(test_object)
|
48
|
-
return unless block
|
49
|
-
|
50
54
|
before_ivars = test_object.instance_variables
|
51
55
|
|
52
|
-
test_object
|
56
|
+
perform_setup(test_object)
|
53
57
|
|
54
58
|
(test_object.instance_variables - before_ivars).each do |ivar|
|
55
59
|
captured_ivars << [ivar, test_object.instance_variable_get(ivar)]
|
@@ -64,6 +68,16 @@ module TestProf
|
|
64
68
|
)
|
65
69
|
end
|
66
70
|
end
|
71
|
+
|
72
|
+
def perform_setup(test_object)
|
73
|
+
parent&.perform_setup(test_object)
|
74
|
+
test_object.instance_eval(&block) if block
|
75
|
+
end
|
76
|
+
|
77
|
+
def perform_teardown(test_object)
|
78
|
+
current_test_object&.instance_eval(&teardown_block) if teardown_block
|
79
|
+
parent&.perform_teardown(test_object)
|
80
|
+
end
|
67
81
|
end
|
68
82
|
|
69
83
|
class << self
|
@@ -73,10 +87,25 @@ module TestProf
|
|
73
87
|
end
|
74
88
|
|
75
89
|
module ClassMethods
|
76
|
-
|
90
|
+
attr_writer :before_all_executor
|
91
|
+
|
92
|
+
def before_all_executor
|
93
|
+
return @before_all_executor if instance_variable_defined?(:@before_all_executor)
|
94
|
+
|
95
|
+
@before_all_executor = if superclass.respond_to?(:before_all_executor)
|
96
|
+
superclass.before_all_executor
|
97
|
+
end
|
98
|
+
end
|
77
99
|
|
78
100
|
def before_all(setup_fixtures: BeforeAll.config.setup_fixtures, &block)
|
79
|
-
self.before_all_executor = Executor.new(
|
101
|
+
self.before_all_executor = Executor.new(
|
102
|
+
setup_fixtures: setup_fixtures,
|
103
|
+
parent: before_all_executor,
|
104
|
+
&block
|
105
|
+
)
|
106
|
+
|
107
|
+
# Do not add patches multiple times
|
108
|
+
return if before_all_executor.parent
|
80
109
|
|
81
110
|
prepend(Module.new do
|
82
111
|
def before_setup
|
@@ -95,7 +124,7 @@ module TestProf
|
|
95
124
|
end
|
96
125
|
|
97
126
|
def after_all(&block)
|
98
|
-
self.before_all_executor
|
127
|
+
self.before_all_executor = Executor.new(parent: before_all_executor)
|
99
128
|
before_all_executor.teardown(&block)
|
100
129
|
end
|
101
130
|
end
|
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.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vladimir Dementyev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-06-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|