rubygems-test 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rubygems/commands/test_command.rb +49 -52
- metadata +3 -3
@@ -3,13 +3,10 @@ require 'rubygems/source_index'
|
|
3
3
|
require 'rubygems/specification'
|
4
4
|
require 'rubygems/dependency_installer'
|
5
5
|
require 'rubygems/user_interaction'
|
6
|
-
require 'fileutils'
|
7
|
-
require 'pathname'
|
8
6
|
require 'rbconfig'
|
9
7
|
require 'yaml'
|
10
8
|
require 'net/http'
|
11
9
|
require 'uri'
|
12
|
-
require 'ostruct'
|
13
10
|
|
14
11
|
class Gem::TestError < Gem::Exception; end
|
15
12
|
class Gem::RakeNotFoundError < Gem::Exception; end
|
@@ -19,7 +16,7 @@ class Gem::Commands::TestCommand < Gem::Command
|
|
19
16
|
include Gem::DefaultUserInteraction
|
20
17
|
|
21
18
|
# taken straight out of rake
|
22
|
-
DEFAULT_RAKEFILES = ['rakefile', 'Rakefile', 'rakefile.rb', 'Rakefile.rb']
|
19
|
+
DEFAULT_RAKEFILES = ['rakefile', 'Rakefile', 'rakefile.rb', 'Rakefile.rb']
|
23
20
|
|
24
21
|
def description
|
25
22
|
'Run the tests for a specific gem'
|
@@ -130,9 +127,9 @@ class Gem::Commands::TestCommand < Gem::Command
|
|
130
127
|
# Upload +yaml+ Results to +results_url+.
|
131
128
|
#
|
132
129
|
|
133
|
-
def upload_results(yaml)
|
130
|
+
def upload_results(yaml, results_url=nil)
|
134
131
|
begin
|
135
|
-
results_url
|
132
|
+
results_url ||= config["upload_service_url"] || 'http://gem-testers.org/test_results'
|
136
133
|
url = URI.parse(results_url)
|
137
134
|
response = Net::HTTP.post_form url, {:results => yaml}
|
138
135
|
rescue Errno::ECONNREFUSED => e
|
@@ -146,7 +143,12 @@ class Gem::Commands::TestCommand < Gem::Command
|
|
146
143
|
url = body[:data][0] if body[:data]
|
147
144
|
say "Test results posted successfully! \n\t#{url}"
|
148
145
|
when Net::HTTPRedirection
|
149
|
-
|
146
|
+
location = response.fetch('Location')
|
147
|
+
if !location or URI.parse(location) == url
|
148
|
+
say %[Caught redirection but was unable to redirect to #{location}.]
|
149
|
+
else
|
150
|
+
upload_results yaml, location
|
151
|
+
end
|
150
152
|
when Net::HTTPNotFound
|
151
153
|
say %q[Unable to find where to put the test results. Try: `gem update rubygems-test`]
|
152
154
|
when Net::HTTPClientError
|
@@ -186,69 +188,64 @@ class Gem::Commands::TestCommand < Gem::Command
|
|
186
188
|
# output.
|
187
189
|
#
|
188
190
|
def run_tests(spec, rake_path)
|
189
|
-
pwd = FileUtils.pwd
|
190
|
-
|
191
|
-
FileUtils.chdir(spec.full_gem_path)
|
192
|
-
|
193
191
|
output = ""
|
194
192
|
exit_status = nil
|
195
193
|
|
196
|
-
|
197
|
-
open_proc = proc do |pid, stdin, stdout, stderr|
|
198
|
-
loop do
|
199
|
-
if stdout.eof? and stderr.eof?
|
200
|
-
break
|
201
|
-
end
|
194
|
+
Dir.chdir(spec.full_gem_path) do
|
202
195
|
|
203
|
-
|
196
|
+
if spec.files.include?(".gemtest")
|
197
|
+
open_proc = proc do |pid, stdin, stdout, stderr|
|
198
|
+
loop do
|
199
|
+
if stdout.eof? and stderr.eof?
|
200
|
+
break
|
201
|
+
end
|
204
202
|
|
205
|
-
|
203
|
+
buf = ""
|
206
204
|
|
207
|
-
|
208
|
-
begin
|
209
|
-
io.readpartial(16384, buf)
|
210
|
-
rescue EOFError, IOError
|
211
|
-
next
|
212
|
-
end
|
213
|
-
end if handles
|
205
|
+
handles, _, _ = IO.select([stdout, stderr].reject { |x| x.closed? || x.eof? }, nil, nil, 0.1)
|
214
206
|
|
215
|
-
|
207
|
+
handles.each do |io|
|
208
|
+
begin
|
209
|
+
io.readpartial(16384, buf)
|
210
|
+
rescue EOFError, IOError
|
211
|
+
next
|
212
|
+
end
|
213
|
+
end if handles
|
216
214
|
|
217
|
-
|
218
|
-
end
|
219
|
-
end
|
215
|
+
output += buf
|
220
216
|
|
221
|
-
|
222
|
-
|
223
|
-
# left untested.
|
224
|
-
klass =
|
225
|
-
if IO.respond_to?(:open4)
|
226
|
-
IO
|
227
|
-
else
|
228
|
-
require 'open4'
|
229
|
-
Open4
|
217
|
+
print buf
|
218
|
+
end
|
230
219
|
end
|
231
220
|
|
232
|
-
|
221
|
+
# jruby stuffs it under IO, so we'll use that if it's available
|
222
|
+
# XXX I'm fairly sure that JRuby's gems don't support plugins, so this is
|
223
|
+
# left untested.
|
224
|
+
klass =
|
225
|
+
if IO.respond_to?(:open4)
|
226
|
+
IO
|
227
|
+
else
|
228
|
+
require 'open4'
|
229
|
+
Open4
|
230
|
+
end
|
233
231
|
|
234
|
-
|
235
|
-
(!config.has_key?("upload_results") and ask_yes_no("Upload these results to rubygems.org?", true))
|
232
|
+
exit_status = klass.popen4(rake_path, "test", '--trace', &open_proc)
|
236
233
|
|
237
|
-
upload_results
|
238
|
-
|
234
|
+
if config["upload_results"] or
|
235
|
+
(!config.has_key?("upload_results") and ask_yes_no("Upload these results to rubygems.org?", true))
|
239
236
|
|
240
|
-
|
241
|
-
|
237
|
+
upload_results(gather_results(spec, output, exit_status.exitstatus == 0))
|
238
|
+
end
|
242
239
|
|
243
|
-
|
240
|
+
if exit_status.exitstatus != 0
|
241
|
+
alert_error "Tests did not pass. Examine the output and report it to the author!"
|
244
242
|
|
245
|
-
|
243
|
+
raise Gem::TestError, "something"
|
244
|
+
end
|
245
|
+
else
|
246
|
+
alert_warning "This gem has no tests! Please contact the author to gain testing and reporting!"
|
246
247
|
end
|
247
|
-
else
|
248
|
-
alert_warning "This gem has no tests! Please contact the author to gain testing and reporting!"
|
249
248
|
end
|
250
|
-
|
251
|
-
FileUtils.chdir(pwd)
|
252
249
|
end
|
253
250
|
|
254
251
|
#
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 5
|
9
|
+
version: 0.1.5
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Erik Hollensbe
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-12-
|
18
|
+
date: 2010-12-26 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|