fork_break 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/fork_break.gemspec +3 -3
- data/lib/fork_break.rb +4 -0
- data/spec/fork_break_spec.rb +19 -9
- metadata +17 -23
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 47b8e876f9207b88a02d344a00c2d88bc9c39b60
|
4
|
+
data.tar.gz: 3dd3b0fb931ffb70c12e29b58a663d3bcd68bb06
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: dca4960c3a050d933cf8628907c74d5fce4663530b3afa393863920e2d21665f900690d36f1f711bc4b5e8448b5b6b295f0f54af83c3a24be2fb2aef14e45930
|
7
|
+
data.tar.gz: cb72d3c1a9676f5bfd77bff21d254bc6d37c55ef743ca745f64f74e32b84998222a09f8cbf1b39cfd83c3a3f0ff86e79c53a6b2125d64d56361b1886eb7f0154
|
data/fork_break.gemspec
CHANGED
@@ -14,7 +14,7 @@ breakpoints. It was originally built for testing the behaviour of database trans
|
|
14
14
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
15
15
|
gem.name = "fork_break"
|
16
16
|
gem.require_paths = ["lib"]
|
17
|
-
gem.version = "0.1.
|
18
|
-
gem.add_dependency "fork"
|
19
|
-
gem.add_development_dependency "rspec"
|
17
|
+
gem.version = "0.1.2"
|
18
|
+
gem.add_dependency "fork" , "= 1.0.1"
|
19
|
+
gem.add_development_dependency "rspec" , "= 3.1.0"
|
20
20
|
end
|
data/lib/fork_break.rb
CHANGED
@@ -45,6 +45,8 @@ module ForkBreak
|
|
45
45
|
raise BreakpointNotReachedError.new("Never reached breakpoint #{@next_breakpoint.inspect}")
|
46
46
|
end
|
47
47
|
end
|
48
|
+
rescue EOFError => exception
|
49
|
+
raise @fork.exception || exception
|
48
50
|
end
|
49
51
|
|
50
52
|
def finish
|
@@ -65,6 +67,8 @@ module ForkBreak
|
|
65
67
|
@next_breakpoint = @fork.receive_object unless symbol == :forkbreak_end
|
66
68
|
puts "#{@fork.pid} received #{@next_breakpoint}" if @debug
|
67
69
|
end
|
70
|
+
rescue EOFError => exception
|
71
|
+
raise @fork.exception || exception
|
68
72
|
end
|
69
73
|
end
|
70
74
|
end
|
data/spec/fork_break_spec.rb
CHANGED
@@ -12,16 +12,16 @@ module ForkBreak
|
|
12
12
|
breakpoints << :after_first_file
|
13
13
|
FileUtils.touch(second_file)
|
14
14
|
end
|
15
|
-
File.exists?(first_file).
|
16
|
-
File.exists?(second_file).
|
15
|
+
expect(File.exists?(first_file)).to be_falsey
|
16
|
+
expect(File.exists?(second_file)).to be_falsey
|
17
17
|
|
18
18
|
process.run_until(:after_first_file).wait
|
19
|
-
File.exists?(first_file).
|
20
|
-
File.exists?(second_file).
|
19
|
+
expect(File.exists?(first_file)).to be_truthy
|
20
|
+
expect(File.exists?(second_file)).to be_falsey
|
21
21
|
|
22
22
|
process.finish.wait
|
23
|
-
File.exists?(first_file).
|
24
|
-
File.exists?(second_file).
|
23
|
+
expect(File.exists?(first_file)).to be_truthy
|
24
|
+
expect(File.exists?(second_file)).to be_truthy
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -84,11 +84,21 @@ module ForkBreak
|
|
84
84
|
Dir.mktmpdir do |tmpdir|
|
85
85
|
counter_path = File.join(tmpdir, "counter")
|
86
86
|
|
87
|
-
counter_after_synced_execution(counter_path, with_lock = true).
|
87
|
+
expect(counter_after_synced_execution(counter_path, with_lock = true)).to eq(2)
|
88
88
|
|
89
89
|
File.unlink(counter_path)
|
90
|
-
counter_after_synced_execution(counter_path, with_lock = false).
|
90
|
+
expect(counter_after_synced_execution(counter_path, with_lock = false)).to eq(1)
|
91
91
|
end
|
92
92
|
end
|
93
|
+
|
94
|
+
it "raises the process exception" do
|
95
|
+
class MyException < StandardError; end
|
96
|
+
|
97
|
+
process = ForkBreak::Process.new do
|
98
|
+
raise MyException
|
99
|
+
end
|
100
|
+
|
101
|
+
expect { process.finish.wait }.to raise_error(MyException)
|
102
|
+
end
|
93
103
|
end
|
94
|
-
end
|
104
|
+
end
|
metadata
CHANGED
@@ -1,48 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fork_break
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Petter Remen
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-11-28 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: fork
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '='
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
19
|
+
version: 1.0.1
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - '='
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
26
|
+
version: 1.0.1
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rspec
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - '='
|
36
32
|
- !ruby/object:Gem::Version
|
37
|
-
version:
|
33
|
+
version: 3.1.0
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - '='
|
44
39
|
- !ruby/object:Gem::Version
|
45
|
-
version:
|
40
|
+
version: 3.1.0
|
46
41
|
description: Fork with breakpoints for syncing child process execution
|
47
42
|
email:
|
48
43
|
- petter.remen@gmail.com
|
@@ -50,8 +45,8 @@ executables: []
|
|
50
45
|
extensions: []
|
51
46
|
extra_rdoc_files: []
|
52
47
|
files:
|
53
|
-
- .gitignore
|
54
|
-
- .rspec
|
48
|
+
- ".gitignore"
|
49
|
+
- ".rspec"
|
55
50
|
- Gemfile
|
56
51
|
- LICENSE
|
57
52
|
- README.md
|
@@ -62,27 +57,26 @@ files:
|
|
62
57
|
- spec/spec_helper.rb
|
63
58
|
homepage: http://github.com/remen/fork_break
|
64
59
|
licenses: []
|
60
|
+
metadata: {}
|
65
61
|
post_install_message:
|
66
62
|
rdoc_options: []
|
67
63
|
require_paths:
|
68
64
|
- lib
|
69
65
|
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
-
none: false
|
71
66
|
requirements:
|
72
|
-
- -
|
67
|
+
- - ">="
|
73
68
|
- !ruby/object:Gem::Version
|
74
69
|
version: '0'
|
75
70
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
-
none: false
|
77
71
|
requirements:
|
78
|
-
- -
|
72
|
+
- - ">="
|
79
73
|
- !ruby/object:Gem::Version
|
80
74
|
version: '0'
|
81
75
|
requirements: []
|
82
76
|
rubyforge_project:
|
83
|
-
rubygems_version:
|
77
|
+
rubygems_version: 2.2.2
|
84
78
|
signing_key:
|
85
|
-
specification_version:
|
79
|
+
specification_version: 4
|
86
80
|
summary: Testing multiprocess behaviour is difficult and requires a way to synchronize
|
87
81
|
processes at specific execution points. This gem allows the parent process to control
|
88
82
|
the behaviour of child processes using breakpoints. It was originally built for
|