maxitest 2.7.0 → 2.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Readme.md +1 -0
- data/lib/maxitest/threads.rb +38 -0
- data/lib/maxitest/timeout.rb +5 -3
- data/lib/maxitest/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 185537a04c24f97f640c3bccbe044ff03d2c7da036db8cdcc9d336731745d5b6
|
4
|
+
data.tar.gz: 73eda2564df5355bb68b0674625fc27826309135330f0cb29178b6ce9120ae36
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0eb408cbd86df9eacd675e1141eb53800b94a2996e263a6d804d7addba159550b469ca5ae873332121566082f7063da44690204172219d842e352328f39a396b
|
7
|
+
data.tar.gz: 84015960efe73035b90a2f27049f5a09657199c36c29744e6603087b9f54c3c41fd60eaf28410744bd3a478929e9da22d142cfff904524327b709e1147da7610
|
data/Readme.md
CHANGED
@@ -20,6 +20,7 @@ Features
|
|
20
20
|
- implicit subject via `require 'maxitest/implicit_subject'`
|
21
21
|
- `xit` to skip test (also does not call setup or teardown)
|
22
22
|
- `require 'maxitest/timeout'` to make hanging tests fail after `Maxitest.timeout` seconds
|
23
|
+
- `require 'maxitest/threads'` fail tests that leave extra threads running
|
23
24
|
|
24
25
|
Install
|
25
26
|
=======
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# tests that leave extra threads running can break other tests in weird ways ... prevent that from happening
|
2
|
+
|
3
|
+
raise "Upgrade above minitest 5.0 to use this feature" if Minitest::VERSION.start_with?("5.0")
|
4
|
+
|
5
|
+
module Maxitest
|
6
|
+
module Threads
|
7
|
+
def setup
|
8
|
+
@maxitest_threads_before = Thread.list
|
9
|
+
super
|
10
|
+
end
|
11
|
+
|
12
|
+
def teardown
|
13
|
+
super
|
14
|
+
found = maxitest_extra_threads
|
15
|
+
raise "Test left #{found.size} extra threads (#{found})" if found.any?
|
16
|
+
ensure
|
17
|
+
maxitest_kill_extra_threads
|
18
|
+
end
|
19
|
+
|
20
|
+
# also a helper methods for users
|
21
|
+
def maxitest_wait_for_extra_threads
|
22
|
+
sleep 0.01 while maxitest_extra_threads.any?
|
23
|
+
end
|
24
|
+
|
25
|
+
# also a helper methods for users
|
26
|
+
def maxitest_kill_extra_threads
|
27
|
+
maxitest_extra_threads.map(&:kill).map(&:join)
|
28
|
+
end
|
29
|
+
|
30
|
+
def maxitest_extra_threads
|
31
|
+
Thread.list - @maxitest_threads_before
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# not using prepend since that would clash with webmock
|
37
|
+
# include works because original setup lives in also included Minitest::LifecycleHooks
|
38
|
+
Minitest::Test.send :include, Maxitest::Threads
|
data/lib/maxitest/timeout.rb
CHANGED
@@ -13,14 +13,16 @@ module Maxitest
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
def
|
16
|
+
def run(*, &block)
|
17
17
|
# NOTE: having a default def maxitest_timeout would break using let(:maxitest_timeout)
|
18
18
|
timeout = (defined?(maxitest_timeout) ? maxitest_timeout : Maxitest.timeout || 5)
|
19
19
|
if timeout == false
|
20
20
|
super
|
21
21
|
else
|
22
|
-
|
23
|
-
::Timeout.timeout(timeout, TestCaseTimeout
|
22
|
+
begin
|
23
|
+
::Timeout.timeout(timeout, TestCaseTimeout) { super }
|
24
|
+
rescue TestCaseTimeout => e
|
25
|
+
failures << UnexpectedError.new(e)
|
24
26
|
end
|
25
27
|
end
|
26
28
|
end
|
data/lib/maxitest/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: maxitest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Grosser
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -103,6 +103,7 @@ files:
|
|
103
103
|
- lib/maxitest/let_bang.rb
|
104
104
|
- lib/maxitest/pending.rb
|
105
105
|
- lib/maxitest/static_class_order.rb
|
106
|
+
- lib/maxitest/threads.rb
|
106
107
|
- lib/maxitest/timeout.rb
|
107
108
|
- lib/maxitest/trap.rb
|
108
109
|
- lib/maxitest/vendor/around.rb
|
@@ -132,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
132
133
|
version: '0'
|
133
134
|
requirements: []
|
134
135
|
rubyforge_project:
|
135
|
-
rubygems_version: 2.
|
136
|
+
rubygems_version: 2.7.3
|
136
137
|
signing_key:
|
137
138
|
specification_version: 4
|
138
139
|
summary: Minitest + all the features you always wanted
|