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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 8f2001796af195514438fa52362627e60627b0ac
4
- data.tar.gz: 6f69b87ae24322e2012e95f94d5e7e05d7502e34
2
+ SHA256:
3
+ metadata.gz: 185537a04c24f97f640c3bccbe044ff03d2c7da036db8cdcc9d336731745d5b6
4
+ data.tar.gz: 73eda2564df5355bb68b0674625fc27826309135330f0cb29178b6ce9120ae36
5
5
  SHA512:
6
- metadata.gz: 0d73abd17ee4bcefa1ab9ccc5c0de34dd1f4f069fbe5d7efe704919dbcebc8cca9e7cdd248df0a404b5874baa70db10345ed6dc3d398a2fb39023a1defde6d63
7
- data.tar.gz: 353c04c531393053b34347cb065215a1744c2e5768de5fee70ca4f09c7aed820b192b82f4d46adb9ecec7aead3d09496a3f0f8dd89004979bbdfad1fb0d10bfc
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
@@ -13,14 +13,16 @@ module Maxitest
13
13
  end
14
14
  end
15
15
 
16
- def capture_exceptions(*, &block)
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
- super do
23
- ::Timeout.timeout(timeout, TestCaseTimeout, &block)
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
@@ -1,3 +1,3 @@
1
1
  module Maxitest
2
- VERSION = "2.7.0"
2
+ VERSION = "2.8.0"
3
3
  end
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.7.0
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-06 00:00:00.000000000 Z
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.6.14
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