rubygems-test 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,4 @@
1
1
  require 'rubygems/version_option'
2
- require 'rubygems/source_index'
3
2
  require 'rubygems/specification'
4
3
  require 'rubygems/dependency_installer'
5
4
  require 'rubygems/user_interaction'
@@ -44,13 +43,6 @@ class Gem::Commands::TestCommand < Gem::Command
44
43
  add_version_option
45
44
  end
46
45
 
47
- #
48
- # Retrieve the source index
49
- #
50
- def source_index
51
- @gsi = Gem::SourceIndex.from_gems_in(*Gem::SourceIndex.installed_spec_directories)
52
- end
53
-
54
46
  #
55
47
  # Get the config in our namespace
56
48
  #
@@ -62,7 +54,7 @@ class Gem::Commands::TestCommand < Gem::Command
62
54
  # find a gem given a name and version
63
55
  #
64
56
  def find_gem(name, version)
65
- spec = source_index.find_name(name, version).last
57
+ spec = Gem.source_index.find_name(name, version).last
66
58
  unless spec and (spec.installation_path rescue nil)
67
59
  alert_error "Could not find gem #{name} (#{version})"
68
60
  raise Gem::GemNotFoundException, "Could not find gem #{name}, (#{version})"
@@ -106,7 +98,7 @@ class Gem::Commands::TestCommand < Gem::Command
106
98
  di = Gem::DependencyInstaller.new
107
99
 
108
100
  spec.development_dependencies.each do |dep|
109
- unless source_index.search(dep).last
101
+ unless Gem.source_index.search(dep).last
110
102
  if config["install_development_dependencies"]
111
103
  say "Installing test dependency #{dep.name} (#{dep.requirement})"
112
104
  di.install(dep)
@@ -116,7 +108,7 @@ class Gem::Commands::TestCommand < Gem::Command
116
108
  di.install(dep)
117
109
  else
118
110
  alert_error "Failed to install dependencies required to run tests. Aborting."
119
- raise Gem::TestError
111
+ raise Gem::TestError, "dependencies not installed"
120
112
  end
121
113
  end
122
114
  end
@@ -195,26 +187,37 @@ class Gem::Commands::TestCommand < Gem::Command
195
187
 
196
188
  if spec.files.include?(".gemtest")
197
189
  open_proc = proc do |pid, stdin, stdout, stderr|
198
- loop do
199
- if stdout.eof? and stderr.eof?
200
- break
201
- end
190
+ reader_proc = proc do |orig_handles|
202
191
 
203
- buf = ""
192
+ current_handles = orig_handles.dup
204
193
 
205
- handles, _, _ = IO.select([stdout, stderr].reject { |x| x.closed? || x.eof? }, nil, nil, 0.1)
194
+ handles, _, _ = IO.select(current_handles, nil, nil, 0.1)
195
+ buf = ""
206
196
 
207
197
  handles.each do |io|
208
198
  begin
209
199
  io.readpartial(16384, buf)
210
- rescue EOFError, IOError
211
- next
200
+ rescue EOFError
201
+ buf += io.read rescue ""
202
+ current_handles.reject!(io)
203
+ rescue IOError
204
+ current_handles.reject!(io)
212
205
  end
213
206
  end if handles
214
207
 
215
- output += buf
208
+ [buf, current_handles]
209
+ end
216
210
 
217
- print buf
211
+ begin
212
+ loop do
213
+ handles = [stdout, stderr]
214
+ buf, handles = reader_proc.call(handles)
215
+ output += buf
216
+ print buf
217
+ break unless handles
218
+ end
219
+ rescue StandardError
220
+ break
218
221
  end
219
222
  end
220
223
 
@@ -240,7 +243,7 @@ class Gem::Commands::TestCommand < Gem::Command
240
243
  if exit_status.exitstatus != 0
241
244
  alert_error "Tests did not pass. Examine the output and report it to the author!"
