jettywrapper 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/.rvmrc CHANGED
@@ -1 +1 @@
1
- rvm use 1.8.7@hydra-testing --create
1
+ rvm use ree-1.8.7@jettywrapper --create
data/README.textile CHANGED
@@ -13,7 +13,7 @@ bc..
13
13
  :jetty_home => File.expand_path(File.dirname(__FILE__) + '/../../jetty'),
14
14
  :quiet => false,
15
15
  :jetty_port => 8983,
16
- :solr_home => File.expand_path(File.dirname(__FILE__) + '/../../jetty/solr'),
16
+ :solr_home => File.expand_path(File.dirname(__FILE__) + '/../../jetty/solr/test-core'),
17
17
  :fedora_home => File.expand_path(File.dirname(__FILE__) + '/../../jetty/fedora/default'),
18
18
  :startup_wait => 30
19
19
  }
@@ -29,5 +29,36 @@ bc..
29
29
  raise "test failures: #{error}" if error
30
30
  else
31
31
  system("rake hudson RAILS_ENV=test")
32
+ fail unless $?.success?
32
33
  end
33
34
  end
35
+
36
+ h2. Important note on creating nested rake tasks:
37
+
38
+ When creating your rake tasks, keep in mind that rake does not by default propogate up errors raised from system commands.
39
+ If you use system(), the return value will be false for any exit codes other than 0. If you use backticks or %x(), you must use $? to check the exit status code
40
+ after the call. Failure to do so could result in false successes.
41
+
42
+ h3. Example 1: Checking return value from system()
43
+
44
+ bc..
45
+ #retval should return false for non-zero exit codes
46
+ retval = system("rake hudson RAILS_ENV=test")
47
+ fail unless retval
48
+
49
+ h3. Example 2: Checking $? with system()
50
+
51
+ bc..
52
+ system("rake hudson RAILS_ENV=test")
53
+ raise "rake hudson encoutered errors" unless $?.success?
54
+
55
+ h3. Example 3: An alternative method: using %x[] or backticks with $?
56
+
57
+ bc..
58
+ # %x[] or `` will return everything sent to stdout from the command
59
+ puts %x[cucumber --tags ~@pending --tags ~@overwritten features]
60
+ raise "Cucumber failed." unless $?.success?
61
+
62
+
63
+
64
+
data/lib/jettywrapper.rb CHANGED
@@ -5,6 +5,7 @@ class Jettywrapper
5
5
  require 'singleton'
6
6
  include Singleton
7
7
 
8
+ attr_accessor :pid # If Jettywrapper is running, what pid is it running as?
8
9
  attr_accessor :port # What port should jetty start on? Default is 8888
9
10
  attr_accessor :jetty_home # Where is jetty located?
10
11
  attr_accessor :startup_wait # After jetty starts, how long to wait until starting the tests?
@@ -13,9 +14,9 @@ class Jettywrapper
13
14
  attr_accessor :fedora_home # Where is fedora located? Default is jetty_home/fedora
14
15
 
15
16
  # configure the singleton with some defaults
16
- def initialize
17
- @pid = nil
18
- end
17
+ # def initialize
18
+ # @pid = nil
19
+ # end
19
20
 
20
21
  class << self
21
22
 
@@ -109,8 +110,9 @@ class Jettywrapper
109
110
  if RUBY_PLATFORM =~ /mswin32/
110
111
  require 'win32/process'
111
112
 
112
- # start the solr server
113
+ # start jetty for windows
113
114
  def platform_specific_start
115
+ puts "Starting Jetty on windows"
114
116
  Dir.chdir(@jetty_home) do
