rubygems-update 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rubygems-update might be problematic. Click here for more details.

Files changed (65) hide show
  1. data.tar.gz.sig +2 -4
  2. data/ChangeLog +155 -0
  3. data/Rakefile +20 -5
  4. data/doc/release_notes/rel_1_3_0.rdoc +125 -0
  5. data/lib/rubygems.rb +107 -15
  6. data/lib/rubygems/commands/contents_command.rb +1 -1
  7. data/lib/rubygems/commands/environment_command.rb +40 -0
  8. data/lib/rubygems/commands/help_command.rb +2 -2
  9. data/lib/rubygems/commands/install_command.rb +15 -0
  10. data/lib/rubygems/commands/lock_command.rb +15 -6
  11. data/lib/rubygems/commands/outdated_command.rb +1 -1
  12. data/lib/rubygems/commands/pristine_command.rb +1 -1
  13. data/lib/rubygems/commands/query_command.rb +14 -9
  14. data/lib/rubygems/commands/rdoc_command.rb +5 -1
  15. data/lib/rubygems/commands/specification_command.rb +2 -2
  16. data/lib/rubygems/commands/unpack_command.rb +1 -1
  17. data/lib/rubygems/commands/update_command.rb +23 -14
  18. data/lib/rubygems/commands/which_command.rb +4 -3
  19. data/lib/rubygems/config_file.rb +25 -3
  20. data/lib/rubygems/defaults.rb +42 -11
  21. data/lib/rubygems/dependency_installer.rb +19 -15
  22. data/lib/rubygems/doc_manager.rb +162 -115
  23. data/lib/rubygems/ext/builder.rb +2 -2
  24. data/lib/rubygems/ext/rake_builder.rb +1 -1
  25. data/lib/rubygems/gem_path_searcher.rb +35 -19
  26. data/lib/rubygems/indexer.rb +15 -6
  27. data/lib/rubygems/install_update_options.rb +7 -0
  28. data/lib/rubygems/installer.rb +85 -9
  29. data/lib/rubygems/local_remote_options.rb +7 -0
  30. data/lib/rubygems/package/tar_reader.rb +7 -7
  31. data/lib/rubygems/platform.rb +1 -18
  32. data/lib/rubygems/remote_fetcher.rb +45 -54
  33. data/lib/rubygems/rubygems_version.rb +1 -1
  34. data/lib/rubygems/source_index.rb +22 -7
  35. data/lib/rubygems/source_info_cache.rb +9 -0
  36. data/lib/rubygems/spec_fetcher.rb +18 -20
  37. data/lib/rubygems/specification.rb +502 -293
  38. data/lib/rubygems/test_utilities.rb +19 -8
  39. data/lib/rubygems/uninstaller.rb +60 -26
  40. data/setup.rb +15 -7
  41. data/test/gemutilities.rb +84 -0
  42. data/test/mockgemui.rb +22 -2
  43. data/test/test_gem.rb +118 -13
  44. data/test/test_gem_commands_dependency_command.rb +1 -1
  45. data/test/test_gem_commands_list_command.rb +37 -0
  46. data/test/test_gem_commands_lock_command.rb +69 -0
  47. data/test/test_gem_commands_query_command.rb +40 -1
  48. data/test/test_gem_commands_uninstall_command.rb +60 -0
  49. data/test/test_gem_config_file.rb +51 -17
  50. data/test/test_gem_ext_configure_builder.rb +9 -9
  51. data/test/test_gem_ext_rake_builder.rb +21 -12
  52. data/test/test_gem_gem_path_searcher.rb +15 -7
  53. data/test/test_gem_indexer.rb +35 -1
  54. data/test/test_gem_install_update_options.rb +26 -5
  55. data/test/test_gem_installer.rb +93 -21
  56. data/test/test_gem_local_remote_options.rb +12 -0
  57. data/test/test_gem_platform.rb +6 -13
  58. data/test/test_gem_remote_fetcher.rb +121 -31
  59. data/test/test_gem_source_index.rb +74 -21
  60. data/test/test_gem_source_info_cache.rb +2 -1
  61. data/test/test_gem_spec_fetcher.rb +13 -3
  62. data/test/test_gem_specification.rb +13 -7
  63. data/test/test_gem_uninstaller.rb +25 -2
  64. metadata +6 -2
  65. metadata.gz.sig +0 -0
@@ -199,7 +199,7 @@ ERROR: Only reverse dependencies for local gems are supported.
199
199
  @fetcher.data["#{@gem_repo}Marshal.#{Gem.marshal_version}"] =
200
200
  si.dump
201
201
 
