spork 1.0.0rc3 → 1.0.0rc4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +5 -5
- data/README.rdoc +1 -1
- data/features/support/bundler_helpers.rb +4 -2
- data/features/support/spork_world.rb +14 -2
- data/lib/spork/forker.rb +8 -6
- data/lib/spork/run_strategy/magazine.rb +17 -18
- data/lib/spork/run_strategy/magazine/magazine_slave.rb +0 -0
- data/lib/spork/run_strategy/magazine/magazine_slave_provider.rb +1 -0
- data/lib/spork/run_strategy/magazine/rinda_ring_finger_patch.rb +26 -0
- data/lib/spork/run_strategy/magazine/ring_server.rb +1 -0
- data/lib/spork/runner.rb +2 -1
- data/lib/spork/server.rb +3 -2
- metadata +7 -9
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 09e462e2026bb7d397b1123f2a5e68b7400d2144
|
4
|
+
data.tar.gz: dc63d581fde6cb9b5e88b252edfbe5351063a8ac
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f8b36602cd861efeaf3b8bc0c5f6a2fce3152366da42a00a938bab76b077be4c9c659d18d54b8c710c72168efd90b16b609bb31d2f1920da5c25f76b55e93a05
|
7
|
+
data.tar.gz: e9f8559eb56aed5a5f2a750651cb025d59629660f440942aa20ed49dc7ce8064c44372db536d0b975ab87bc76b72f09b3e5ab66846dd3f78aefc4e9dfa2efdfa
|
data/Gemfile
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
source
|
1
|
+
source 'https://rubygems.org'
|
2
2
|
gemspec
|
3
|
-
gem 'cucumber', '~>
|
4
|
-
gem 'rspec', '~>
|
3
|
+
gem 'cucumber', '~>1.3.2'
|
4
|
+
gem 'rspec', '~>2.13.0'
|
5
5
|
gem 'rake'
|
6
6
|
gem "spork", :path => File.expand_path("../", __FILE__)
|
7
7
|
|
8
|
-
if RUBY_VERSION =~ /^1\.9/
|
9
|
-
gem '
|
8
|
+
if RUBY_VERSION =~ /^2\.0|^1\.9/
|
9
|
+
gem 'debugger'
|
10
10
|
else
|
11
11
|
gem 'ruby-debug'
|
12
12
|
end
|
data/README.rdoc
CHANGED
@@ -2,8 +2,10 @@ module BundlerHelpers
|
|
2
2
|
extend self
|
3
3
|
def install_bundle(dir)
|
4
4
|
Dir.chdir(dir) do
|
5
|
-
command = "
|
6
|
-
|
5
|
+
command = "bundle install --gemfile=#{Dir.pwd}/Gemfile --path=#{Dir.pwd}/.bundle"
|
6
|
+
Bundler.with_clean_env do
|
7
|
+
system(command)
|
8
|
+
end
|
7
9
|
$?.exitstatus
|
8
10
|
end
|
9
11
|
end
|
@@ -53,7 +53,15 @@ class SporkWorld
|
|
53
53
|
stderr_file = Tempfile.new('spork')
|
54
54
|
stderr_file.close
|
55
55
|
in_current_dir do
|
56
|
-
|
56
|
+
if command.start_with?("rails new")
|
57
|
+
@last_stdout = `bundle exec #{command} 2> #{stderr_file.path}`
|
58
|
+
else
|
59
|
+
gemfile = ENV['BUNDLE_GEMFILE']
|
60
|
+
Bundler.with_clean_env do
|
61
|
+
ENV['BUNDLE_GEMFILE'] = gemfile
|
62
|
+
@last_stdout = `bundle exec #{command} 2> #{stderr_file.path}`
|
63
|
+
end
|
64
|
+
end
|
57
65
|
@last_exit_status = $?.exitstatus
|
58
66
|
end
|
59
67
|
@last_stderr = IO.read(stderr_file.path)
|
@@ -61,7 +69,11 @@ class SporkWorld
|
|
61
69
|
|
62
70
|
def run_in_background(command)
|
63
71
|
in_current_dir do
|
64
|
-
|
72
|
+
gemfile = ENV['BUNDLE_GEMFILE']
|
73
|
+
Bundler.with_clean_env do
|
74
|
+
ENV['BUNDLE_GEMFILE'] = gemfile
|
75
|
+
@background_job = BackgroundJob.run("bundle exec " + command)
|
76
|
+
end
|
65
77
|
end
|
66
78
|
@background_jobs << @background_job
|
67
79
|
@background_job
|
data/lib/spork/forker.rb
CHANGED
@@ -6,10 +6,10 @@
|
|
6
6
|
# sleep 3
|
7
7
|
# "success"
|
8
8
|
# end
|
9
|
-
#
|
9
|
+
#
|
10
10
|
# forker.result # => "success"
|
11
11
|
class Spork::Forker
|
12
|
-
|
12
|
+
|
13
13
|
# Raised if the fork died (was killed) before it sent it's response back.
|
14
14
|
class ForkDiedException < Exception; end
|
15
15
|
def initialize(&block)
|
@@ -23,16 +23,18 @@ class Spork::Forker
|
|
23
23
|
master_response = Marshal.load(@child_io)
|
24
24
|
rescue EOFError
|
25
25
|
nil
|
26
|
+
rescue SystemExit => e
|
27
|
+
puts "Error: exit code #{e.status}" unless e.status == 0
|
26
28
|
rescue Exception => e
|
27
29
|
puts "Exception encountered: #{e.inspect}\nbacktrace:\n#{e.backtrace * %(\n)}"
|
28
30
|
end
|
29
|
-
|
31
|
+
|
30
32
|
# terminate, skipping any at_exit blocks.
|
31
33
|
exit!(0)
|
32
34
|
end
|
33
35
|
@child_io.close
|
34
36
|
end
|
35
|
-
|
37
|
+
|
36
38
|
# Wait for the fork to finish running, and then return its return value.
|
37
39
|
#
|
38
40
|
# If the fork was aborted, then result returns nil.
|
@@ -52,7 +54,7 @@ class Spork::Forker
|
|
52
54
|
@child_pid = nil
|
53
55
|
@result
|
54
56
|
end
|
55
|
-
|
57
|
+
|
56
58
|
# abort the current running fork
|
57
59
|
def abort
|
58
60
|
if running?
|
@@ -61,7 +63,7 @@ class Spork::Forker
|
|
61
63
|
true
|
62
64
|
end
|
63
65
|
end
|
64
|
-
|
66
|
+
|
65
67
|
def running?
|
66
68
|
return false unless @child_pid
|
67
69
|
Process.getpgid(@child_pid)
|
@@ -2,6 +2,7 @@
|
|
2
2
|
# to boldly just run test after test
|
3
3
|
# as they come in
|
4
4
|
require 'drb'
|
5
|
+
require 'timeout'
|
5
6
|
require 'rinda/ring'
|
6
7
|
if RUBY_PLATFORM =~ /mswin|mingw/ and RUBY_VERSION < '1.9.1'
|
7
8
|
begin
|
@@ -16,6 +17,7 @@ require 'rubygems' # used for Gem.ruby
|
|
16
17
|
|
17
18
|
$:.unshift(File.dirname(__FILE__))
|
18
19
|
require 'magazine/magazine_slave'
|
20
|
+
require 'magazine/rinda_ring_finger_patch' if RUBY_VERSION > '1.9.1'
|
19
21
|
|
20
22
|
class Spork::RunStrategy::Magazine < Spork::RunStrategy
|
21
23
|
|
@@ -84,24 +86,21 @@ class Spork::RunStrategy::Magazine < Spork::RunStrategy
|
|
84
86
|
end
|
85
87
|
|
86
88
|
def run(argv, stderr, stdout)
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
else
|
103
|
-
puts '- NO tuple'; $stdout.flush
|
104
|
-
end
|
89
|
+
DRb.start_service
|
90
|
+
ts = Rinda::RingFinger.primary
|
91
|
+
Timeout.timeout(60) {sleep 0.1 until ts.read_all([:name, :MagazineSlave, nil, nil]).size > 0}
|
92
|
+
print ' <-- take tuple'; stdout.flush
|
93
|
+
tuple = ts.take([:name, :MagazineSlave, nil, nil])
|
94
|
+
slave = tuple[2]
|
95
|
+
id = tuple[3]
|
96
|
+
|
97
|
+
puts "(#{slave.id_num}); slave.run..."; $stdout.flush
|
98
|
+
begin
|
99
|
+
slave.run(argv,stderr,stdout)
|
100
|
+
puts " -- (#{slave.id_num});run done"; $stdout.flush
|
101
|
+
ensure
|
102
|
+
restart_slave(id)
|
103
|
+
end
|
105
104
|
end
|
106
105
|
|
107
106
|
def restart_slave(id)
|
File without changes
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# Patch for Rinda::RingFinger.primary hanging forever on Ruby 1.9.2 & 1.9.3
|
2
|
+
# from http://www.ruby-forum.com/topic/4229908
|
3
|
+
require 'rinda/ring'
|
4
|
+
|
5
|
+
module Rinda
|
6
|
+
class RingFinger
|
7
|
+
def lookup_ring_any(timeout=5)
|
8
|
+
queue = Queue.new
|
9
|
+
|
10
|
+
Thread.new do
|
11
|
+
self.lookup_ring(timeout) do |ts|
|
12
|
+
queue.push(ts)
|
13
|
+
end
|
14
|
+
queue.push(nil)
|
15
|
+
end
|
16
|
+
|
17
|
+
@primary = queue.pop
|
18
|
+
raise('RingNotFound') if @primary.nil?
|
19
|
+
while it = queue.pop
|
20
|
+
@rings.push(it)
|
21
|
+
end
|
22
|
+
|
23
|
+
@primary
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/spork/runner.rb
CHANGED
@@ -22,6 +22,7 @@ module Spork
|
|
22
22
|
opt.on("-b", "--bootstrap") {|ignore| @options[:bootstrap] = true }
|
23
23
|
opt.on("-d", "--diagnose") {|ignore| @options[:diagnose] = true }
|
24
24
|
opt.on("-h", "--help") {|ignore| @options[:help] = true }
|
25
|
+
opt.on("-q", "--quiet") {|ignore| @options[:quiet] = true }
|
25
26
|
opt.on("-p", "--port [PORT]") {|port| @options[:port] = port }
|
26
27
|
non_option_args = args.select { |arg| ! args[0].match(/^-/) }
|
27
28
|
@options[:server_matcher] = non_option_args[0]
|
@@ -72,7 +73,7 @@ module Spork
|
|
72
73
|
else
|
73
74
|
run_strategy = Spork::RunStrategy.factory(test_framework)
|
74
75
|
return(false) unless run_strategy.preload
|
75
|
-
Spork::Server.run(:port => @options[:port] || test_framework.default_port, :run_strategy => run_strategy)
|
76
|
+
Spork::Server.run(:port => @options[:port] || test_framework.default_port, :run_strategy => run_strategy, :quiet => @options[:quiet])
|
76
77
|
return true
|
77
78
|
end
|
78
79
|
end
|
data/lib/spork/server.rb
CHANGED
@@ -14,6 +14,7 @@ class Spork::Server
|
|
14
14
|
def initialize(options = {})
|
15
15
|
@run_strategy = options[:run_strategy]
|
16
16
|
@port = options[:port]
|
17
|
+
@quiet = options[:quiet]
|
17
18
|
end
|
18
19
|
|
19
20
|
def self.run(options = {})
|
@@ -44,9 +45,9 @@ class Spork::Server
|
|
44
45
|
#
|
45
46
|
# When implementing a test server, don't override this method: override run_tests instead.
|
46
47
|
def run(argv, stderr, stdout)
|
47
|
-
puts "Running tests with args #{argv.inspect}..."
|
48
|
+
puts "Running tests with args #{argv.inspect}..." unless @quiet
|
48
49
|
result = run_strategy.run(argv, stderr, stdout)
|
49
|
-
puts "Done.\n\n"
|
50
|
+
puts "Done.\n\n" unless @quiet
|
50
51
|
result
|
51
52
|
end
|
52
53
|
|
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spork
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
5
|
-
prerelease: 5
|
4
|
+
version: 1.0.0rc4
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Tim Harper
|
@@ -10,7 +9,7 @@ authors:
|
|
10
9
|
autorequire:
|
11
10
|
bindir: bin
|
12
11
|
cert_chain: []
|
13
|
-
date:
|
12
|
+
date: 2013-09-14 00:00:00.000000000 Z
|
14
13
|
dependencies: []
|
15
14
|
description: A forking Drb spec server
|
16
15
|
email:
|
@@ -35,6 +34,7 @@ files:
|
|
35
34
|
- lib/spork/run_strategy/forking.rb
|
36
35
|
- lib/spork/run_strategy/magazine/magazine_slave.rb
|
37
36
|
- lib/spork/run_strategy/magazine/magazine_slave_provider.rb
|
37
|
+
- lib/spork/run_strategy/magazine/rinda_ring_finger_patch.rb
|
38
38
|
- lib/spork/run_strategy/magazine/ring_server.rb
|
39
39
|
- lib/spork/run_strategy/magazine.rb
|
40
40
|
- lib/spork/run_strategy.rb
|
@@ -78,6 +78,7 @@ files:
|
|
78
78
|
- bin/spork
|
79
79
|
homepage: http://github.com/sporkrb/spork
|
80
80
|
licenses: []
|
81
|
+
metadata: {}
|
81
82
|
post_install_message:
|
82
83
|
rdoc_options:
|
83
84
|
- --main
|
@@ -85,20 +86,18 @@ rdoc_options:
|
|
85
86
|
require_paths:
|
86
87
|
- lib
|
87
88
|
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
-
none: false
|
89
89
|
requirements:
|
90
|
-
- -
|
90
|
+
- - '>='
|
91
91
|
- !ruby/object:Gem::Version
|
92
92
|
version: '0'
|
93
93
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
|
-
none: false
|
95
94
|
requirements:
|
96
|
-
- -
|
95
|
+
- - '>='
|
97
96
|
- !ruby/object:Gem::Version
|
98
97
|
version: '0'
|
99
98
|
requirements: []
|
100
99
|
rubyforge_project:
|
101
|
-
rubygems_version: 1.
|
100
|
+
rubygems_version: 2.1.3
|
102
101
|
signing_key:
|
103
102
|
specification_version: 3
|
104
103
|
summary: spork
|
@@ -131,4 +130,3 @@ test_files:
|
|
131
130
|
- spec/support/should_include_a_string_like.rb
|
132
131
|
- spec/support/test_io_streams.rb
|
133
132
|
- spec/support/tmp_project_helpers.rb
|
134
|
-
has_rdoc:
|