async-rspec 1.4.0 → 1.5.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
2
  SHA256:
3
- metadata.gz: e3740c7d6640f8341b9c748d5d992e3fe815fb404c0096077de47f42437d9464
4
- data.tar.gz: a0e097113adadf7e7e5483cb2bf62184af9162d2f5320c9e38b95e7f94236142
3
+ metadata.gz: 4662aa08daa03184f72a9447f5c7d8567bd35f89692695f71febab03d4897297
4
+ data.tar.gz: d68401193d009f2fb6147e325628f65b76e53e2e921946464cfc1fe63985e9fa
5
5
  SHA512:
6
- metadata.gz: 1512325a47c8ee2c63336b598b3767545a8a0e85709c7ad2f2ff81620634a3cca389e29867609127f9e9699d814a67fb5318f7e5cea7be551aa274483f240a80
7
- data.tar.gz: fac2caaeaccc3b7206647f9a9456d106da12edd2745712d7b574ee35abee5b370abe6d8c46a92c164419c18666dcf69eb824631280b73a6b3c05c92cea796053
6
+ metadata.gz: 3ca947cc355d74542beec3b42de5e1c12dda183ff82cf119dc5537e6069842ede90995beafd2d597ecfd8e92cf4919237098ec187a50fd5ae5fa9bbdb59ccd7c
7
+ data.tar.gz: afd1957e91eab763e8ed16fe5a53820ebb88b6263d5bffcab789bce9d229be04e2e1e31f2346b751e99b8c8017ec668b3d8a5ad0ec5dee4287ce3c1d34050930
data/async-rspec.gemspec CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.add_dependency "rspec", "~> 3.0"
20
20
 
21
21
  # Since we test the shared contexts, we need some bits of async:
22
- spec.add_development_dependency "async"
22
+ spec.add_development_dependency "async", "~> 1.8"
23
23
  spec.add_development_dependency "ruby-prof"
24
24
 
25
25
  spec.add_development_dependency "bundler", "~> 1.13"
@@ -19,24 +19,49 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  require_relative 'leaks'
22
+
22
23
  require 'async/reactor'
24
+ require 'async/debug/selector'
23
25
 
24
26
  module Async
25
27
  module RSpec
26
28
  module Reactor
27
- def run_reactor(example, duration = nil)
29
+ def run_example(reactor, example, duration)
28
30
  result = nil
29
31
 
30
- duration ||= example.metadata[:timeout] || 60
31
-
32
- Async::Reactor.run do |task|
33
- task.timeout(duration) do
32
+ reactor.run do |task|
33
+ task.annotate(self.class)
34
+
35
+ reactor = task.reactor
36
+ timer = nil
37
+
38
+ if duration
39
+ timer = reactor.async do |task|
40
+ task.annotate("timer task duration=#{duration}")
41
+ task.sleep(duration)
42
+
43
+ buffer = StringIO.new
44
+ reactor.print_hierarchy(buffer)
45
+
46
+ reactor.stop
47
+
48
+ raise TimeoutError, "run time exceeded duration #{duration}s:\r\n#{buffer.string}"
49
+ end
50
+ end
51
+
52
+ task.async do |spec_task|
53
+ spec_task.annotate("example runner")
54
+
34
55
  result = example.run
35
56
 
36
- task.children.each(&:wait)
37
- end
57
+ if result.is_a? Exception
58
+ reactor.stop
59
+ else
60
+ spec_task.children.each(&:wait)
61
+ end
62
+ end.wait
38
63
 
39
- task.reactor.stop if result.is_a? Exception
64
+ timer.stop if timer
40
65
  end
41
66
 
42
67
  return result
@@ -46,12 +71,18 @@ module Async
46
71
  RSpec.shared_context Reactor do
47
72
  include Reactor
48
73
 
49
- let(:reactor) {Async::Task.current.reactor}
74
+ let(:reactor) {Async::Reactor.new(selector: Async::Debug::Selector.new)}
50
75
 
51
76
  include_context Async::RSpec::Leaks
52
77
 
53
78
  around(:each) do |example|
54
- run_reactor(example)
79
+ duration = example.metadata.fetch(:timeout, 60)
80
+
81
+ begin
82
+ run_example(reactor, example, duration)
83
+ ensure
84
+ reactor.close
85
+ end
55
86
  end
56
87
  end
57
88
  end
@@ -20,6 +20,6 @@
20
20
 
21
21
  module Async
22
22
  module RSpec
23
- VERSION = "1.4.0"
23
+ VERSION = "1.5.0"
24
24
  end
25
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: async-rspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-25 00:00:00.000000000 Z
11
+ date: 2018-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: async
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '1.8'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: '1.8'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: ruby-prof
43
43
  requirement: !ruby/object:Gem::Requirement