202
- @fetcher.data["#{@gem_repo}latest_specs.#{Gem.marshal_version}.gz"] = nil
202
+ @fetcher.data.delete "#{@gem_repo}latest_specs.#{Gem.marshal_version}.gz"
203
203
 
204
204
  FileUtils.rm File.join(@gemhome, 'specifications',
205
205
  "#{foo.full_name}.gemspec")
@@ -0,0 +1,37 @@
1
+ require 'test/unit'
2
+ require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
3
+ require 'rubygems/commands/list_command'
4
+
5
+ class TestGemCommandsListCommand < RubyGemTestCase
6
+
7
+ def setup
8
+ super
9
+
10
+ @cmd = Gem::Commands::ListCommand.new
11
+
12
+ util_setup_fake_fetcher
13
+
14
+ @si = util_setup_spec_fetcher @a1, @a2, @pl1
15
+
16
+ @fetcher.data["#{@gem_repo}Marshal.#{Gem.marshal_version}"] = proc do
17
+ raise Gem::RemoteFetcher::FetchError
18
+ end
19
+ end
20
+
21
+ def test_execute_installed
22
+ @cmd.handle_options %w[c --installed]
23
+
24
+ e = assert_raise Gem::SystemExitException do
25
+ use_ui @ui do
26
+ @cmd.execute
27
+ end
28
+ end
29
+
30
+ assert_equal 0, e.exit_code
31
+
32
+ assert_equal "true\n", @ui.output
33
+
34
+ assert_equal '', @ui.error
35
+ end
36
+
37
+ end
@@ -0,0 +1,69 @@
1
+ require 'test/unit'
2
+ require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
3
+ require 'rubygems/commands/lock_command'
4
+
5
+ class TestGemCommandsLockCommand < RubyGemTestCase
6
+
7
+ def setup
8
+ super
9
+
10
+ @a1 = quick_gem 'a', '1'
11
+ @b1 = quick_gem 'b', '1' do |s|
12
+ s.add_runtime_dependency 'a'
13
+ end
14
+
15
+ @d1 = quick_gem 'd', '1' do |s|
16
+ s.add_runtime_dependency 'z'
17
+ end
18
+
19
+ @cmd = Gem::Commands::LockCommand.new
20
+ end
21
+
22
+ def test_execute
23
+ @cmd.handle_options %w[b-1]
24
+
25
+ use_ui @ui do
26
+ @cmd.execute
27
+ end
28
+
29
+ expected = <<-EXPECTED
30
+ require 'rubygems'
31
+ gem 'b', '= 1'
32
+ gem 'a', '= 1'
33
+ EXPECTED
34
+
35
+ assert_equal expected, @ui.output
36
+ assert_equal '', @ui.error
37
+ end
38
+
39
+ def test_execute_missing_dependency
40
+ @cmd.handle_options %w[d-1]
41
+
42
+ use_ui @ui do
43
+ @cmd.execute
44
+ end
45
+
46
+ expected = <<-EXPECTED
47
+ require 'rubygems'
48
+ gem 'd', '= 1'
49
+ # Unable to satisfy 'z (>= 0, runtime)' from currently installed gems
50
+ EXPECTED
51
+
52
+ assert_equal expected, @ui.output
53
+ assert_equal '', @ui.error
54
+ end
55
+
56
+ def test_execute_strict
57
+ @cmd.handle_options %w[c-1 --strict]
58
+
59
+ e = assert_raise Gem::Exception do
60
+ use_ui @ui do
61
+ @cmd.execute
62
+ end
63
+ end
64
+
65
+ assert_equal 'Could not find gem c-1, try using the full name', e.message
66
+ end
67
+
68
+ end
69
+
@@ -180,7 +180,7 @@ pl (1)
180
180
  @fetcher.data["#{@gem_repo}Marshal.#{Gem.marshal_version}"] =
181
181
  si.dump
182
182
 
183
- @fetcher.data["#{@gem_repo}latest_specs.#{Gem.marshal_version}.gz"] = nil
183
+ @fetcher.data.delete "#{@gem_repo}latest_specs.#{Gem.marshal_version}.gz"
184
184
 
185
185
  @cmd.handle_options %w[-r]
186
186
 
@@ -265,6 +265,27 @@ pl (1)
265
265
  assert_equal '', @ui.error
266
266
  end
267
267
 
268
+ def test_execute_local_notty
269
+ @cmd.handle_options %w[]
270
+
271
+ @ui.outs.tty = false
272
+
273
+ use_ui @ui do
274
+ @cmd.execute
275
+ end
276
+
277
+ expected = <<-EOF
278
+ a (2, 1)
279
+ a_evil (9)
280
+ b (2)
281
+ c (1.2)
282
+ pl (1)
283
+ EOF
284
+
285
+ assert_equal expected, @ui.output
286
+ assert_equal '', @ui.error
287
+ end
288
+
268
289
  def test_execute_no_versions
