rubygems-update 0.9.0 → 0.9.1

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 (105) hide show
  1. data/.document +4 -0
  2. data/ChangeLog +458 -0
  3. data/GPL.txt +340 -0
  4. data/LICENSE.txt +53 -0
  5. data/Rakefile +26 -10
  6. data/TODO +0 -1
  7. data/bin/gem_server +2 -434
  8. data/bin/gemlock +1 -1
  9. data/bin/index_gem_repository.rb +34 -12
  10. data/examples/application/an-app.gemspec +4 -2
  11. data/examples/application/ext/Makefile +139 -0
  12. data/examples/application/ext/extconf.rb +3 -0
  13. data/examples/application/ext/foo.c +1 -0
  14. data/lib/gemconfigure.rb +2 -2
  15. data/lib/rubygems.rb +85 -46
  16. data/lib/rubygems/cmd_manager.rb +14 -11
  17. data/lib/rubygems/command.rb +18 -9
  18. data/lib/rubygems/config_file.rb +17 -16
  19. data/lib/rubygems/custom_require.rb +7 -12
  20. data/lib/rubygems/dependency_list.rb +38 -38
  21. data/lib/rubygems/gem_commands.rb +471 -242
  22. data/lib/rubygems/gem_openssl.rb +1 -1
  23. data/lib/rubygems/gem_runner.rb +2 -1
  24. data/lib/rubygems/installer.rb +189 -143
  25. data/lib/rubygems/package.rb +625 -621
  26. data/lib/rubygems/remote_fetcher.rb +142 -0
  27. data/lib/rubygems/remote_installer.rb +85 -465
  28. data/lib/rubygems/rubygems_version.rb +1 -1
  29. data/lib/rubygems/security.rb +54 -11
  30. data/lib/rubygems/server.rb +486 -0
  31. data/lib/rubygems/source_index.rb +187 -21
  32. data/lib/rubygems/source_info_cache.rb +153 -0
  33. data/lib/rubygems/source_info_cache_entry.rb +31 -0
  34. data/lib/rubygems/specification.rb +71 -30
  35. data/lib/rubygems/user_interaction.rb +22 -20
  36. data/lib/rubygems/validator.rb +8 -7
  37. data/lib/rubygems/version.rb +32 -17
  38. data/pkgs/sources/sources-0.0.1.gem +0 -0
  39. data/post-install.rb +42 -3
  40. data/scripts/gemdoc.rb +3 -3
  41. data/scripts/runtest.rb +1 -1
  42. data/scripts/upload_gemdoc.rb +11 -11
  43. data/setup.rb +14 -7
  44. data/test/brokenbuildgem.rb +35 -0
  45. data/test/data/a-0.0.1.gem +0 -0
  46. data/test/data/a-0.0.2.gem +0 -0
  47. data/test/data/b-0.0.2.gem +0 -0
  48. data/test/data/broken-1.0.0.gem +0 -0
  49. data/test/data/broken_build/broken-build.gemspec +20 -0
  50. data/test/data/broken_build/ext/extconf.rb +3 -0
  51. data/test/data/broken_build/ext/foo.c +1 -0
  52. data/test/data/c-1.2.gem +0 -0
  53. data/test/data/gemhome/cache/a-0.0.1.gem +0 -0
  54. data/test/data/gemhome/cache/a-0.0.2.gem +0 -0
  55. data/test/data/gemhome/cache/b-0.0.2.gem +0 -0
  56. data/test/data/gemhome/cache/c-1.2.gem +0 -0
  57. data/test/data/gemhome/gems/a-0.0.1/lib/code.rb +0 -6
  58. data/test/data/gemhome/gems/a-0.0.2/lib/code.rb +0 -6
  59. data/test/data/gemhome/gems/b-0.0.2/lib/code.rb +0 -6
  60. data/test/data/gemhome/gems/c-1.2/lib/code.rb +0 -6
  61. data/test/data/gemhome/specifications/a-0.0.1.gemspec +1 -1
  62. data/test/data/gemhome/specifications/a-0.0.2.gemspec +1 -1
  63. data/test/data/gemhome/specifications/b-0.0.2.gemspec +1 -1
  64. data/test/data/gemhome/specifications/c-1.2.gemspec +1 -1
  65. data/test/data/lib/code.rb +0 -6
  66. data/test/data/one/one-0.0.1.gem +0 -0
  67. data/test/functional.rb +24 -21
  68. data/test/functional_extension_gems.rb +48 -0
  69. data/test/functional_generate_yaml_index.rb +6 -3
  70. data/test/gemenvironment.rb +27 -22
  71. data/test/gemutilities.rb +95 -5
  72. data/test/insure_session.rb +2 -2
  73. data/test/io_capture.rb +33 -0
  74. data/test/test_check_command.rb +2 -2
  75. data/test/test_command.rb +16 -13
  76. data/test/test_dependency_list.rb +20 -20
  77. data/test/test_file_list.rb +10 -11
  78. data/test/test_format.rb +19 -46
  79. data/test/test_gem.rb +25 -0
  80. data/test/test_gem_ext_configure_builder.rb +88 -0
  81. data/test/test_gem_ext_ext_conf_builder.rb +122 -0
  82. data/test/test_gem_ext_rake_builder.rb +61 -0
  83. data/test/test_gem_outdated_command.rb +37 -0
  84. data/test/test_gem_source_info_cache.rb +196 -0
  85. data/test/test_gem_source_info_cache_entry.rb +44 -0
  86. data/test/test_gem_sources_command.rb +130 -0
  87. data/test/test_installer.rb +137 -9
  88. data/test/test_package.rb +521 -531
  89. data/test/test_parse_commands.rb +7 -7
  90. data/test/test_process_commands.rb +1 -1
  91. data/test/test_remote_fetcher.rb +187 -45
  92. data/test/test_remote_installer.rb +35 -52
  93. data/test/test_require_gem.rb +12 -12
  94. data/test/test_source_index.rb +194 -48
  95. data/test/test_specification.rb +154 -0
  96. data/test/test_user_interaction.rb +48 -0
  97. data/test/test_validator.rb +1 -1
  98. data/test/test_version_comparison.rb +116 -5
  99. metadata +33 -10
  100. data/lib/rubygems/incremental_fetcher.rb +0 -136
  101. data/lib/rubygems/loadpath_manager.rb +0 -114
  102. data/lib/rubygems/open-uri.rb +0 -756
  103. data/test/test_cached_fetcher.rb +0 -64
  104. data/test/test_incremental_fetcher.rb +0 -175
  105. data/test/test_local_cache.rb +0 -106
