rubygems-update 1.3.6 → 1.3.7

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 (80) hide show
  1. data.tar.gz.sig +0 -0
  2. data/ChangeLog +86 -0
  3. data/History.txt +34 -1
  4. data/Manifest.txt +6 -1
  5. data/Rakefile +79 -34
  6. data/lib/rubygems.rb +52 -30
  7. data/lib/rubygems/builder.rb +2 -0
  8. data/lib/rubygems/command.rb +12 -0
  9. data/lib/rubygems/command_manager.rb +17 -12
  10. data/lib/rubygems/commands/contents_command.rb +1 -1
  11. data/lib/rubygems/commands/dependency_command.rb +3 -1
  12. data/lib/rubygems/commands/environment_command.rb +3 -2
  13. data/lib/rubygems/commands/fetch_command.rb +7 -3
  14. data/lib/rubygems/commands/install_command.rb +2 -1
  15. data/lib/rubygems/commands/query_command.rb +16 -3
  16. data/lib/rubygems/commands/server_command.rb +5 -3
  17. data/lib/rubygems/commands/setup_command.rb +1 -1
  18. data/lib/rubygems/commands/unpack_command.rb +35 -23
  19. data/lib/rubygems/commands/update_command.rb +1 -1
  20. data/lib/rubygems/defaults.rb +4 -6
  21. data/lib/rubygems/dependency.rb +32 -6
  22. data/lib/rubygems/dependency_installer.rb +10 -3
  23. data/lib/rubygems/doc_manager.rb +5 -2
  24. data/lib/rubygems/errors.rb +35 -0
  25. data/lib/rubygems/exceptions.rb +10 -1
  26. data/lib/rubygems/indexer.rb +1 -1
  27. data/lib/rubygems/installer.rb +6 -5
  28. data/lib/rubygems/package.rb +6 -3
  29. data/lib/rubygems/package/f_sync_dir.rb +4 -3
  30. data/lib/rubygems/package/tar_header.rb +4 -3
  31. data/lib/rubygems/package/tar_output.rb +4 -3
  32. data/lib/rubygems/package/tar_reader.rb +4 -3
  33. data/lib/rubygems/package/tar_writer.rb +4 -3
  34. data/lib/rubygems/package_task.rb +4 -3
  35. data/lib/rubygems/platform.rb +4 -1
  36. data/lib/rubygems/remote_fetcher.rb +9 -3
  37. data/lib/rubygems/requirement.rb +5 -0
  38. data/lib/rubygems/security.rb +3 -3
  39. data/lib/rubygems/server.rb +33 -18
  40. data/lib/rubygems/source_index.rb +4 -4
  41. data/lib/rubygems/source_info_cache.rb +4 -2
  42. data/lib/rubygems/spec_fetcher.rb +33 -11
  43. data/lib/rubygems/specification.rb +40 -32
  44. data/lib/rubygems/test_utilities.rb +2 -2
  45. data/lib/rubygems/validator.rb +3 -4
  46. data/lib/rubygems/version.rb +1 -1
  47. data/test/gem_package_tar_test_case.rb +2 -2
  48. data/test/gemutilities.rb +15 -9
  49. data/test/insure_session.rb +1 -1
  50. data/test/plugin/exception/rubygems_plugin.rb +2 -0
  51. data/test/plugin/load/rubygems_plugin.rb +1 -0
  52. data/test/plugin/standarderror/rubygems_plugin.rb +2 -0
  53. data/test/rubygems/commands/crash_command.rb +5 -0
  54. data/test/rubygems_plugin.rb +5 -0
  55. data/test/simple_gem.rb +15 -15
  56. data/test/test_gem.rb +45 -2
  57. data/test/test_gem_command_manager.rb +14 -0
  58. data/test/test_gem_commands_contents_command.rb +7 -5
  59. data/test/test_gem_commands_environment_command.rb +3 -1
  60. data/test/test_gem_commands_fetch_command.rb +21 -1
  61. data/test/test_gem_commands_install_command.rb +2 -4
  62. data/test/test_gem_commands_query_command.rb +33 -6
  63. data/test/test_gem_commands_server_command.rb +9 -2
  64. data/test/test_gem_commands_uninstall_command.rb +4 -2
  65. data/test/test_gem_commands_unpack_command.rb +46 -2
  66. data/test/test_gem_config_file.rb +2 -0
  67. data/test/test_gem_dependency.rb +11 -0
  68. data/test/test_gem_doc_manager.rb +1 -1
  69. data/test/test_gem_indexer.rb +2 -2
  70. data/test/test_gem_installer.rb +1 -1
  71. data/test/test_gem_package_tar_input.rb +1 -1
  72. data/test/test_gem_package_tar_writer.rb +3 -3
  73. data/test/test_gem_platform.rb +19 -0
  74. data/test/test_gem_server.rb +11 -0
  75. data/test/test_gem_source_index.rb +2 -2
  76. data/test/test_gem_spec_fetcher.rb +42 -0
  77. data/test/test_gem_specification.rb +46 -7
  78. data/util/{gem_prelude.rb.template → gem_prelude.rb} +53 -23
  79. metadata +16 -6
  80. metadata.gz.sig +0 -0