269
290
  @cmd.handle_options %w[-r --no-versions]
270
291
 
@@ -284,5 +305,23 @@ pl
284
305
  assert_equal '', @ui.error
285
306
  end
286
307
 
308
+ def test_execute_notty
309
+ @cmd.handle_options %w[-r]
310
+
311
+ @ui.outs.tty = false
312
+
313
+ use_ui @ui do
314
+ @cmd.execute
315
+ end
316
+
317
+ expected = <<-EOF
318
+ a (2)
319
+ pl (1)
320
+ EOF
321
+
322
+ assert_equal expected, @ui.output
323
+ assert_equal '', @ui.error
324
+ end
325
+
287
326
  end
288
327
 
@@ -0,0 +1,60 @@
1
+ require 'test/unit'
2
+ require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
3
+ require File.join(File.expand_path(File.dirname(__FILE__)),
4
+ 'gem_installer_test_case')
5
+ require 'rubygems/commands/uninstall_command'
6
+
7
+ class TestGemCommandsUninstallCommand < GemInstallerTestCase
8
+
9
+ def setup
10
+ super
11
+
12
+ ui = MockGemUi.new
13
+ util_setup_gem ui
14
+
15
+ use_ui ui do
16
+ @installer.install
17
+ end
18
+
19
+ @cmd = Gem::Commands::UninstallCommand.new
20
+ @cmd.options[:executables] = true
21
+ @executable = File.join(@gemhome, 'bin', 'executable')
22
+ end
23
+
24
+ def test_execute_removes_executable
25
+ if win_platform?
26
+ assert_equal true, File.exist?(@executable)
27
+ else
28
+ assert_equal true, File.symlink?(@executable)
29
+ end
30
+
31
+ # Evil hack to prevent false removal success
32
+ FileUtils.rm_f @executable
33
+ File.open(@executable, "wb+") {|f| f.puts "binary"}
34
+
35
+ @cmd.options[:args] = Array(@spec.name)
36
+ use_ui @ui do
37
+ @cmd.execute
38
+ end
39
+
40
+ output = @ui.output.split "\n"
41
+ assert_match(/Removing executable/, output.shift)
42
+ assert_match(/Successfully uninstalled/, output.shift)
43
+ assert_equal false, File.exist?(@executable)
44
+ assert_nil output.shift, "UI output should have contained only two lines"
45
+ end
46
+
47
+ def test_execute_not_installed
48
+ @cmd.options[:args] = ["foo"]
49
+ e = assert_raise(Gem::InstallError) do
50
+ use_ui @ui do
51
+ @cmd.execute
52
+ end
53
+ end
54
+
55
+ assert_match(/\AUnknown gem foo >= 0$/, e.message)
56
+ output = @ui.output.split "\n"
57
+ assert output.empty?, "UI output should be empty after an uninstall error"
58
+ end
59
+ end
60
+
@@ -22,11 +22,15 @@ class TestGemConfigFile < RubyGemTestCase
22
22
  Gem::ConfigFile.send :remove_const, :SYSTEM_WIDE_CONFIG_FILE
23
23
  Gem::ConfigFile.send :const_set, :SYSTEM_WIDE_CONFIG_FILE,
24
24
  File.join(@tempdir, 'system-gemrc')
25
+ Gem::ConfigFile::OPERATING_SYSTEM_DEFAULTS.clear
26
+ Gem::ConfigFile::PLATFORM_DEFAULTS.clear
25
27
 
26
28
  util_config_file
27
29
  end
28
30
 
29
31
  def teardown
32
+ Gem::ConfigFile::OPERATING_SYSTEM_DEFAULTS.clear
33
+ Gem::ConfigFile::PLATFORM_DEFAULTS.clear
30
34
  Gem::ConfigFile.send :remove_const, :SYSTEM_WIDE_CONFIG_FILE
31
35
  Gem::ConfigFile.send :const_set, :SYSTEM_WIDE_CONFIG_FILE,
32
36
  @orig_SYSTEM_WIDE_CONFIG_FILE
@@ -53,6 +57,9 @@ class TestGemConfigFile < RubyGemTestCase
53
57
  fp.puts ":sources:"
54
58
  fp.puts " - http://more-gems.example.com"
55
59
  fp.puts "install: --wrappers"
60
+ fp.puts ":gempath:"
61
+ fp.puts "- /usr/ruby/1.8/lib/ruby/gems/1.8"
62
+ fp.puts "- /var/ruby/1.8/gem_home"
56
63
  end