@@ -20,12 +20,12 @@ class TestFileList < RubyGemTestCase
20
20
 
21
21
  def setup
22
22
  @spec = Gem::Specification.new do |s|
23
- s.files = ['lib/code.rb','lib/apple.rb','lib/brown.rb']
24
- s.name = "a"
25
- s.version = "0.0.1"
26
- s.summary = "summary"
27
- s.description = "desc"
28
- s.require_path = 'lib'
23
+ s.files = ['lib/code.rb','lib/apple.rb','lib/brown.rb']
24
+ s.name = "a"
25
+ s.version = "0.0.1"
26
+ s.summary = "summary"
27
+ s.description = "desc"
28
+ s.require_path = 'lib'
29
29
  end
30
30
 
31
31
  @cm = Gem::CommandManager.new
@@ -39,11 +39,11 @@ class TestFileList < RubyGemTestCase
39
39
  @spec_destination_path = File.join(@gem_install_path, "specifications", @gemspec_filename)
40
40
 
41
41
  begin
42
- File.open(@spec_destination_path, 'w') do |fp|
43
- fp.write @spec.to_ruby
44
- end
42
+ File.open(@spec_destination_path, 'w') do |fp|
43
+ fp.write @spec.to_ruby
44
+ end
45
45
  rescue Exception => e