data/test/test_gem.rb CHANGED
@@ -16,6 +16,8 @@ class TestGem < RubyGemTestCase
16
16
  else
17
17
  %r|/[Rr]uby/[Gg]ems/[0-9.]+|
18
18
  end
19
+
20
+ util_remove_interrupt_command
19
21
  end
20
22
 
21
23
  def test_self_all_load_paths
@@ -258,6 +260,8 @@ class TestGem < RubyGemTestCase
258
260
 
259
261
  def test_self_find_files
260
262
  discover_path = File.join 'lib', 'foo', 'discover.rb'
263
+ cwd = File.expand_path '..', __FILE__
264
+ $LOAD_PATH.unshift cwd.dup
261
265
 
262
266
  foo1 = quick_gem 'foo', '1' do |s|
263
267
  s.files << discover_path
@@ -281,12 +285,14 @@ class TestGem < RubyGemTestCase
281
285
  Gem.searcher = nil
282
286
 
283
287
  expected = [
284
- File.expand_path('foo/discover.rb', File.dirname(__FILE__)),
288
+ File.expand_path('../foo/discover.rb', __FILE__),
285
289
  File.join(foo2.full_gem_path, discover_path),
286
290
  File.join(foo1.full_gem_path, discover_path),
287
291
  ]
288
292
 
289
293
  assert_equal expected, Gem.find_files('foo/discover')
294
+ ensure
295
+ assert_equal cwd, $LOAD_PATH.shift
290
296
  end
291
297
 
292
298
  def test_self_latest_load_paths
@@ -437,7 +443,7 @@ class TestGem < RubyGemTestCase
437
443
  def test_self_refresh
438
444
  util_make_gems
439
445
 
440
- a1_spec = File.join @gemhome, "specifications", @a1.spec_name
446
+ a1_spec = File.join @gemhome, "specifications", @a1.spec_name
441
447
 
442
448
  FileUtils.mv a1_spec, @tempdir
443
449
 
@@ -613,6 +619,38 @@ class TestGem < RubyGemTestCase
613
619
  ENV['USERPATH'] = orig_user_path
614
620
  end if '1.9' > RUBY_VERSION
615
621
 
622
+ def test_load_plugins
623
+ with_plugin('load') { Gem.load_plugins }
624
+ assert_equal :loaded, TEST_PLUGIN_LOAD
625
+
626
+ util_remove_interrupt_command
627
+
628
+ # Should attempt to cause a StandardError
629
+ with_plugin('standarderror') { Gem.load_plugins }
630
+ assert_equal :loaded, TEST_PLUGIN_STANDARDERROR
631
+
632
+ util_remove_interrupt_command
633
+
634
+ # Should attempt to cause an Exception
635
+ with_plugin('exception') { Gem.load_plugins }
636
+ assert_equal :loaded, TEST_PLUGIN_EXCEPTION
637
+ end
638
+
639
+ def with_plugin(path)
640
+ test_plugin_path = File.expand_path "../plugin/#{path}", __FILE__
641
+
642
+ # A single test plugin should get loaded once only, in order to preserve
643
+ # sane test semantics.
644
+ refute_includes $LOAD_PATH, test_plugin_path
645
+ $LOAD_PATH.unshift test_plugin_path
646
+
647
+ capture_io do
648
+ yield
649
+ end
650
+ ensure
651
+ $LOAD_PATH.delete test_plugin_path
652
+ end
653
+
616
654
  def util_ensure_gem_dirs
