test-prof 1.0.6 → 1.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/lib/test_prof/recipes/minitest/before_all.rb +49 -1
- data/lib/test_prof/recipes/rspec/let_it_be.rb +1 -1
- 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: 2f55e42ee372a9ebe0f8981487931bf70ab3209e38163b32f84a7553bdfb4249
|
4
|
+
data.tar.gz: 3ca0352ca4671c11d18937d3ee1de361322c827671d199d079b1460667c32a1c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 00dcd7797667e28b54fe32e36392e44b80a1dd6fdcc04b8a0565084311c5420bbe017eecba2ae553b84b2cdd6bc92886f15a919da8e1ba7a293aa737bc2c81da
|
7
|
+
data.tar.gz: eed04e297d23872fae979d7da614d4cf2730c4414b7eb26ad14095e619eeabd872619cd3e51293a4949fc04f214807cb10425da4a7ebe343df8a8f9af766f413
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,14 @@
|
|
2
2
|
|
3
3
|
## master (unrealeased)
|
4
4
|
|
5
|
+
## 1.0.7 (2021-08-30)
|
6
|
+
|
7
|
+
- Fix access to `let_it_be` variables in `after(:all)` hook. ([@cbarton][])
|
8
|
+
|
9
|
+
- Add support for using the before_all hook with Rails' parallelize feature (using processes). ([@peret][])
|
10
|
+
|
11
|
+
Make sure to include `TestProf::BeforeAll::Minitest` before you call `parallelize`.
|
12
|
+
|
5
13
|
## 1.0.6 (2021-06-23)
|
6
14
|
|
7
15
|
- Fix Spring detection when `DISABLE_SPRING=1` is used. ([@palkan][])
|
@@ -2,6 +2,22 @@
|
|
2
2
|
|
3
3
|
require "test_prof/before_all"
|
4
4
|
|
5
|
+
Minitest.singleton_class.prepend(Module.new do
|
6
|
+
attr_reader :previous_klass
|
7
|
+
@previous_klass = nil
|
8
|
+
|
9
|
+
def run_one_method(klass, method_name)
|
10
|
+
return super unless klass.respond_to?(:parallelized) && klass.parallelized
|
11
|
+
|
12
|
+
if @previous_klass && @previous_klass != klass
|
13
|
+
@previous_klass.before_all_executor&.deactivate!
|
14
|
+
end
|
15
|
+
@previous_klass = klass
|
16
|
+
|
17
|
+
super
|
18
|
+
end
|
19
|
+
end)
|
20
|
+
|
5
21
|
module TestProf
|
6
22
|
module BeforeAll
|
7
23
|
# Add before_all hook to Minitest: wrap all examples into a transaction and
|
@@ -83,6 +99,38 @@ module TestProf
|
|
83
99
|
class << self
|
84
100
|
def included(base)
|
85
101
|
base.extend ClassMethods
|
102
|
+
|
103
|
+
base.cattr_accessor :parallelized
|
104
|
+
if base.respond_to?(:parallelize_teardown)
|
105
|
+
base.parallelize_teardown do
|
106
|
+
last_klass = ::Minitest.previous_klass
|
107
|
+
if last_klass&.respond_to?(:parallelized) && last_klass&.parallelized
|
108
|
+
last_klass.before_all_executor&.deactivate!
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
if base.respond_to?(:parallelize)
|
114
|
+
base.singleton_class.prepend(Module.new do
|
115
|
+
def parallelize(workers: :number_of_processors, with: :processes)
|
116
|
+
# super.parallelize returns nil when no parallelization is set up
|
117
|
+
if super(workers: workers, with: with).nil?
|
118
|
+
return
|
119
|
+
end
|
120
|
+
|
121
|
+
case with
|
122
|
+
when :processes
|
123
|
+
self.parallelized = true
|
124
|
+
when :threads
|
125
|
+
warn "!!! before_all is not implemented for parallalization with threads and " \
|
126
|
+
"could work incorrectly"
|
127
|
+
else
|
128
|
+
warn "!!! tests are using an unknown parallelization strategy and before_all " \
|
129
|
+
"could work incorrectly"
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end)
|
133
|
+
end
|
86
134
|
end
|
87
135
|
end
|
88
136
|
|
@@ -118,7 +166,7 @@ module TestProf
|
|
118
166
|
def run(*)
|
119
167
|
super
|
120
168
|
ensure
|
121
|
-
before_all_executor&.deactivate!
|
169
|
+
before_all_executor&.deactivate! unless parallelized
|
122
170
|
end
|
123
171
|
end)
|
124
172
|
end
|
@@ -107,7 +107,7 @@ module TestProf
|
|
107
107
|
define_method(identifier) do
|
108
108
|
# Trying to detect the context
|
109
109
|
# Based on https://github.com/rspec/rspec-rails/commit/7cb796db064f58da7790a92e73ab906ef50b1f34
|
110
|
-
if
|
110
|
+
if /(before|after)\(:context\)/.match?(@__inspect_output) || @__inspect_output.include?("before_all")
|
111
111
|
instance_variable_get(:"#{PREFIX}#{identifier}")
|
112
112
|
else
|
113
113
|
# Fallback to let definition
|
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.7
|
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-08-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|