46
- # ignore errors in setup
46
+ # ignore errors in setup
47
47
  end
48
48
 
49
49
  end
@@ -99,4 +99,3 @@ class TestFileList < RubyGemTestCase
99
99
  end
100
100
 
101
101
  end
102
-
@@ -4,30 +4,40 @@
4
4
  # See LICENSE.txt for permissions.
5
5
  #++
6
6
 
7
- require 'rubygems'
8
- Gem::manage_gems
9
7
  require 'test/unit'
10
8
  require 'stringio'
11
9
 
10
+ require 'rubygems'
11
+ require 'rubygems/format'
12
+ require "test/simple_gem"
13
+
12
14
  class TestFormat < Test::Unit::TestCase
15
+
13
16
  def setup
14
- require File.dirname(__FILE__) + "/simple_gem.rb"
15
17
  @simple_gem = SIMPLE_GEM
16
18
  end
17
19
 
18
20
  def test_garbled_gem_throws_format_exception
19
- assert_raises(RuntimeError) {
21
+ e = assert_raises Gem::Package::FormatError do
20
22
  # subtly bogus input
21
23
  Gem::Format.from_io(StringIO.new(@simple_gem.upcase))
22
- }
23
- assert_raises(RuntimeError) {
24
+ end
25
+
26
+ assert_equal 'No metadata found!', e.message
27
+
28
+ e = assert_raises Gem::Package::FormatError do
24
29
  # Totally bogus input
25
30
  Gem::Format.from_io(StringIO.new(@simple_gem.reverse))
26
- }
27
- assert_raises(RuntimeError) {
31
+ end
32
+
33
+ assert_equal 'No metadata found!', e.message
34
+
35
+ e = assert_raises Gem::Package::FormatError do
28
36
  # This was intentionally screws up YAML parsing.
29
37
  Gem::Format.from_io(StringIO.new(@simple_gem.gsub(/:/, "boom")))
30
- }
38
+ end
39
+
40
+ assert_equal 'No metadata found!', e.message
31
41
  end
32
42
 
33
43
  def test_passing_nonexistent_files_throws_sensible_exception
@@ -37,40 +47,3 @@ class TestFormat < Test::Unit::TestCase
37
47
  end
38
48
  end
39
49
 