617
655
  Gem.ensure_gem_subdirectories @gemhome
618
656
  @additional.each do |dir|
@@ -661,5 +699,10 @@ class TestGem < RubyGemTestCase
661
699
  defined?(@RUBY_REVISION)
662
700
  end
663
701
 
702
+ def util_remove_interrupt_command
703
+ Gem::Commands.send :remove_const, :InterruptCommand if
704
+ Gem::Commands.const_defined? :InterruptCommand
705
+ end
706
+
664
707
  end
665
708
 
@@ -10,6 +10,8 @@ class TestGemCommandManager < RubyGemTestCase
10
10
  end
11
11
 
12
12
  def test_run_interrupt
13
+ Gem.load_plugins
14
+
13
15
  use_ui @ui do
14
16
  assert_raises MockGemUi::TermError do
15
17
  @command_manager.run 'interrupt'
@@ -19,6 +21,18 @@ class TestGemCommandManager < RubyGemTestCase
19
21
  end
20
22
  end
21
23
 
24
+ def test_run_crash_command
25
+ @command_manager.register_command :crash
26
+ use_ui @ui do
27
+ assert_raises MockGemUi::TermError do
28
+ @command_manager.run 'crash'
29
+ end
30
+ assert_equal '', ui.output
31
+ err = ui.error.split("\n").first
32
+ assert_equal "ERROR: Loading command: crash (RuntimeError)", err
33
+ end
34
+ end
35
+
22
36
  def test_process_args_bad_arg
23
37
  use_ui @ui do