242
245
 
243
- raise Gem::TestError, "something"
246
+ raise Gem::TestError, "tests failed"
244
247
  end
245
248
  else
246
249
  alert_warning "This gem has no tests! Please contact the author to gain testing and reporting!"
@@ -259,7 +262,8 @@ class Gem::Commands::TestCommand < Gem::Command
259
262
  spec = find_gem(name, version)
260
263
 
261
264
  unless spec
262
- say usage
265
+ say "unable to find gem #{name} #{version}"
266
+ next
263
267
  end
264
268
 
265
269
  if spec.files.include?('.gemtest')
@@ -273,13 +277,9 @@ class Gem::Commands::TestCommand < Gem::Command
273
277
  run_tests(spec, rake_path)
274
278
  end
275
279
  end
276
- rescue Exception => e
277
- if @on_install
278
- raise e
279
- else
280
- say usage
281
- terminate_interaction 1
282
- end
280
+ rescue Gem::TestError
281
+ raise if @on_install
282
+ terminate_interaction 1
283
283
  end
284
284
  end
285
285
  end
data/test/helper.rb CHANGED
@@ -19,18 +19,17 @@ class Test::Unit::TestCase
19
19
  path = file.path
20
20
  file.close
21
21
 
22
- pwd = FileUtils.pwd
23
- FileUtils.chdir('gems')
24
-
25
- spec = eval File.read(path)
26
- filename = Gem::Builder.new(spec).build
27
- Gem::Installer.new(filename).install
28
-
29
- FileUtils.chdir(pwd)
22
+ FileUtils.chdir('gems') do
23
+ spec = eval File.read(path)
24
+ filename = Gem::Builder.new(spec).build
25
+ Gem::Installer.new(filename).install
26
+ Gem.refresh
27
+ end
30
28
  end
31
29
 
32
30
  def uninstall_stub_gem
33
31
  Gem::Uninstaller.new("test-gem").uninstall
32
+ Gem.refresh
34
33
  end
35
34
 
36
35
  def template_gemspec(hash)
data/test/test_execute.rb CHANGED
@@ -21,16 +21,6 @@ class TestExecute < Test::Unit::TestCase
21
21
  assert_equal @test.usage, "#{@test.program_name} GEM -v VERSION"
22
22
  end
23
23
 
24
- def test_03_source_index
25
- install_stub_gem({ })
26
-
27
- assert @test.source_index
28
- assert_kind_of Array, @test.source_index.find_name("test-gem", Gem::Version.new("0.0.0"))
29
- assert_kind_of Gem::Specification, @test.source_index.find_name("test-gem", Gem::Version.new("0.0.0")).last
30
-
31
- uninstall_stub_gem
32
- end
33
-
34
24
  def test_04_find_gem
35
25
  install_stub_gem({ })
36
26
 
@@ -38,7 +28,9 @@ class TestExecute < Test::Unit::TestCase
38
28
 
39
29
  uninstall_stub_gem
40
30
 
41
- assert_raises(Gem::GemNotFoundException) { @test.find_gem("test-gem", "0.0.0") }
31
+ assert_raises(Gem::GemNotFoundException) {
32
+ @test.find_gem("test-gem", "0.0.0")
33
+ }
42
34
  end
43
35
 
44
36
  def test_05_find_rakefile
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubygems-test
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 6
10
- version: 0.1.6
9
+ - 7
10
+ version: 0.1.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Erik Hollensbe
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-12-28 00:00:00 -05:00
19
+ date: 2011-01-02 00:00:00 -05:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -61,7 +61,6 @@ files:
61
61
  - Rakefile
62
62
  - gems/Rakefile
63
63
  - gems/template.gemspec
64
- - gems/test-gem-0.0.0.gem
65
64
  - gems/test/test_pass.rb
66
65
  - lib/open4.rb
67
66
  - lib/rubygems/commands/test_command.rb
Binary file