guard-spork 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +131 -0
- data/lib/guard/spork/runner.rb +17 -22
- data/lib/guard/spork/version.rb +1 -1
- metadata +14 -14
- data/README.rdoc +0 -112
data/README.md
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
# Guard::Spork [](http://travis-ci.org/guard/guard-spokr)
|
2
|
+
|
3
|
+
Guard::Spork allows to automatically & intelligently start/reload your RSpec/Cucumber/Test::Unit [Spork](https://github.com/timcharper/spork) server(s).
|
4
|
+
|
5
|
+
* Compatible with Spork 0.8.4 & 0.9.0.rcX.
|
6
|
+
* Tested against Ruby 1.8.7, 1.9.2, REE and the latest versions of JRuby & Rubinius.
|
7
|
+
|
8
|
+
## Install
|
9
|
+
|
10
|
+
Please be sure to have [Guard](https://github.com/guard/guard) installed before continue.
|
11
|
+
|
12
|
+
Install the gem:
|
13
|
+
|
14
|
+
$ gem install guard-spork
|
15
|
+
|
16
|
+
Add it to your Gemfile (inside test group):
|
17
|
+
|
18
|
+
gem 'guard-spork'
|
19
|
+
|
20
|
+
Add guard definition to your Guardfile with:
|
21
|
+
|
22
|
+
$ guard init spork
|
23
|
+
|
24
|
+
## Usage
|
25
|
+
|
26
|
+
Please read the [Guard usage documentation](https://github.com/guard/guard#readme).
|
27
|
+
|
28
|
+
## Guardfile
|
29
|
+
|
30
|
+
Please read [Guard doc](https://github.com/guard/guard#readme) for more info about the Guardfile DSL.
|
31
|
+
|
32
|
+
**IMPORTANT: place Spork guard before RSpec/Cucumber/Test::Unit guards!**
|
33
|
+
|
34
|
+
### Rails app
|
35
|
+
|
36
|
+
``` ruby
|
37
|
+
guard 'spork' do
|
38
|
+
watch('config/application.rb')
|
39
|
+
watch('config/environment.rb')
|
40
|
+
watch(%r{^config/environments/.*\.rb$})
|
41
|
+
watch(%r{^config/initializers/.*\.rb$})
|
42
|
+
watch('Gemfile')
|
43
|
+
watch('Gemfile.lock')
|
44
|
+
watch('spec/spec_helper.rb')
|
45
|
+
watch('test/test_helper.rb')
|
46
|
+
end
|
47
|
+
```
|
48
|
+
|
49
|
+
### Running specs over Spork
|
50
|
+
|
51
|
+
Pass the `:cli => "--drb"` option to [Guard::RSpec](https://github.com/guard/guard-rspec) and/or [Guard::Cucumber](https://github.com/guard/guard-cucumber) to run them over the Spork DRb server:
|
52
|
+
|
53
|
+
``` ruby
|
54
|
+
guard 'rspec', :cli => "--drb" do
|
55
|
+
# ...
|
56
|
+
end
|
57
|
+
|
58
|
+
guard 'cucumber', :cli => "--drb" do
|
59
|
+
# ...
|
60
|
+
end
|
61
|
+
```
|
62
|
+
|
63
|
+
For MiniTest Guard you should pass the `:drb => true` option:
|
64
|
+
|
65
|
+
``` ruby
|
66
|
+
guard 'minitest', :drb => true do
|
67
|
+
# ...
|
68
|
+
end
|
69
|
+
```
|
70
|
+
|
71
|
+
## Options
|
72
|
+
|
73
|
+
Guard::Spork automatically detect RSpec/Cucumber/Test::Unit/Bundler presence but you can disable any of them with the corresponding options:
|
74
|
+
|
75
|
+
``` ruby
|
76
|
+
guard 'spork', :cucumber => false, :bundler => false do
|
77
|
+
# ...
|
78
|
+
end
|
79
|
+
```
|
80
|
+
|
81
|
+
|
82
|
+
You can provide additional environment variables for RSpec, Cucumber, and Test::Unit with the <tt>:rspec_env</tt>, <tt>:cucumber_env</tt>, and <tt>:test_unit_env</tt> options:
|
83
|
+
|
84
|
+
``` ruby
|
85
|
+
guard 'spork', :cucumber_env => { 'RAILS_ENV' => 'cucumber' }, :rspec_env => { 'RAILS_ENV' => 'test' }, :test_unit_env => { 'RAILS_ENV' => 'test' } do
|
86
|
+
# ...
|
87
|
+
end
|
88
|
+
```
|
89
|
+
|
90
|
+
Available options:
|
91
|
+
|
92
|
+
``` ruby
|
93
|
+
:wait => 30 # Seconds to wait for the server to starts, default: 20
|
94
|
+
:cucumber => false
|
95
|
+
:rspec => false
|
96
|
+
:test_unit => false
|
97
|
+
:bundler => false # Don't use "bundle exec"
|
98
|
+
:test_unit_port => 1233 # Default: 8988
|
99
|
+
:rspec_port => 1234 # Default: 8989
|
100
|
+
:cucumber_port => 4321 # Default: 8990
|
101
|
+
:test_unit_env => { 'RAILS_ENV' => 'baz' } # Default: nil
|
102
|
+
:rspec_env => { 'RAILS_ENV' => 'foo' } # Default: nil
|
103
|
+
:cucumber_env => { 'RAILS_ENV' => 'bar' } # Default: nil
|
104
|
+
:aggressive_kills => false # Default: true, will search Spork pids from `ps aux` and kill them all on start.
|
105
|
+
```
|
106
|
+
|
107
|
+
## Common troubleshooting
|
108
|
+
|
109
|
+
If you can start Spork manually but get the following error message when using Guard::Spork:
|
110
|
+
|
111
|
+
Starting Spork for RSpec ERROR: Could not start Spork for RSpec/Cucumber. Make sure you can use it manually first.
|
112
|
+
|
113
|
+
Try to increase the value of the `:wait => 60` option before any further investigation.
|
114
|
+
|
115
|
+
## Development
|
116
|
+
|
117
|
+
* Source hosted at [GitHub](https://github.com/guard/guard-spork).
|
118
|
+
* Report issues and feature requests to [GitHub Issues](https://github.com/guard/guard-spork/issues).
|
119
|
+
|
120
|
+
Pull requests are very welcome! Please try to follow these simple "rules", though:
|
121
|
+
|
122
|
+
* Please create a topic branch for every separate change you make.
|
123
|
+
* Make sure your patches are well tested.
|
124
|
+
* Update the README (if applicable).
|
125
|
+
* Please **do not change** the version number.
|
126
|
+
|
127
|
+
For questions please join us on our [Google group](http://groups.google.com/group/guard-dev) or on `#guard` (irc.freenode.net).
|
128
|
+
|
129
|
+
## Author
|
130
|
+
|
131
|
+
[Thibaud Guillaume-Gentil](https://github.com/thibaudgg)
|
data/lib/guard/spork/runner.rb
CHANGED
@@ -8,15 +8,14 @@ module Guard
|
|
8
8
|
def initialize(options={})
|
9
9
|
options[:wait] ||= 20 # seconds
|
10
10
|
options[:test_unit_port] ||= 8988
|
11
|
-
options[:rspec_port] ||= 8989
|
12
11
|
options[:cucumber_port] ||= 8990
|
13
|
-
options[:
|
12
|
+
options[:rspec_port] ||= 8989
|
14
13
|
options[:rspec_env] ||= {}
|
14
|
+
options[:test_unit_env] ||= {}
|
15
15
|
options[:cucumber_env] ||= {}
|
16
|
+
options[:aggressive_kill] = true unless options[:aggressive_kill] == false
|
16
17
|
@options = options
|
17
18
|
ENV['SPORK_PIDS'] ||= ''
|
18
|
-
|
19
|
-
Signal.trap('CHLD', self.method(:reap_children))
|
20
19
|
end
|
21
20
|
|
22
21
|
def launch_sporks(action)
|
@@ -29,7 +28,10 @@ module Guard
|
|
29
28
|
|
30
29
|
def kill_sporks
|
31
30
|
UI.debug "Killing Spork servers with PID: #{spork_pids.join(', ')}"
|
32
|
-
spork_pids.each
|
31
|
+
spork_pids.each do |pid|
|
32
|
+
::Process.kill("KILL", pid)
|
33
|
+
remove_children(pid)
|
34
|
+
end
|
33
35
|
end
|
34
36
|
|
35
37
|
private
|
@@ -39,7 +41,6 @@ module Guard
|
|
39
41
|
raise "Fork failed." if pid == -1
|
40
42
|
|
41
43
|
unless pid
|
42
|
-
ignore_control_signals
|
43
44
|
if RUBY_VERSION > "1.9"
|
44
45
|
exec(env, cmd)
|
45
46
|
else
|
@@ -52,12 +53,6 @@ module Guard
|
|
52
53
|
pid
|
53
54
|
end
|
54
55
|
|
55
|
-
def ignore_control_signals
|
56
|
-
Signal.trap('QUIT', 'IGNORE')
|
57
|
-
Signal.trap('INT', 'IGNORE')
|
58
|
-
Signal.trap('TSTP', 'IGNORE')
|
59
|
-
end
|
60
|
-
|
61
56
|
def swap_env(env)
|
62
57
|
old_env = {}
|
63
58
|
env.each do |key, value|
|
@@ -72,15 +67,6 @@ module Guard
|
|
72
67
|
end
|
73
68
|
end
|
74
69
|
|
75
|
-
def reap_children(sig)
|
76
|
-
terminated_children.each do |stat|
|
77
|
-
pid = stat.pid
|
78
|
-
if remove_children(pid)
|
79
|
-
UI.debug "Reaping spork #{pid}"
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
70
|
def terminated_children
|
85
71
|
stats = []
|
86
72
|
loop do
|
@@ -129,6 +115,7 @@ module Guard
|
|
129
115
|
UI.reset_line # workaround before Guard::UI update
|
130
116
|
UI.error "Could not #{action} Spork server for #{sporked_gems}. Make sure you can use it manually first."
|
131
117
|
Notifier.notify "#{sporked_gems} NOT #{action}ed", :title => "Spork", :image => :failed
|
118
|
+
throw :task_has_failed
|
132
119
|
end
|
133
120
|
|
134
121
|
def add_children(pid)
|
@@ -144,7 +131,15 @@ module Guard
|
|
144
131
|
end
|
145
132
|
|
146
133
|
def spork_pids
|
147
|
-
ENV['SPORK_PIDS']
|
134
|
+
if ENV['SPORK_PIDS'] == '' && options[:aggressive_kill]
|
135
|
+
ps_spork_pids
|
136
|
+
else
|
137
|
+
ENV['SPORK_PIDS'].split(',').map { |pid| pid.to_i }
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
def ps_spork_pids
|
142
|
+
`ps aux | awk '/spork/&&!/awk/{print $2;}'`.split("\n").map { |pid| pid.to_i }
|
148
143
|
end
|
149
144
|
|
150
145
|
def sporked_gems
|
data/lib/guard/spork/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guard-spork
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,22 +9,22 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
12
|
+
date: 2011-10-08 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: guard
|
16
|
-
requirement: &
|
16
|
+
requirement: &70103270744260 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 0.8.
|
21
|
+
version: 0.8.4
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70103270744260
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: spork
|
27
|
-
requirement: &
|
27
|
+
requirement: &70103270743040 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 0.8.4
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70103270743040
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: bundler
|
38
|
-
requirement: &
|
38
|
+
requirement: &70103270742200 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '1.0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70103270742200
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rspec
|
49
|
-
requirement: &
|
49
|
+
requirement: &70103270741260 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '2.6'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70103270741260
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: guard-rspec
|
60
|
-
requirement: &
|
60
|
+
requirement: &70103270732320 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
version: '0.4'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70103270732320
|
69
69
|
description: Guard::Spork automatically manage Spork DRb servers.
|
70
70
|
email:
|
71
71
|
- thibaud@thibaud.me
|
@@ -78,7 +78,7 @@ files:
|
|
78
78
|
- lib/guard/spork/version.rb
|
79
79
|
- lib/guard/spork.rb
|
80
80
|
- LICENSE
|
81
|
-
- README.
|
81
|
+
- README.md
|
82
82
|
homepage: http://rubygems.org/gems/guard-spork
|
83
83
|
licenses: []
|
84
84
|
post_install_message:
|
data/README.rdoc
DELETED
@@ -1,112 +0,0 @@
|
|
1
|
-
= Guard::Spork
|
2
|
-
http://travis-ci.org/guard/guard-spork.png
|
3
|
-
|
4
|
-
Guard::Spork allows to automatically & intelligently start/reload your RSpec/Cucumber/Test::Unit {Spork}[https://github.com/timcharper/spork] server(s).
|
5
|
-
|
6
|
-
- Compatible with Spork 0.8.4 & 0.9.0.rcXX.
|
7
|
-
- Tested on Ruby 1.8.7, REE, 1.9.2 & Rubinius.
|
8
|
-
|
9
|
-
== Install
|
10
|
-
|
11
|
-
Please be sure to have {Guard}[https://github.com/guard/guard] installed before continue.
|
12
|
-
|
13
|
-
Install the gem:
|
14
|
-
|
15
|
-
gem install guard-spork
|
16
|
-
|
17
|
-
Add it to your Gemfile (inside test group):
|
18
|
-
|
19
|
-
gem 'guard-spork'
|
20
|
-
|
21
|
-
Add guard definition to your Guardfile with:
|
22
|
-
|
23
|
-
guard init spork
|
24
|
-
|
25
|
-
== Usage
|
26
|
-
|
27
|
-
Please read {Guard usage doc}[https://github.com/guard/guard#readme].
|
28
|
-
|
29
|
-
== Guardfile
|
30
|
-
|
31
|
-
Please read {Guard doc}[https://github.com/guard/guard#readme] for more info about the Guardfile DSL.
|
32
|
-
|
33
|
-
<b>IMPORTANT: place Spork guard before RSpec/Cucumber/Test::Unit guards!</b>
|
34
|
-
|
35
|
-
=== Rails app
|
36
|
-
|
37
|
-
guard 'spork' do
|
38
|
-
watch('config/application.rb')
|
39
|
-
watch('config/environment.rb')
|
40
|
-
watch(%r{^config/environments/.*\.rb$})
|
41
|
-
watch(%r{^config/initializers/.*\.rb$})
|
42
|
-
watch('Gemfile')
|
43
|
-
watch('Gemfile.lock')
|
44
|
-
watch('spec/spec_helper.rb')
|
45
|
-
watch('test/test_helper.rb')
|
46
|
-
end
|
47
|
-
|
48
|
-
=== Running specs over Spork
|
49
|
-
|
50
|
-
Pass the <tt>:cli => "--drb"</tt> option to {Guard::RSpec}[https://github.com/guard/guard-rspec] and/or {Guard::Cucumber}[https://github.com/guard/guard-cucumber] to run them over the Spork DRb server:
|
51
|
-
|
52
|
-
guard 'rspec', :cli => "--drb" do
|
53
|
-
...
|
54
|
-
end
|
55
|
-
|
56
|
-
guard 'cucumber', :cli => "--drb" do
|
57
|
-
...
|
58
|
-
end
|
59
|
-
|
60
|
-
For MiniTest Guard you should pass the `:drb => true` option:
|
61
|
-
|
62
|
-
guard 'minitest', :drb => true do
|
63
|
-
...
|
64
|
-
end
|
65
|
-
|
66
|
-
== Options
|
67
|
-
|
68
|
-
Guard::Spork automatically detect RSpec/Cucumber/Test::Unit/Bundler presence but you can disable any of them with the corresponding options:
|
69
|
-
|
70
|
-
guard 'spork', :cucumber => false, :bundler => false do
|
71
|
-
...
|
72
|
-
end
|
73
|
-
|
74
|
-
You can provide additional environment variables for RSpec, Cucumber, and Test::Unit with the <tt>:rspec_env</tt>, <tt>:cucumber_env</tt>, and <tt>:test_unit_env</tt> options:
|
75
|
-
|
76
|
-
guard 'spork', :cucumber_env => { 'RAILS_ENV' => 'cucumber' }, :rspec_env => { 'RAILS_ENV' => 'test' }, :test_unit_env => { 'RAILS_ENV' => 'test' } do
|
77
|
-
...
|
78
|
-
end
|
79
|
-
|
80
|
-
Available options:
|
81
|
-
|
82
|
-
:wait => 30 # Seconds to wait for the server to starts, default: 20
|
83
|
-
:cucumber => false
|
84
|
-
:rspec => false
|
85
|
-
:test_unit => false
|
86
|
-
:bundler => false # Don't use "bundle exec"
|
87
|
-
:test_unit_port => 1233 # Default: 8988
|
88
|
-
:rspec_port => 1234 # Default: 8989
|
89
|
-
:cucumber_port => 4321 # Default: 8990
|
90
|
-
:test_unit_env => { 'RAILS_ENV' => 'baz' } # Default: nil
|
91
|
-
:rspec_env => { 'RAILS_ENV' => 'foo' } # Default: nil
|
92
|
-
:cucumber_env => { 'RAILS_ENV' => 'bar' } # Default: nil
|
93
|
-
|
94
|
-
== Common troubleshooting
|
95
|
-
|
96
|
-
If you can start Spork manually but get the following error message when using Guard::Spork:
|
97
|
-
|
98
|
-
Starting Spork for RSpec ERROR: Could not start Spork for RSpec/Cucumber. Make sure you can use it manually first.
|
99
|
-
|
100
|
-
Try to increase the value of the <tt>:wait</tt> option before any further investigation.
|
101
|
-
|
102
|
-
== Development
|
103
|
-
|
104
|
-
- Source hosted at {GitHub}[https://github.com/guard/guard-spork]
|
105
|
-
- Report issues/Questions/Feature requests on {GitHub Issues}[https://github.com/guard/guard-spork/issues]
|
106
|
-
|
107
|
-
Pull requests are very welcome! Make sure your patches are well tested. Please create a topic branch for every separate change
|
108
|
-
you make.
|
109
|
-
|
110
|
-
== Authors
|
111
|
-
|
112
|
-
{Thibaud Guillaume-Gentil}[https://github.com/thibaudgg]
|