57
64
 
58
65
  util_config_file
@@ -64,6 +71,8 @@ class TestGemConfigFile < RubyGemTestCase
64
71
  assert_equal false, @cfg.update_sources
65
72
  assert_equal %w[http://more-gems.example.com], Gem.sources
66
73
  assert_equal '--wrappers', @cfg[:install]
74
+ assert_equal(['/usr/ruby/1.8/lib/ruby/gems/1.8', '/var/ruby/1.8/gem_home'],
75
+ @cfg.path)
67
76
  end
68
77
 
69
78
  def test_initialize_handle_arguments_config_file
@@ -84,6 +93,48 @@ class TestGemConfigFile < RubyGemTestCase
84
93
  assert_equal @temp_conf, @cfg.config_file_name
85
94
  end
86
95
 
96
+ def test_initialize_operating_system_override
97
+ Gem::ConfigFile::OPERATING_SYSTEM_DEFAULTS[:bulk_threshold] = 1
98
+ Gem::ConfigFile::OPERATING_SYSTEM_DEFAULTS['install'] = '--no-env-shebang'
99
+
100
+ Gem::ConfigFile::PLATFORM_DEFAULTS[:bulk_threshold] = 2
101
+
102
+ util_config_file
103
+
104
+ assert_equal 2, @cfg.bulk_threshold
105
+ assert_equal '--no-env-shebang', @cfg[:install]
106
+ end
107
+
108
+ def test_initialize_platform_override
109
+ Gem::ConfigFile::PLATFORM_DEFAULTS[:bulk_threshold] = 2
110
+ Gem::ConfigFile::PLATFORM_DEFAULTS['install'] = '--no-env-shebang'
111
+
112
+ File.open Gem::ConfigFile::SYSTEM_WIDE_CONFIG_FILE, 'w' do |fp|
113
+ fp.puts ":bulk_threshold: 3"
114
+ end
115
+
116
+ util_config_file
117
+
118
+ assert_equal 3, @cfg.bulk_threshold
119
+ assert_equal '--no-env-shebang', @cfg[:install]
120
+ end
121
+
122
+ def test_initialize_system_wide_override
123
+ File.open Gem::ConfigFile::SYSTEM_WIDE_CONFIG_FILE, 'w' do |fp|
124
+ fp.puts ":backtrace: false"
125
+ fp.puts ":bulk_threshold: 2048"
126
+ end
127
+
128
+ File.open @temp_conf, 'w' do |fp|
129
+ fp.puts ":backtrace: true"
130
+ end
131
+
132
+ util_config_file
133
+
134
+ assert_equal 2048, @cfg.bulk_threshold
135
+ assert_equal true, @cfg.backtrace
136
+ end
137
+
87
138
  def test_handle_arguments
88
139
  args = %w[--backtrace --bunch --of --args here]
89
140
 
@@ -222,23 +273,6 @@ class TestGemConfigFile < RubyGemTestCase
222
273
  assert_equal %w[http://even-more-gems.example.com], Gem.sources
223
274
  end
224
275
 
225
- def test_global_config_file
226
- File.open(@temp_conf, 'w') do |fp|
227
- fp.puts ":backtrace: true"
228
- end
229
-
230
- File.open(File.join(Gem::ConfigFile::SYSTEM_WIDE_CONFIG_FILE),
231
- 'w') do |fp|
232
- fp.puts ":backtrace: false"
233
- fp.puts ":bulk_threshold: 2048"
234
- end
235
-
236
- util_config_file
237
-
238
- assert_equal 2048, @cfg.bulk_threshold
239
- assert @cfg.backtrace
240
- end
241
-
242
276
  def util_config_file(args = @cfg_args)
243
277
  @cfg = Gem::ConfigFile.new args
244
278
  end
@@ -29,12 +29,12 @@ class TestGemExtConfigureBuilder < RubyGemTestCase
29
29
  Gem::Ext::ConfigureBuilder.build nil, nil, @dest_path, output
30
30
  end
31
31
 
32
- expected = [
33
- "sh ./configure --prefix=#{@dest_path}",
34
- "", "make", "ok\n", "make install", "ok\n"
35
- ]
36
-
37
- assert_equal expected, output
32
+ assert_equal "sh ./configure --prefix=#{@dest_path}", output.shift
33
+ assert_equal "", output.shift
34
+ assert_equal "make", output.shift
35
+ assert_match(/^ok$/m, output.shift)
36
+ assert_equal "make install", output.shift
37
+ assert_match(/^ok$/m, output.shift)
38
38
  end
39
39
 
40
40
  def test_self_build_fail
@@ -47,9 +47,9 @@ class TestGemExtConfigureBuilder < RubyGemTestCase
47
47
  end
48
48
  end
49
49
 
50
- shell_error_msg = %r{(\./configure: No such file or directory)|(Can't open \./configure)}
50
+ shell_error_msg = %r{(\./configure: .*)|(Can't open \./configure)}
51
51
  sh_prefix_configure = "sh ./configure --prefix="
52
-
52
+
53
53
  expected = %r(configure failed:
54
54
 
55
55
  #{Regexp.escape sh_prefix_configure}#{Regexp.escape @dest_path}
@@ -59,7 +59,7 @@ class TestGemExtConfigureBuilder < RubyGemTestCase
59
59
  assert_match expected, error.message
60
60
 
61
61
  assert_equal "#{sh_prefix_configure}#{@dest_path}", output.shift
62
- assert_match %r(#{shell_error_msg}\n), output.shift
62
+ assert_match %r(#{shell_error_msg}), output.shift
63
63
  assert_equal true, output.empty?
64
64
  end
65
65
 
@@ -3,7 +3,6 @@ require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
3
3
  require 'rubygems/ext'
4
4
 
5
5
  class TestGemExtRakeBuilder < RubyGemTestCase
6
-
7
6
  def setup
8
7
  super
9
8
 
@@ -26,19 +25,25 @@ class TestGemExtRakeBuilder < RubyGemTestCase
26
25
  output = []
27
26
  realdir = nil # HACK /tmp vs. /private/tmp
28
27
 
29
- Dir.chdir @ext do
30
- realdir = Dir.pwd
31
- Gem::Ext::RakeBuilder.build 'mkrf_conf.rb', nil, @dest_path, output
28
+ build_rake_in do
29
+ Dir.chdir @ext do
30
+ realdir = Dir.pwd
31
+ Gem::Ext::RakeBuilder.build 'mkrf_conf.rb', nil, @dest_path, output
32
+ end
32
33
  end
33
34
 
35
+ output = output.join "\n"
36
+
34
37
  expected = [
35
- "#{Gem.ruby} mkrf_conf.rb",
38
+ "#{@@ruby} mkrf_conf.rb",
36
39
  "",
37
- "rake RUBYARCHDIR=#{@dest_path} RUBYLIBDIR=#{@dest_path}",
40
+ "#{@@rake} RUBYARCHDIR=#{@dest_path} RUBYLIBDIR=#{@dest_path}",
38
41
  "(in #{realdir})\n"
39
42
  ]
40
43
 
41
- assert_equal expected, output
44
+ assert_no_match %r%^rake failed:%, output
45
+ assert_match %r%^#{Regexp.escape @@ruby} mkrf_conf\.rb%, output
46
+ assert_match %r%^#{Regexp.escape @@rake} RUBYARCHDIR=#{Regexp.escape @dest_path} RUBYLIBDIR=#{Regexp.escape @dest_path}%, output
42
47
  end
43
48
 
44
49
  def test_class_build_fail
@@ -53,20 +58,24 @@ class TestGemExtRakeBuilder < RubyGemTestCase
53
58
  output = []
54
59
 
55
60
  error = assert_raise Gem::InstallError do
56
- Dir.chdir @ext do
57
- Gem::Ext::RakeBuilder.build "mkrf_conf.rb", nil, @dest_path, output
61
+ build_rake_in do
62
+ Dir.chdir @ext do
63
+ Gem::Ext::RakeBuilder.build "mkrf_conf.rb", nil, @dest_path, output
64
+ end
58
65
  end
59
66
  end
60
67
 
61
68
  expected = <<-EOF.strip
62
69
  rake failed:
63
70
 
64
- #{Gem.ruby} mkrf_conf.rb
71
+ #{@@ruby} mkrf_conf.rb
65
72
 
66
- rake RUBYARCHDIR=#{@dest_path} RUBYLIBDIR=#{@dest_path}
73
+ #{@@rake} RUBYARCHDIR=#{@dest_path} RUBYLIBDIR=#{@dest_path}
67
74
  EOF
68
75
 
69
- assert_equal expected, error.message.split("\n")[0..4].join("\n")
76
+ assert_match %r%^rake failed:%, error.message
77
+ assert_match %r%^#{Regexp.escape @@ruby} mkrf_conf\.rb%, error.message
78
+ assert_match %r%^#{Regexp.escape @@rake} RUBYARCHDIR=#{Regexp.escape @dest_path} RUBYLIBDIR=#{Regexp.escape @dest_path}%, error.message
70
79
  end
71
80
 
72
81
  end