24
38
  assert_raises(MockGemUi::TermError) {
@@ -139,13 +139,15 @@ Rakefile
139
139
  end
140
140
 
141
141
  def test_handle_options
142
- assert_equal false, @cmd.options[:lib_only]
143
- assert_equal [], @cmd.options[:specdirs]
144
- assert_equal nil, @cmd.options[:version]
142
+ refute @cmd.options[:lib_only]
143
+ assert @cmd.options[:prefix]
144
+ assert_empty @cmd.options[:specdirs]
145
+ assert_nil @cmd.options[:version]
145
146
 
146
- @cmd.send :handle_options, %w[-l -s foo --version 0.0.2]
147
+ @cmd.send :handle_options, %w[-l -s foo --version 0.0.2 --no-prefix]
147
148
 
148
- assert_equal true, @cmd.options[:lib_only]
149
+ assert @cmd.options[:lib_only]
150
+ refute @cmd.options[:prefix]
149
151
  assert_equal %w[foo], @cmd.options[:specdirs]
150
152
  assert_equal Gem::Requirement.new('0.0.2'), @cmd.options[:version]
151
153
  end
@@ -12,6 +12,7 @@ class TestGemCommandsEnvironmentCommand < RubyGemTestCase
12
12
  def test_execute
13
13
  orig_sources = Gem.sources.dup
14
14
  Gem.sources.replace %w[http://gems.example.com]
15
+ Gem.configuration['gemcutter_key'] = 'blah'
15
16
 
16
17
  @cmd.send :handle_options, %w[]
17
18
 
@@ -32,6 +33,7 @@ class TestGemCommandsEnvironmentCommand < RubyGemTestCase
32
33
  assert_match %r|GEM PATHS:|, @ui.output
33
34
  assert_match %r|- #{Regexp.escape @gemhome}|, @ui.output
34
35
  assert_match %r|GEM CONFIGURATION:|, @ui.output
36
+ assert_match %r|"gemcutter_key" => "\*\*\*\*"|, @ui.output
35
37
  assert_match %r|:verbose => |, @ui.output
36
38
  assert_match %r|REMOTE SOURCES:|, @ui.output
37
39
  assert_equal '', @ui.error
@@ -125,7 +127,7 @@ class TestGemCommandsEnvironmentCommand < RubyGemTestCase
125
127
  @cmd.execute
126
128
  end
127
129
 
128
- assert_equal "#{Gem::RubyGemsVersion}\n", @ui.output
130
+ assert_equal "#{Gem::VERSION}\n", @ui.output
129
131
  assert_equal '', @ui.error
130
132
  end
131
133
 
@@ -27,7 +27,7 @@ class TestGemCommandsFetchCommand < RubyGemTestCase
27
27
  end
28
28
 
29
29
  assert File.exist?(File.join(@tempdir, @a2.file_name)),
30
- "#{@a2.full_name} fetched"
30
+ "#{@a2.full_name} not fetched"
31
31
  end
32
32
 
33
33
  def test_execute_prerelease
@@ -52,5 +52,25 @@ class TestGemCommandsFetchCommand < RubyGemTestCase
52
52
  "#{@a2_pre.full_name} not fetched"
53
53
  end
54
54
 
55
+ def test_execute_version
56
+ util_setup_fake_fetcher
57
+ util_setup_spec_fetcher @a1, @a2
58
+
59
+ @fetcher.data["#{@gem_repo}gems/#{@a1.file_name}"] =
60
+ File.read(File.join(@gemhome, 'cache', @a1.file_name))
61
+
62
+ @cmd.options[:args] = [@a2.name]
63
+ @cmd.options[:version] = Gem::Requirement.new '1'
64
+
65
+ use_ui @ui do
66
+ Dir.chdir @tempdir do
67
+ @cmd.execute
68
+ end
69
+ end
70
+
71
+ assert File.exist?(File.join(@tempdir, @a1.file_name)),
72
+ "#{@a1.full_name} not fetched"
73
+ end
74
+
55
75
  end
56
76
 
@@ -145,8 +145,7 @@ class TestGemCommandsInstallCommand < RubyGemTestCase
145
145
  end
146
146
 
147
147
  # HACK no repository was checked
148
- assert_equal "ERROR: could not find gem no_such_gem locally or in a repository\n",
149
- @ui.error
148
+ assert_match(/ould not find a valid gem 'no_such_gem'/, @ui.error)
150
149
  end
151
150
 
152
151
  def test_execute_no_gem
@@ -170,8 +169,7 @@ class TestGemCommandsInstallCommand < RubyGemTestCase
170
169
  assert_equal 2, e.exit_code
171
170
  end
172
171
 
173
- assert_equal "ERROR: could not find gem nonexistent locally or in a repository\n",
174
- @ui.error
172
+ assert_match(/ould not find a valid gem 'nonexistent'/, @ui.error)
175
173
  end
176
174
 
177
175
  def test_execute_prerelease
@@ -29,7 +29,34 @@ class TestGemCommandsQueryCommand < RubyGemTestCase
29
29
  *** REMOTE GEMS ***
30
30
 
31
31
  a (2)
32
- pl (1)
32
+ pl (1 i386-linux)
33
+ EOF
34
+
35
+ assert_equal expected, @ui.output
36
+ assert_equal '', @ui.error
37
+ end
38
+
39
+ def test_execute_platform
40
+ @a1r = @a1.dup
41
+
42
+ @a1.platform = 'x86-linux'
43
+ @a2.platform = 'universal-darwin'
44
+
45
+ @si = util_setup_spec_fetcher @a1, @a1r, @a2, @b2, @pl1
46
+
47
+ @cmd.handle_options %w[-r -a]
48
+
49
+ use_ui @ui do
50
+ @cmd.execute
51
+ end
52
+
53
+ expected = <<-EOF
54
+
55
+ *** REMOTE GEMS ***
56
+
57
+ a (2 universal-darwin, 1 ruby x86-linux)
58
+ b (2)
59
+ pl (1 i386-linux)
33
60
  EOF
34
61
 
35
62
  assert_equal expected, @ui.output
@@ -51,7 +78,7 @@ pl (1)
51
78
  *** REMOTE GEMS ***
52
79
 
53
80
  a (2, 1)
54
- pl (1)
81
+ pl (1 i386-linux)
55
82
  EOF
56
83
 
57
84
  assert_equal expected, @ui.output
@@ -73,7 +100,7 @@ pl (1)
73
100
  *** REMOTE GEMS ***
74
101
 
75
102
  a (3.a, 2, 1)
76
- pl (1)
103
+ pl (1 i386-linux)
77
104
  EOF
78
105
 
79
106
  assert_equal expected, @ui.output
@@ -311,7 +338,7 @@ a (3.a, 2, 1)
311
338
  a_evil (9)
312
339
  b (2)
313
340
  c (1.2)
314
- pl (1)
341
+ pl (1 i386-linux)
315
342
  EOF
316
343
 
317
344
  assert_equal expected, @ui.output
@@ -348,7 +375,7 @@ pl
348
375
 
349
376
  expected = <<-EOF
350
377
  a (2)
351
- pl (1)
378
+ pl (1 i386-linux)
352
379
  EOF
353
380
 
354
381
  assert_equal expected, @ui.output
@@ -388,7 +415,7 @@ a (3.a, 2, 1)
388
415
  a_evil (9)
389
416
  b (2)
390
417
  c (1.2)
391
- pl (1)
418
+ pl (1 i386-linux)
392
419
  EOF
393
420
 
394
421
  assert_equal expected, @ui.output
@@ -13,16 +13,23 @@ class TestGemCommandsServerCommand < RubyGemTestCase
13
13
  @cmd.send :handle_options, %w[-p 8808 --no-daemon]
14
14
 
15
15
  assert_equal false, @cmd.options[:daemon]
16
- assert_equal @gemhome, @cmd.options[:gemdir]
16
+ assert_equal [], @cmd.options[:gemdir]
17
17
  assert_equal 8808, @cmd.options[:port]
18
18
 
19
19
  @cmd.send :handle_options, %w[-p 9999 -d /nonexistent --daemon]
20
20
 
21
21
  assert_equal true, @cmd.options[:daemon]
22
- assert_equal File.expand_path('/nonexistent'), @cmd.options[:gemdir]
22
+ assert_equal [File.expand_path('/nonexistent')], @cmd.options[:gemdir]
23
23
  assert_equal 9999, @cmd.options[:port]
24
24
  end
25
25
 
26
+ def test_handle_options_gemdir
27
+ @cmd.send :handle_options, %w[--dir a --dir b]
28
+
29
+ assert_equal [File.expand_path('a'), File.expand_path('b')],
30
+ @cmd.options[:gemdir]
31
+ end
32
+
26
33
  def test_handle_options_port
27
34
  @cmd.send :handle_options, %w[-p 0]
28
35
  assert_equal 0, @cmd.options[:port]
@@ -64,8 +64,10 @@ class TestGemCommandsUninstallCommand < GemInstallerTestCase
64
64
 
65
65
  util_setup_gem
66
66
 
67
- use_ui @ui do
68
- @installer.install
67
+ build_rake_in do
68
+ use_ui @ui do
69
+ @installer.install
70
+ end
69
71
  end
70
72
 
71
73
  @cmd.options[:args] = ["pre"]
@@ -22,8 +22,8 @@ class TestGemCommandsUnpackCommand < RubyGemTestCase
22
22
  end
23
23
  end
24
24
 
25
- assert File.exist?(File.join(@tempdir, 'a-3.a')), 'a should be installed'
26
- assert File.exist?(File.join(@tempdir, 'b-2')), 'b should be installed'
25
+ assert File.exist?(File.join(@tempdir, 'a-3.a')), 'a should be unpacked'
26
+ assert File.exist?(File.join(@tempdir, 'b-2')), 'b should be unpacked'
27
27
  end
28
28
 
29
29
  def test_execute_gem_path
@@ -49,6 +49,7 @@ class TestGemCommandsUnpackCommand < RubyGemTestCase
49
49
 
50
50
  def test_execute_gem_path_missing
51
51
  util_make_gems
52
+ util_setup_spec_fetcher
52
53
 
53
54
  Gem.clear_paths
54
55
 
@@ -68,6 +69,49 @@ class TestGemCommandsUnpackCommand < RubyGemTestCase
68
69
  assert_equal '', @ui.output
69
70
  end
70
71
 
72
+ def test_execute_remote
73
+ util_setup_fake_fetcher
74
+ util_setup_spec_fetcher @a1, @a2
75
+ util_clear_gems
76
+
77
+ a2_data = nil
78
+ open File.join(@gemhome, 'cache', @a2.file_name), 'rb' do |fp|
79
+ a2_data = fp.read
80
+ end
81
+
82
+ Gem::RemoteFetcher.fetcher.data['http://gems.example.com/gems/a-2.gem'] =
83
+ a2_data
84
+
85
+ Gem.configuration.verbose = :really
86
+ @cmd.options[:args] = %w[a]
87
+
88
+ use_ui @ui do
89
+ Dir.chdir @tempdir do
90
+ @cmd.execute
91
+ end
92
+ end
93
+
94
+ assert File.exist?(File.join(@tempdir, 'a-2')), 'a should be unpacked'
95
+ end
96
+
97
+ def test_execute_sudo
98
+ util_make_gems
99
+
100
+ File.chmod 0555, @gemhome
101
+
102
+ @cmd.options[:args] = %w[b]
103
+
104
+ use_ui @ui do
105
+ Dir.chdir @tempdir do
106
+ @cmd.execute
107
+ end
108
+ end
109
+
110
+ assert File.exist?(File.join(@tempdir, 'b-2')), 'b should be unpacked'
111
+ ensure
112
+ File.chmod 0755, @gemhome
113
+ end
114
+
71
115
  def test_execute_with_target_option
72
116
  util_make_gems
73
117
 
@@ -46,6 +46,7 @@ class TestGemConfigFile < RubyGemTestCase
46
46
  fp.puts ":benchmark: true"
47
47
  fp.puts ":bulk_threshold: 10"
48
48
  fp.puts ":verbose: false"
49
+ fp.puts ":rubygems_api_key: 701229f217cdf23b1344c7b4b54ca97"
49
50
  fp.puts ":sources:"
50
51
  fp.puts " - http://more-gems.example.com"
51
52
  fp.puts "install: --wrappers"
@@ -61,6 +62,7 @@ class TestGemConfigFile < RubyGemTestCase
61
62
  assert_equal 10, @cfg.bulk_threshold
62
63
  assert_equal false, @cfg.verbose
63
64
  assert_equal false, @cfg.update_sources
65
+ assert_equal "701229f217cdf23b1344c7b4b54ca97", @cfg.rubygems_api_key
64
66
  assert_equal %w[http://more-gems.example.com], Gem.sources
65
67
  assert_equal '--wrappers', @cfg[:install]
66
68
  assert_equal(['/usr/ruby/1.8/lib/ruby/gems/1.8', '/var/ruby/1.8/gem_home'],
@@ -134,5 +134,16 @@ class TestGemDependency < RubyGemTestCase
134
134
  assert d.prerelease?
135
135
  end
136
136
 
137
+ def test_version_requirements_equals_deprecated
138
+ d = dep "pkg", "1.0"
139
+
140
+ out, err = capture_io do
141
+ d.version_requirements = '2.0'
142
+ assert_equal Gem::Requirement.new(%w[2.0]), d.requirement
143
+ end
144
+
145
+ assert_match %r%deprecated%, err
146
+ end
147
+
137
148
  end
138
149
 
@@ -12,7 +12,7 @@ class TestGemDocManager < RubyGemTestCase
12
12
 
13
13
  def test_uninstall_doc_unwritable
14
14
  orig_mode = File.stat(@spec.installation_path).mode
15
-
15
+
16
16
  # File.chmod has no effect on MS Windows directories (it needs ACL).
17
17
  if win_platform?
18
18
  skip("test_uninstall_doc_unwritable skipped on MS Windows")