40
-
41
- class TestOldFormat # < Test::Unit::TestCase
42
- def setup
43
- require File.dirname(__FILE__) + "/simple_gem.rb"
44
- @simple_gem = SIMPLE_GEM
45
- end
46
-
47
- def test_from_io_returns_format_object
48
- format = Gem::OldFormat.from_io(StringIO.new(@simple_gem))
49
-
50
- assert_equal(Gem::OldFormat, format.class)
51
- assert_equal(Gem::Specification, format.spec.class)
52
- # simple_gem.rb's gem has 3 files in it
53
- assert_equal(3, format.file_entries.size)
54
- end
55
-
56
- def test_garbled_gem_throws_format_exception
57
- assert_raises(RuntimeError) {
58
- # subtly bogus input
59
- Gem::OldFormat.from_io(StringIO.new(@simple_gem.upcase))
60
- }
61
- assert_raises(RuntimeError) {
62
- # Totally bogus input
63
- Gem::OldFormat.from_io(StringIO.new(@simple_gem.reverse))
64
- }
65
- assert_raises(RuntimeError) {
66
- # This was intentionally screws up YAML parsing.
67
- Gem::OldFormat.from_io(StringIO.new(@simple_gem.gsub(/:/, "boom")))
68
- }
69
- end
70
-
71
- def test_passing_nonexistent_files_throws_sensible_exception
72
- assert_raises(Gem::Exception) {
73
- Gem::OldFormat.from_file_by_path("/this/path/almost/definitely/will/not/exist")
74
- }
75
- end
76
- end
@@ -0,0 +1,25 @@
1
+ require 'test/unit'
2
+ require 'rubygems'
3
+ require 'sources'
4
+
5
+ class TestGem < Test::Unit::TestCase
6
+
7
+ def test_self_configuration
8
+ expected = {}
9
+ Gem.send :instance_variable_set, :@configuration, nil
10
+
11
+ assert_equal expected, Gem.configuration
12
+
13
+ Gem.configuration[:verbose] = true
14
+ expected[:verbose] = true
15
+
16
+ assert_equal expected, Gem.configuration
17
+ assert_equal true, Gem.configuration.verbose, 'method_missing on Hash'
18
+ end
19
+
20
+ def test_self_loaded_specs
21
+ assert_equal true, Gem.loaded_specs.keys.include?('sources')
22
+ end
23
+
24
+ end
25
+
@@ -0,0 +1,88 @@
1
+ require 'test/unit'
2
+ require 'test/gemutilities'
3
+
4
+ require 'rubygems/installer'
5
+
6
+ class TestGemExtConfigureBuilder < RubyGemTestCase
7
+
8
+ def setup
9
+ super
10
+
11
+ @makefile_body = "all:\n\t@echo ok\ninstall:\n\t@echo ok"
12
+
13
+ @ext = File.join @tempdir, 'ext'
14
+ @dest_path = File.join @tempdir, 'prefix'
15
+
16
+ FileUtils.mkdir_p @ext
17
+ FileUtils.mkdir_p @dest_path
18
+ end
19
+
20
+ def test_self_build
21
+ return if RUBY_PLATFORM =~ /mswin/ # HACK
22
+
23
+ File.open File.join(@ext, './configure'), 'w' do |configure|
24
+ configure.puts "#!/bin/sh\necho \"#{@makefile_body}\" > Makefile"
25
+ end
26
+
27
+ output = []
28
+
29
+ Dir.chdir @ext do
30
+ Gem::ExtConfigureBuilder.build nil, nil, @dest_path, output
31
+ end
32
+
33
+ expected = [
34
+ "sh ./configure --prefix=#{@dest_path}",
35
+ "", "make", "ok\n", "make install", "ok\n"
36
+ ]
37
+
38
+ assert_equal expected, output
39
+ end
40
+
41
+ def test_self_build_fail
42
+ return if RUBY_PLATFORM =~ /mswin/ # HACK
43
+ output = []
44
+
45
+ error = assert_raise Gem::InstallError do
46
+ Dir.chdir @ext do
47
+ Gem::ExtConfigureBuilder.build nil, nil, @dest_path, output
48
+ end
49
+ end
50
+
51
+ expected = "configure failed:
52
+
53
+ sh ./configure --prefix=#{@dest_path}
54
+ ./configure: ./configure: No such file or directory
55
+ "
56
+
57
+ assert_equal expected, error.message
58
+
59
+ expected = [
60
+ "sh ./configure --prefix=#{@dest_path}",
61
+ "./configure: ./configure: No such file or directory\n"
62
+ ]
63
+
64
+ assert_equal expected, output
65
+ end
66
+
67
+ def test_self_build_has_makefile
68
+ File.open File.join(@ext, 'Makefile'), 'w' do |makefile|
69
+ makefile.puts @makefile_body
70
+ end
71
+
72
+ output = []
73
+ Dir.chdir @ext do
74
+ Gem::ExtConfigureBuilder.build nil, nil, @dest_path, output
75
+ end
76
+
77
+ case RUBY_PLATFORM
78
+ when /mswin/ then
79
+ assert_equal 'nmake', output[0]
80
+ assert_equal 'nmake install', output[2]
81
+ else
82
+ assert_equal 'make', output[0]
83
+ assert_equal 'make install', output[2]
84
+ end
85
+ end
86
+
87
+ end
88
+
@@ -0,0 +1,122 @@
1
+ require 'test/unit'
2
+ require 'test/gemutilities'
3
+ require 'rubygems/installer'
4
+
5
+ class TestGemExtExtConfBuilder < RubyGemTestCase
6
+
7
+ def setup
8
+ super
9
+
10
+ @ext = File.join @tempdir, 'ext'
11
+ @dest_path = File.join @tempdir, 'prefix'
12
+
13
+ FileUtils.mkdir_p @ext
14
+ FileUtils.mkdir_p @dest_path
15
+ end
16
+
17
+ def test_class_build
18
+ File.open File.join(@ext, 'extconf.rb'), 'w' do |extconf|
19
+ extconf.puts "require 'mkmf'\ncreate_makefile 'foo'"
20
+ end
21
+
22
+ output = []
23
+
24
+ Dir.chdir @ext do
25
+ Gem::ExtExtConfBuilder.build 'extconf.rb', nil, @dest_path, output
26
+ end
27
+
28
+ expected = [
29
+ "ruby extconf.rb",
30
+ "creating Makefile\n",
31
+ "make",
32
+ "make: Nothing to be done for `all'.\n",
33
+ "make install",
34
+ "make: Nothing to be done for `install'.\n"
35
+ ]
36
+
37
+ assert_equal "ruby extconf.rb", output[0]
38
+ assert_equal "creating Makefile\n", output[1]
39
+ case RUBY_PLATFORM
40
+ when /mswin/ then
41
+ assert_equal "nmake", output[2]
42
+ assert_equal "nmake install", output[4]
43
+ else
44
+ assert_equal "make", output[2]
45
+ assert_equal "make install", output[4]
46
+ end
47
+ end
48
+
49
+ def test_class_build_extconf_fail
50
+ File.open File.join(@ext, 'extconf.rb'), 'w' do |extconf|
51
+ extconf.puts "require 'mkmf'"
52
+ extconf.puts "have_library 'nonexistent' or abort 'need libnonexistent'"
53
+ extconf.puts "create_makefile 'foo'"
54
+ end
55
+
56
+ output = []
57
+
58
+ error = assert_raise Gem::InstallError do
59
+ Dir.chdir @ext do
60
+ Gem::ExtExtConfBuilder.build 'extconf.rb', nil, @dest_path, output
61
+ end
62
+ end
63
+
64
+ assert_match(/\Aextconf failed:
65
+
66
+ ruby extconf.rb
67
+ checking for main\(\) in .*?nonexistent/, error.message)
68
+
69
+ assert_equal 'ruby extconf.rb', output[0]
70
+ end
71
+
72
+ def test_class_make
73
+ output = []
74
+ makefile_path = File.join(@ext, 'Makefile')
75
+ File.open makefile_path, 'w' do |makefile|
76
+ makefile.puts "RUBYARCHDIR = $(foo)$(target_prefix)"
77
+ makefile.puts "RUBYLIBDIR = $(bar)$(target_prefix)"
78
+ makefile.puts "all:"
79
+ makefile.puts "install:"
80
+ end
81
+
82
+ Dir.chdir @ext do
83
+ Gem::ExtExtConfBuilder.make @ext, output
84
+ end
85
+
86
+ case RUBY_PLATFORM
87
+ when /mswin/ then
88
+ assert_equal 'nmake', output[0]
89
+ assert_equal 'nmake install', output[2]
90
+ else
91
+ assert_equal 'make', output[0]
92
+ assert_equal 'make install', output[2]
93
+ end
94
+
95
+ edited_makefile = <<-EOF
96
+ RUBYARCHDIR = #{@ext}$(target_prefix)
97
+ RUBYLIBDIR = #{@ext}$(target_prefix)
98
+ all:
99
+ install:
100
+ EOF
101
+
102
+ assert_equal edited_makefile, File.read(makefile_path)
103
+ end
104
+
105
+ def test_class_make_no_Makefile
106
+ error = assert_raise Gem::InstallError do
107
+ Dir.chdir @ext do
108
+ Gem::ExtExtConfBuilder.make @ext, ['output']
109
+ end
110
+ end
111
+
112
+ expected = <<-EOF.strip
113
+ Makefile not found:
114
+
115
+ output
116
+ EOF
117
+
118
+ assert_equal expected, error.message
119
+ end
120
+
121
+ end
122
+
@@ -0,0 +1,61 @@
1
+ require 'test/unit'
2
+ require 'test/gemutilities'
3
+ require 'rubygems/installer'
4
+
5
+ class TestGemExtRakeBuilder < RubyGemTestCase
6
+
7
+ def setup
8
+ super
9
+
10
+ @ext = File.join @tempdir, 'ext'
11
+ @dest_path = File.join @tempdir, 'prefix'
12
+
13
+ FileUtils.mkdir_p @ext
14
+ FileUtils.mkdir_p @dest_path
15
+ end
16
+
17
+ def test_class_build
18
+ File.open File.join(@ext, 'Rakefile'), 'w' do |configure|
19
+ configure.puts "task :extension"
20
+ end
21
+
22
+ output = []
23
+ realdir = nil # HACK /tmp vs. /private/tmp
24
+
25
+ Dir.chdir @ext do
26
+ realdir = Dir.pwd
27
+ Gem::ExtRakeBuilder.build nil, nil, @dest_path, output
28
+ end
29
+
30
+ expected = [
31
+ "rake RUBYARCHDIR=#{@dest_path} RUBYLIBDIR=#{@dest_path} extension",
32
+ "(in #{realdir})\n"
33
+ ]
34
+
35
+ assert_equal expected, output
36
+ end
37
+
38
+ def test_class_build_fail
39
+ File.open File.join(@ext, 'rakefile'), 'w' do |rakefile|
40
+ rakefile.puts "task :extension do abort 'fail' end"
41
+ end
42
+
43
+ output = []
44
+
45
+ error = assert_raise Gem::InstallError do
46
+ Dir.chdir @ext do
47
+ Gem::ExtRakeBuilder.build nil, nil, @dest_path, output
48
+ end
49
+ end
50
+
51
+ expected = <<-EOF.strip
52
+ rake failed:
53
+
54
+ rake RUBYARCHDIR=#{@dest_path} RUBYLIBDIR=#{@dest_path} extension
55
+ EOF
56
+
57
+ assert_equal expected, error.message.split("\n")[0..2].join("\n")
58
+ end
59
+
60
+ end
61
+
@@ -0,0 +1,37 @@
1
+ require 'test/unit'
2
+ require 'test/gemutilities'
3
+ require 'rubygems/gem_commands'
4
+
5
+ class TestGemOutdatedCommand < RubyGemTestCase
6
+
7
+ def setup
8
+ super
9
+ end
10
+
11
+ def test_execute
12
+ local_01 = quick_gem 'foo', '0.1'
13
+ local_02 = quick_gem 'foo', '0.2'
14
+ remote_10 = quick_gem 'foo', '1.0'
15
+ remote_20 = quick_gem 'foo', '2.0'
16
+
17
+ remote_spec_file = File.join @gemhome, 'specifications',
18
+ remote_10.full_name + ".gemspec"
19
+ FileUtils.rm remote_spec_file
20
+
21
+ remote_spec_file = File.join @gemhome, 'specifications',
22
+ remote_20.full_name + ".gemspec"
23
+ FileUtils.rm remote_spec_file
24
+
25
+ oc = Gem::OutdatedCommand.new
26
+
27
+ util_setup_source_info_cache remote_10, remote_20
28
+
29
+ ui = MockGemUi.new
30
+ use_ui ui do oc.execute end
31
+
32
+ assert_equal "foo (0.2 < 2.0)\n", ui.output
33
+ assert_equal "", ui.error
34
+ end
35
+
36
+ end
37
+