115
117
  @pid = Process.create(
116
118
  :app_name => jetty_command,
@@ -122,7 +124,7 @@ class Jettywrapper
122
124
  end
123
125
  end
124
126
 
125
- # stop a running solr server
127
+ # stop jetty for windows
126
128
  def platform_specific_stop
127
129
  Process.kill(1, @pid)
128
130
  Process.wait
@@ -133,21 +135,18 @@ class Jettywrapper
133
135
  raise 'JRuby requires that you start solr manually, then run "rake spec" or "rake features"' if defined?(JRUBY_VERSION)
134
136
  end
135
137
 
136
- # start the solr server
138
+ # start jetty for *nix
137
139
  def platform_specific_start
138
-
139
- jruby_raise_error?
140
-
141
- puts self.inspect
140
+ jruby_raise_error?
142
141
  Dir.chdir(@jetty_home) do
143
- @pid = fork do
142
+ self.pid = fork do
144
143
  STDERR.close if @quiet
145
144
  exec jetty_command
146
145
  end
147
146
  end
148
147
  end
149
148
 
150
- # stop a running solr server
149
+ # stop jetty for *nix
151
150
  def platform_specific_stop
152
151
  jruby_raise_error?
153
152
  Process.kill('TERM', @pid)
@@ -1 +1 @@
1
- GEMVERSION = "0.0.3"
1
+ GEMVERSION = "0.0.4"
@@ -64,6 +64,16 @@ module Hydra
64
64
 
65
65
  end
66
66
 
67
+ it "has a pid if it has been started" do
68
+ jetty_params = {
69
+ :jetty_home => '/tmp'
70
+ }
71
+ ts = Jettywrapper.configure(jetty_params)
72
+ Jettywrapper.any_instance.stubs(:fork).returns(5454)
73
+ ts.start
74
+ ts.pid.should eql(5454)
75
+ end
76
+
67
77
  end # end of instantiation context
68
78
 
69
79
  context "wrapping a task" do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jettywrapper
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 3
10
- version: 0.0.3
9
+ - 4
10
+ version: 0.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Bess Sadler
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-21 00:00:00 -07:00
18
+ date: 2011-06-21 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -28,10 +28,10 @@ dependencies:
28
28
  segments:
29
29
  - 0
30
30
  version: "0"
31
- type: :development
32
31
  requirement: *id001
33
- prerelease: false
32
+ type: :development
34
33
  name: ruby-debug
34
+ prerelease: false
35
35
  - !ruby/object:Gem::Dependency
36
36
  version_requirements: &id002 !ruby/object:Gem::Requirement
37
37
  none: false
@@ -42,10 +42,10 @@ dependencies:
42
42
  segments:
43
43
  - 0
44
44
  version: "0"
45
- type: :development
46
45
  requirement: *id002
47
- prerelease: false
46
+ type: :development
48
47
  name: ruby-debug-base
48
+ prerelease: false
49
49
  - !ruby/object:Gem::Dependency
50
50
  version_requirements: &id003 !ruby/object:Gem::Requirement
51
51
  none: false
@@ -57,10 +57,10 @@ dependencies:
57
57
  - 2
58
58
  - 0
59
59
  version: "2.0"
60
- type: :development
61
60
  requirement: *id003
62
- prerelease: false
61
+ type: :development
63
62
  name: rspec
63
+ prerelease: false
64
64
  - !ruby/object:Gem::Dependency
65
65
  version_requirements: &id004 !ruby/object:Gem::Requirement
66
66
  none: false
@@ -73,10 +73,10 @@ dependencies:
73
73
  - 0
74
74
  - 0
75
75
  version: 2.0.0
76
- type: :development
77
76
  requirement: *id004
78
- prerelease: false
77
+ type: :development
79
78
  name: rspec-rails
79
+ prerelease: false
80
80
  - !ruby/object:Gem::Dependency
81
81
  version_requirements: &id005 !ruby/object:Gem::Requirement
82
82
  none: false
@@ -87,10 +87,10 @@ dependencies:
87
87
  segments:
88
88
  - 0
89
89
  version: "0"
90
- type: :development
91
90
  requirement: *id005
92
- prerelease: false
91
+ type: :development
93
92
  name: mocha
93
+ prerelease: false
94
94
  - !ruby/object:Gem::Dependency
95
95
  version_requirements: &id006 !ruby/object:Gem::Requirement
96
96
  none: false
@@ -103,10 +103,10 @@ dependencies:
103
103
  - 8
104
104
  - 5
105
105
  version: 0.8.5
106
- type: :development
107
106
  requirement: *id006
108
- prerelease: false
107
+ type: :development
109
108
  name: cucumber
109
+ prerelease: false
110
110
  - !ruby/object:Gem::Dependency
111
111
  version_requirements: &id007 !ruby/object:Gem::Requirement
112
112
  none: false
@@ -117,10 +117,10 @@ dependencies:
117
117
  segments:
118
118
  - 0
119
119
  version: "0"
120
- type: :development
121
120
  requirement: *id007
122
- prerelease: false
121
+ type: :development
123
122
  name: cucumber-rails
123
+ prerelease: false
124
124
  - !ruby/object:Gem::Dependency
125
125
  version_requirements: &id008 !ruby/object:Gem::Requirement
126
126
  none: false
@@ -131,10 +131,10 @@ dependencies:
131
131
  segments:
132
132
  - 0
133
133
  version: "0"
134
- type: :development
135
134
  requirement: *id008
136
- prerelease: false
135
+ type: :development
137
136
  name: gherkin
137
+ prerelease: false
138
138
  - !ruby/object:Gem::Dependency
139
139
  version_requirements: &id009 !ruby/object:Gem::Requirement
140
140
  none: false
@@ -145,10 +145,10 @@ dependencies:
145
145
  segments:
146
146
  - 0
147
147
  version: "0"
148
- type: :development
149
148
  requirement: *id009
150
- prerelease: false
149
+ type: :development
151
150
  name: rcov
151
+ prerelease: false
152
152
  - !ruby/object:Gem::Dependency
153
153
  version_requirements: &id010 !ruby/object:Gem::Requirement
154
154
  none: false
@@ -161,10 +161,10 @@ dependencies:
161
161
  - 6
162
162
  - 5
163
163
  version: 0.6.5
164
- type: :development
165
164
  requirement: *id010
166
- prerelease: false
165
+ type: :development
167
166
  name: yard
167
+ prerelease: false
168
168
  - !ruby/object:Gem::Dependency
169
169
  version_requirements: &id011 !ruby/object:Gem::Requirement
170
170
  none: false
@@ -175,10 +175,10 @@ dependencies:
175
175
  segments:
176
176
  - 0
177
177
  version: "0"
178
- type: :development
179
178
  requirement: *id011
180
- prerelease: false
179
+ type: :development
181
180
  name: RedCloth
181
+ prerelease: false
182
182
  description: Spin up a jetty instance (e.g., the one at https://github.com/projecthydra/hydra-jetty) and wrap test in it. This lets us run tests against a real copy of solr and fedora.
183
183
  email:
184
184
  - bess@stanford.edu