rubygems-update 0.9.4 → 0.9.5
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.
- data/ChangeLog +587 -0
- data/README +0 -1
- data/Rakefile +39 -12
- data/TODO +0 -5
- data/bin/gem +7 -7
- data/bin/update_rubygems +1 -1
- data/examples/application/an-app.gemspec +1 -1
- data/gemspecs/cgikit-1.1.0.gemspec +1 -2
- data/gemspecs/jabber4r.gemspec +1 -1
- data/gemspecs/linguistics.gemspec +1 -1
- data/gemspecs/ook.gemspec +1 -1
- data/gemspecs/progressbar.gemspec +1 -1
- data/gemspecs/redcloth.gemspec +1 -1
- data/gemspecs/rublog.gemspec +1 -1
- data/gemspecs/ruby-doom.gemspec +1 -1
- data/gemspecs/rubyjdwp.gemspec +1 -1
- data/gemspecs/statistics.gemspec +1 -1
- data/lib/rubygems.rb +167 -105
- data/lib/rubygems/builder.rb +12 -10
- data/lib/rubygems/command.rb +177 -60
- data/lib/rubygems/command_manager.rb +30 -38
- data/lib/rubygems/commands/build_command.rb +42 -46
- data/lib/rubygems/commands/cert_command.rb +72 -69
- data/lib/rubygems/commands/check_command.rb +63 -63
- data/lib/rubygems/commands/cleanup_command.rb +25 -7
- data/lib/rubygems/commands/contents_command.rb +70 -62
- data/lib/rubygems/commands/dependency_command.rb +131 -86
- data/lib/rubygems/commands/environment_command.rb +67 -46
- data/lib/rubygems/commands/fetch_command.rb +62 -0
- data/lib/rubygems/commands/generate_index_command.rb +57 -0
- data/lib/rubygems/commands/help_command.rb +163 -73
- data/lib/rubygems/commands/install_command.rb +114 -128
- data/lib/rubygems/commands/list_command.rb +10 -8
- data/lib/rubygems/commands/lock_command.rb +101 -0
- data/lib/rubygems/commands/mirror_command.rb +105 -0
- data/lib/rubygems/commands/outdated_command.rb +24 -15
- data/lib/rubygems/commands/pristine_command.rb +118 -88
- data/lib/rubygems/commands/query_command.rb +109 -77
- data/lib/rubygems/commands/rdoc_command.rb +13 -10
- data/lib/rubygems/commands/search_command.rb +10 -8
- data/lib/rubygems/commands/server_command.rb +48 -0
- data/lib/rubygems/commands/sources_command.rb +104 -83
- data/lib/rubygems/commands/specification_command.rb +65 -51
- data/lib/rubygems/commands/uninstall_command.rb +17 -12
- data/lib/rubygems/commands/unpack_command.rb +68 -68
- data/lib/rubygems/commands/update_command.rb +72 -25
- data/lib/rubygems/commands/which_command.rb +86 -0
- data/lib/rubygems/config_file.rb +202 -78
- data/lib/rubygems/custom_require.rb +7 -88
- data/lib/rubygems/dependency.rb +65 -0
- data/lib/rubygems/dependency_installer.rb +232 -0
- data/lib/rubygems/dependency_list.rb +133 -105
- data/lib/rubygems/digest/md5.rb +4 -1
- data/lib/rubygems/digest/sha2.rb +1 -1
- data/lib/rubygems/doc_manager.rb +41 -19
- data/lib/rubygems/exceptions.rb +63 -0
- data/lib/rubygems/ext.rb +18 -0
- data/lib/rubygems/ext/builder.rb +56 -0
- data/lib/rubygems/ext/configure_builder.rb +24 -0
- data/lib/rubygems/ext/ext_conf_builder.rb +23 -0
- data/lib/rubygems/ext/rake_builder.rb +27 -0
- data/lib/rubygems/format.rb +16 -6
- data/lib/rubygems/gem_openssl.rb +43 -6
- data/lib/rubygems/gem_path_searcher.rb +84 -0
- data/lib/rubygems/gem_runner.rb +20 -5
- data/lib/rubygems/indexer.rb +163 -0
- data/lib/rubygems/indexer/abstract_index_builder.rb +80 -0
- data/lib/rubygems/indexer/marshal_index_builder.rb +17 -0
- data/lib/rubygems/indexer/master_index_builder.rb +53 -0
- data/lib/rubygems/indexer/quick_index_builder.rb +48 -0
- data/lib/rubygems/install_update_options.rb +87 -0
- data/lib/rubygems/installer.rb +316 -562
- data/lib/rubygems/local_remote_options.rb +106 -0
- data/lib/rubygems/old_format.rb +5 -13
- data/lib/rubygems/open-uri.rb +2 -0
- data/lib/rubygems/package.rb +28 -32
- data/lib/rubygems/platform.rb +187 -0
- data/lib/rubygems/remote_fetcher.rb +46 -29
- data/lib/rubygems/remote_installer.rb +11 -18
- data/lib/rubygems/requirement.rb +157 -0
- data/lib/rubygems/rubygems_version.rb +1 -1
- data/lib/rubygems/security.rb +715 -457
- data/lib/rubygems/server.rb +77 -59
- data/lib/rubygems/source_index.rb +154 -83
- data/lib/rubygems/source_info_cache.rb +73 -30
- data/lib/rubygems/source_info_cache_entry.rb +12 -3
- data/lib/rubygems/specification.rb +378 -145
- data/lib/rubygems/uninstaller.rb +183 -0
- data/lib/rubygems/user_interaction.rb +38 -9
- data/lib/rubygems/validator.rb +53 -24
- data/lib/rubygems/version.rb +126 -289
- data/lib/rubygems/version_option.rb +49 -0
- data/pkgs/sources/lib/sources.rb +1 -4
- data/pkgs/sources/sources.gemspec +3 -3
- data/scripts/gemdoc.rb +0 -1
- data/setup.rb +166 -1505
- data/test/bogussources.rb +0 -1
- data/test/data/gem-private_key.pem +27 -0
- data/test/data/gem-public_cert.pem +20 -0
- data/test/functional.rb +3 -105
- data/test/gemutilities.rb +145 -24
- data/test/insure_session.rb +0 -1
- data/test/{test_datadir.rb → test_config.rb} +7 -13
- data/test/test_gem.rb +360 -9
- data/test/test_gem_builder.rb +34 -0
- data/test/{test_command.rb → test_gem_command.rb} +119 -62
- data/test/{test_parse_commands.rb → test_gem_command_manager.rb} +64 -40
- data/test/test_gem_commands_build_command.rb +75 -0
- data/test/test_gem_commands_cert_command.rb +122 -0
- data/test/test_gem_commands_check_command.rb +25 -0
- data/test/test_gem_commands_contents_command.rb +92 -0
- data/test/test_gem_commands_dependency_command.rb +108 -0
- data/test/test_gem_commands_environment_command.rb +117 -0
- data/test/test_gem_commands_fetch_command.rb +34 -0
- data/test/test_gem_commands_generate_index_command.rb +32 -0
- data/test/test_gem_commands_install_command.rb +160 -0
- data/test/test_gem_commands_mirror_command.rb +56 -0
- data/test/test_gem_commands_pristine_command.rb +100 -0
- data/test/test_gem_commands_query_command.rb +82 -0
- data/test/test_gem_commands_sources_command.rb +147 -0
- data/test/test_gem_commands_specification_command.rb +93 -0
- data/test/test_gem_commands_unpack_command.rb +55 -0
- data/test/test_gem_config_file.rb +210 -0
- data/test/test_gem_dependency.rb +89 -0
- data/test/test_gem_dependency_installer.rb +542 -0
- data/test/test_gem_dependency_list.rb +212 -0
- data/test/test_gem_doc_manager.rb +32 -0
- data/test/test_gem_ext_configure_builder.rb +13 -17
- data/test/test_gem_ext_ext_conf_builder.rb +9 -9
- data/test/test_gem_ext_rake_builder.rb +23 -11
- data/test/test_gem_format.rb +69 -0
- data/test/test_gem_gem_path_searcher.rb +57 -0
- data/test/test_gem_gem_runner.rb +35 -0
- data/test/test_gem_indexer.rb +119 -0
- data/test/test_gem_install_update_options.rb +40 -0
- data/test/test_gem_installer.rb +796 -0
- data/test/test_gem_local_remote_options.rb +84 -0
- data/test/test_gem_outdated_command.rb +11 -9
- data/test/test_gem_platform.rb +240 -0
- data/test/{test_remote_fetcher.rb → test_gem_remote_fetcher.rb} +124 -55
- data/test/{test_remote_installer.rb → test_gem_remote_installer.rb} +3 -4
- data/test/test_gem_requirement.rb +223 -0
- data/test/test_gem_server.rb +71 -0
- data/test/test_gem_source_index.rb +429 -0
- data/test/test_gem_source_info_cache.rb +79 -17
- data/test/test_gem_source_info_cache_entry.rb +11 -9
- data/test/test_gem_specification.rb +738 -0
- data/test/test_gem_stream_ui.rb +117 -0
- data/test/test_gem_validator.rb +70 -0
- data/test/test_gem_version.rb +191 -0
- data/test/test_gem_version_option.rb +77 -0
- data/test/{test_require_gem.rb → test_kernel.rb} +19 -12
- data/test/test_open_uri.rb +1 -2
- data/test/test_package.rb +45 -34
- metadata +116 -141
- data/Releases +0 -127
- data/bin/gem_mirror +0 -73
- data/bin/gem_server +0 -6
- data/bin/gemlock +0 -127
- data/bin/gemri +0 -24
- data/bin/gemwhich +0 -89
- data/bin/index_gem_repository.rb +0 -302
- data/lib/gemconfigure.rb +0 -24
- data/lib/rubygems/gem_commands.rb +0 -273
- data/pkgs/sources/sources-0.0.1.gem +0 -0
- data/post-install.rb +0 -121
- data/test/brokenbuildgem.rb +0 -35
- data/test/data/PostMessage-0.0.1.gem +0 -0
- data/test/data/a-0.0.1.gem +0 -0
- data/test/data/a-0.0.2.gem +0 -0
- data/test/data/b-0.0.2.gem +0 -0
- data/test/data/broken-1.0.0.gem +0 -0
- data/test/data/broken_build/broken-build.gemspec +0 -20
- data/test/data/broken_build/ext/extconf.rb +0 -3
- data/test/data/broken_build/ext/foo.c +0 -1
- data/test/data/c-1.2.gem +0 -0
- data/test/data/gemhome/cache/a-0.0.1.gem +0 -0
- data/test/data/gemhome/cache/a-0.0.2.gem +0 -0
- data/test/data/gemhome/cache/b-0.0.2.gem +0 -0
- data/test/data/gemhome/cache/c-1.2.gem +0 -0
- data/test/data/gemhome/gems/a-0.0.1/lib/code.rb +0 -1
- data/test/data/gemhome/gems/a-0.0.2/lib/code.rb +0 -1
- data/test/data/gemhome/gems/b-0.0.2/lib/code.rb +0 -1
- data/test/data/gemhome/gems/c-1.2/lib/code.rb +0 -1
- data/test/data/gemhome/specifications/a-0.0.1.gemspec +0 -8
- data/test/data/gemhome/specifications/a-0.0.2.gemspec +0 -8
- data/test/data/gemhome/specifications/b-0.0.2.gemspec +0 -8
- data/test/data/gemhome/specifications/c-1.2.gemspec +0 -8
- data/test/data/legacy/keyedlist-0.4.0.ruby +0 -11
- data/test/data/legacy/keyedlist-0.4.0.yaml +0 -16
- data/test/data/lib/code.rb +0 -1
- data/test/data/one/README.one +0 -1
- data/test/data/one/lib/one.rb +0 -9
- data/test/data/one/one-0.0.1.gem +0 -0
- data/test/data/one/one.gemspec +0 -17
- data/test/data/one/one.yaml +0 -40
- data/test/data/post_install.gemspec +0 -19
- data/test/functional_extension_gems.rb +0 -48
- data/test/functional_generate_yaml_index.rb +0 -104
- data/test/gemenvironment.rb +0 -59
- data/test/io_capture.rb +0 -33
- data/test/mock/gems/gems/sources-0.0.1/lib/sources.rb +0 -11
- data/test/mock/gems/specifications/sources-0.0.1.gemspec +0 -8
- data/test/onegem.rb +0 -35
- data/test/test_builder.rb +0 -34
- data/test/test_check_command.rb +0 -34
- data/test/test_configfile.rb +0 -42
- data/test/test_dependency_list.rb +0 -169
- data/test/test_file_list.rb +0 -101
- data/test/test_format.rb +0 -49
- data/test/test_gem_sources_command.rb +0 -135
- data/test/test_gemloadpaths.rb +0 -51
- data/test/test_gempaths.rb +0 -170
- data/test/test_installer.rb +0 -369
- data/test/test_loadmanager.rb +0 -48
- data/test/test_process_commands.rb +0 -52
- data/test/test_source_index.rb +0 -231
- data/test/test_specific_extras.rb +0 -46
- data/test/test_specification.rb +0 -565
- data/test/test_user_interaction.rb +0 -48
- data/test/test_validator.rb +0 -59
- data/test/test_version_comparison.rb +0 -321
- data/test/testgem.rc +0 -7
- data/test/user_capture.rb +0 -7
- data/test/yaml_data.rb +0 -63
@@ -0,0 +1,89 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
|
3
|
+
# All rights reserved.
|
4
|
+
# See LICENSE.txt for permissions.
|
5
|
+
#++
|
6
|
+
|
7
|
+
require 'test/unit'
|
8
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
9
|
+
require 'rubygems/version'
|
10
|
+
|
11
|
+
class TestGemDependency < RubyGemTestCase
|
12
|
+
|
13
|
+
def setup
|
14
|
+
super
|
15
|
+
|
16
|
+
@pkg1_0 = Gem::Dependency.new 'pkg', ['> 1.0']
|
17
|
+
@pkg1_1 = Gem::Dependency.new 'pkg', ['> 1.1']
|
18
|
+
|
19
|
+
@oth1_0 = Gem::Dependency.new 'other', ['> 1.0']
|
20
|
+
|
21
|
+
@r1_0 = Gem::Requirement.new ['> 1.0']
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_initialize
|
25
|
+
assert_equal "pkg", @pkg1_0.name
|
26
|
+
assert_equal @r1_0, @pkg1_0.version_requirements
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_initialize_double
|
30
|
+
dep = Gem::Dependency.new("pkg", ["> 1.0", "< 2.0"])
|
31
|
+
|
32
|
+
assert_equal Gem::Requirement.new(["> 1.0", "< 2.0"]),
|
33
|
+
dep.version_requirements
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_initialize_empty
|
37
|
+
dep = Gem::Dependency.new("pkg", [])
|
38
|
+
req = @r1_0
|
39
|
+
|
40
|
+
req.instance_eval do
|
41
|
+
@version = ">= 1.0"
|
42
|
+
@op = ">="
|
43
|
+
@nums = [1,0]
|
44
|
+
@requirements = nil
|
45
|
+
end
|
46
|
+
|
47
|
+
dep.instance_eval do
|
48
|
+
@version_requirement = req
|
49
|
+
@version_requirements = nil
|
50
|
+
end
|
51
|
+
|
52
|
+
assert_equal Gem::Requirement.new([">= 1.0"]), dep.version_requirements
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_initialize_version
|
56
|
+
dep = Gem::Dependency.new 'pkg', Gem::Version.new('2')
|
57
|
+
|
58
|
+
assert_equal 'pkg', dep.name
|
59
|
+
|
60
|
+
assert_equal Gem::Requirement.new('= 2'), dep.version_requirements
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_equals2
|
64
|
+
assert_equal @pkg1_0, @pkg1_0.dup
|
65
|
+
assert_equal @pkg1_0.dup, @pkg1_0
|
66
|
+
|
67
|
+
assert_not_equal @pkg1_0, @pkg1_1, "requirements different"
|
68
|
+
assert_not_equal @pkg1_1, @pkg1_0, "requirements different"
|
69
|
+
|
70
|
+
assert_not_equal @pkg1_0, @oth1_0, "names different"
|
71
|
+
assert_not_equal @oth1_0, @pkg1_0, "names different"
|
72
|
+
|
73
|
+
assert_not_equal @pkg1_0, Object.new
|
74
|
+
assert_not_equal Object.new, @pkg1_0
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_hash
|
78
|
+
assert_equal @pkg1_0.hash, @pkg1_0.dup.hash
|
79
|
+
assert_equal @pkg1_0.dup.hash, @pkg1_0.hash
|
80
|
+
|
81
|
+
assert_not_equal @pkg1_0.hash, @pkg1_1.hash, "requirements different"
|
82
|
+
assert_not_equal @pkg1_1.hash, @pkg1_0.hash, "requirements different"
|
83
|
+
|
84
|
+
assert_not_equal @pkg1_0.hash, @oth1_0.hash, "names different"
|
85
|
+
assert_not_equal @oth1_0.hash, @pkg1_0.hash, "names different"
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
|
@@ -0,0 +1,542 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
3
|
+
require 'rubygems/dependency_installer'
|
4
|
+
|
5
|
+
class TestGemDependencyInstaller < RubyGemTestCase
|
6
|
+
|
7
|
+
def setup
|
8
|
+
super
|
9
|
+
|
10
|
+
@gems_dir = File.join @tempdir, 'gems'
|
11
|
+
@cache_dir = File.join @gemhome, 'cache'
|
12
|
+
FileUtils.mkdir @gems_dir
|
13
|
+
|
14
|
+
write_file File.join('gems', 'a-1', 'bin', 'a_bin') do |fp|
|
15
|
+
fp.puts "#!/usr/bin/ruby"
|
16
|
+
end
|
17
|
+
@a1, @a1_gem = util_gem 'a', '1' do |s| s.executables << 'a_bin' end
|
18
|
+
|
19
|
+
@b1, @b1_gem = util_gem 'b', '1' do |s| s.add_dependency 'a' end
|
20
|
+
|
21
|
+
@d1, @d1_gem = util_gem 'd', '1'
|
22
|
+
@d2, @d2_gem = util_gem 'd', '2'
|
23
|
+
|
24
|
+
@x1_m, @x1_m_gem = util_gem 'x', '1' do |s|
|
25
|
+
s.platform = Gem::Platform.new %w[cpu my_platform 1]
|
26
|
+
end
|
27
|
+
|
28
|
+
@x1_o, @x1_o_gem = util_gem 'x', '1' do |s|
|
29
|
+
s.platform = Gem::Platform.new %w[cpu other_platform 1]
|
30
|
+
end
|
31
|
+
|
32
|
+
@w1, @w1_gem = util_gem 'w', '1' do |s| s.add_dependency 'x' end
|
33
|
+
|
34
|
+
@y1, @y1_gem = util_gem 'y', '1'
|
35
|
+
@y1_1_p, @y1_1_p_gem = util_gem 'y', '1.1' do |s|
|
36
|
+
s.platform = Gem::Platform.new %w[cpu my_platform 1]
|
37
|
+
end
|
38
|
+
|
39
|
+
@z1, @z1_gem = util_gem 'z', '1' do |s| s.add_dependency 'y' end
|
40
|
+
|
41
|
+
si = util_setup_source_info_cache @a1, @b1, @d1, @d2, @x1_m, @x1_o, @w1,
|
42
|
+
@y1, @y1_1_p, @z1
|
43
|
+
|
44
|
+
@fetcher = FakeFetcher.new
|
45
|
+
Gem::RemoteFetcher.instance_variable_set :@fetcher, @fetcher
|
46
|
+
@fetcher.uri = URI.parse 'http://gems.example.com'
|
47
|
+
@fetcher.data['http://gems.example.com/gems/yaml'] = si.to_yaml
|
48
|
+
|
49
|
+
FileUtils.rm_rf File.join(@gemhome, 'gems')
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_install
|
53
|
+
FileUtils.mv @a1_gem, @tempdir
|
54
|
+
inst = nil
|
55
|
+
|
56
|
+
Dir.chdir @tempdir do
|
57
|
+
inst = Gem::DependencyInstaller.new 'a'
|
58
|
+
inst.install
|
59
|
+
end
|
60
|
+
|
61
|
+
assert_equal Gem::SourceIndex.new(@a1.full_name => @a1),
|
62
|
+
Gem::SourceIndex.from_installed_gems
|
63
|
+
|
64
|
+
assert_equal [@a1], inst.installed_gems
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_install_dependency
|
68
|
+
FileUtils.mv @a1_gem, @tempdir
|
69
|
+
FileUtils.mv @b1_gem, @tempdir
|
70
|
+
inst = nil
|
71
|
+
|
72
|
+
Dir.chdir @tempdir do
|
73
|
+
inst = Gem::DependencyInstaller.new 'b'
|
74
|
+
inst.install
|
75
|
+
end
|
76
|
+
|
77
|
+
assert_equal %w[a-1 b-1], inst.installed_gems.map { |s| s.full_name }
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_install_dependency_existing
|
81
|
+
Gem::Installer.new(@a1_gem).install
|
82
|
+
FileUtils.mv @a1_gem, @tempdir
|
83
|
+
FileUtils.mv @b1_gem, @tempdir
|
84
|
+
inst = nil
|
85
|
+
|
86
|
+
Dir.chdir @tempdir do
|
87
|
+
inst = Gem::DependencyInstaller.new 'b'
|
88
|
+
inst.install
|
89
|
+
end
|
90
|
+
|
91
|
+
assert_equal %w[b-1], inst.installed_gems.map { |s| s.full_name }
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_install_dependency_old
|
95
|
+
e1, e1_gem = util_gem 'e', '1'
|
96
|
+
f1, f1_gem = util_gem 'f', '1' do |s| s.add_dependency 'e' end
|
97
|
+
f2, f2_gem = util_gem 'f', '2'
|
98
|
+
|
99
|
+
FileUtils.mv e1_gem, @tempdir
|
100
|
+
FileUtils.mv f1_gem, @tempdir
|
101
|
+
FileUtils.mv f2_gem, @tempdir
|
102
|
+
inst = nil
|
103
|
+
|
104
|
+
Dir.chdir @tempdir do
|
105
|
+
inst = Gem::DependencyInstaller.new 'f'
|
106
|
+
inst.install
|
107
|
+
end
|
108
|
+
|
109
|
+
assert_equal %w[f-2], inst.installed_gems.map { |s| s.full_name }
|
110
|
+
end
|
111
|
+
|
112
|
+
def test_install_local
|
113
|
+
FileUtils.mv @a1_gem, @tempdir
|
114
|
+
inst = nil
|
115
|
+
|
116
|
+
Dir.chdir @tempdir do
|
117
|
+
inst = Gem::DependencyInstaller.new 'a-1.gem'
|
118
|
+
inst.install
|
119
|
+
end
|
120
|
+
|
121
|
+
assert_equal %w[a-1], inst.installed_gems.map { |s| s.full_name }
|
122
|
+
end
|
123
|
+
|
124
|
+
def test_install_local_subdir
|
125
|
+
inst = nil
|
126
|
+
|
127
|
+
Dir.chdir @tempdir do
|
128
|
+
inst = Gem::DependencyInstaller.new 'gems/a-1.gem'
|
129
|
+
inst.install
|
130
|
+
end
|
131
|
+
|
132
|
+
assert_equal %w[a-1], inst.installed_gems.map { |s| s.full_name }
|
133
|
+
end
|
134
|
+
|
135
|
+
def test_install_env_shebang
|
136
|
+
FileUtils.mv @a1_gem, @tempdir
|
137
|
+
inst = nil
|
138
|
+
|
139
|
+
Dir.chdir @tempdir do
|
140
|
+
inst = Gem::DependencyInstaller.new 'a', nil, :env_shebang => true,
|
141
|
+
:wrappers => true
|
142
|
+
inst.install
|
143
|
+
end
|
144
|
+
|
145
|
+
assert_match %r|\A#!/usr/bin/env ruby\n|,
|
146
|
+
File.read(File.join(@gemhome, 'bin', 'a_bin'))
|
147
|
+
end
|
148
|
+
|
149
|
+
def test_install_force
|
150
|
+
FileUtils.mv @b1_gem, @tempdir
|
151
|
+
si = util_setup_source_info_cache @b1
|
152
|
+
@fetcher.data['http://gems.example.com/gems/yaml'] = si.to_yaml
|
153
|
+
inst = nil
|
154
|
+
|
155
|
+
Dir.chdir @tempdir do
|
156
|
+
inst = Gem::DependencyInstaller.new 'b', nil, :force => true
|
157
|
+
inst.install
|
158
|
+
end
|
159
|
+
|
160
|
+
assert_equal %w[b-1], inst.installed_gems.map { |s| s.full_name }
|
161
|
+
end
|
162
|
+
|
163
|
+
def test_install_ignore_dependencies
|
164
|
+
FileUtils.mv @b1_gem, @tempdir
|
165
|
+
inst = nil
|
166
|
+
|
167
|
+
Dir.chdir @tempdir do
|
168
|
+
inst = Gem::DependencyInstaller.new 'b', nil, :ignore_dependencies => true
|
169
|
+
inst.install
|
170
|
+
end
|
171
|
+
|
172
|
+
assert_equal %w[b-1], inst.installed_gems.map { |s| s.full_name }
|
173
|
+
end
|
174
|
+
|
175
|
+
def test_install_install_dir
|
176
|
+
FileUtils.mv @a1_gem, @tempdir
|
177
|
+
gemhome2 = File.join @tempdir, 'gemhome2'
|
178
|
+
Dir.mkdir gemhome2
|
179
|
+
inst = nil
|
180
|
+
|
181
|
+
Dir.chdir @tempdir do
|
182
|
+
inst = Gem::DependencyInstaller.new 'a', nil, :install_dir => gemhome2
|
183
|
+
inst.install
|
184
|
+
end
|
185
|
+
|
186
|
+
assert_equal %w[a-1], inst.installed_gems.map { |s| s.full_name }
|
187
|
+
|
188
|
+
assert File.exist?(File.join(gemhome2, 'specifications',
|
189
|
+
"#{@a1.full_name}.gemspec"))
|
190
|
+
end
|
191
|
+
|
192
|
+
def test_install_domain_both
|
193
|
+
a1_data = nil
|
194
|
+
File.open @a1_gem, 'rb' do |fp|
|
195
|
+
a1_data = fp.read
|
196
|
+
end
|
197
|
+
|
198
|
+
@fetcher.data['http://gems.example.com/gems/a-1.gem'] = a1_data
|
199
|
+
|
200
|
+
FileUtils.mv @b1_gem, @tempdir
|
201
|
+
inst = nil
|
202
|
+
|
203
|
+
Dir.chdir @tempdir do
|
204
|
+
inst = Gem::DependencyInstaller.new 'b', nil, :domain => :both
|
205
|
+
inst.install
|
206
|
+
end
|
207
|
+
|
208
|
+
assert_equal %w[a-1 b-1], inst.installed_gems.map { |s| s.full_name }
|
209
|
+
a1, b1 = inst.installed_gems
|
210
|
+
|
211
|
+
a1_expected = File.join(@gemhome, 'specifications',
|
212
|
+
"#{a1.full_name}.gemspec")
|
213
|
+
b1_expected = File.join(@gemhome, 'specifications',
|
214
|
+
"#{b1.full_name}.gemspec")
|
215
|
+
|
216
|
+
assert_equal a1_expected, a1.loaded_from
|
217
|
+
assert_equal b1_expected, b1.loaded_from
|
218
|
+
end
|
219
|
+
|
220
|
+
def test_install_domain_local
|
221
|
+
FileUtils.mv @b1_gem, @tempdir
|
222
|
+
inst = nil
|
223
|
+
|
224
|
+
Dir.chdir @tempdir do
|
225
|
+
e = assert_raise Gem::InstallError do
|
226
|
+
inst = Gem::DependencyInstaller.new 'b', nil, :domain => :local
|
227
|
+
inst.install
|
228
|
+
end
|
229
|
+
assert_equal 'b requires a (>= 0)', e.message
|
230
|
+
end
|
231
|
+
|
232
|
+
assert_equal [], inst.installed_gems.map { |s| s.full_name }
|
233
|
+
end
|
234
|
+
|
235
|
+
def test_install_domain_remote
|
236
|
+
a1_data = nil
|
237
|
+
File.open @a1_gem, 'rb' do |fp|
|
238
|
+
a1_data = fp.read
|
239
|
+
end
|
240
|
+
|
241
|
+
@fetcher.data['http://gems.example.com/gems/a-1.gem'] = a1_data
|
242
|
+
|
243
|
+
inst = Gem::DependencyInstaller.new 'a', nil, :domain => :remote
|
244
|
+
inst.install
|
245
|
+
|
246
|
+
assert_equal %w[a-1], inst.installed_gems.map { |s| s.full_name }
|
247
|
+
end
|
248
|
+
|
249
|
+
def test_install_domain_remote_platform_newer
|
250
|
+
a2_o, a2_o_gem = util_gem 'a', '2' do |s|
|
251
|
+
s.platform = Gem::Platform.new %w[cpu other_platform 1]
|
252
|
+
end
|
253
|
+
|
254
|
+
si = util_setup_source_info_cache @a1, a2_o
|
255
|
+
|
256
|
+
@fetcher.data['http://gems.example.com/gems/yaml'] = si.to_yaml
|
257
|
+
|
258
|
+
a1_data = nil
|
259
|
+
a2_o_data = nil
|
260
|
+
|
261
|
+
File.open @a1_gem, 'rb' do |fp| a1_data = fp.read end
|
262
|
+
File.open a2_o_gem, 'rb' do |fp| a2_o_data = fp.read end
|
263
|
+
|
264
|
+
@fetcher.data["http://gems.example.com/gems/#{@a1.full_name}.gem"] =
|
265
|
+
a1_data
|
266
|
+
@fetcher.data["http://gems.example.com/gems/#{a2_o.full_name}.gem"] =
|
267
|
+
a2_o_data
|
268
|
+
|
269
|
+
inst = Gem::DependencyInstaller.new 'a', nil, :domain => :remote
|
270
|
+
inst.install
|
271
|
+
|
272
|
+
assert_equal %w[a-1], inst.installed_gems.map { |s| s.full_name }
|
273
|
+
end
|
274
|
+
|
275
|
+
def test_install_reinstall
|
276
|
+
Gem::Installer.new(@a1_gem).install
|
277
|
+
FileUtils.mv @a1_gem, @tempdir
|
278
|
+
inst = nil
|
279
|
+
|
280
|
+
Dir.chdir @tempdir do
|
281
|
+
inst = Gem::DependencyInstaller.new 'a'
|
282
|
+
inst.install
|
283
|
+
end
|
284
|
+
|
285
|
+
assert_equal Gem::SourceIndex.new(@a1.full_name => @a1),
|
286
|
+
Gem::SourceIndex.from_installed_gems
|
287
|
+
|
288
|
+
assert_equal %w[a-1], inst.installed_gems.map { |s| s.full_name }
|
289
|
+
end
|
290
|
+
|
291
|
+
def test_install_security_policy
|
292
|
+
FileUtils.mv @a1_gem, @cache_dir
|
293
|
+
FileUtils.mv @b1_gem, @cache_dir
|
294
|
+
policy = Gem::Security::HighSecurity
|
295
|
+
inst = Gem::DependencyInstaller.new 'b', nil, :security_policy => policy
|
296
|
+
|
297
|
+
e = assert_raise Gem::Exception do
|
298
|
+
inst.install
|
299
|
+
end
|
300
|
+
|
301
|
+
assert_equal 'Unsigned gem', e.message
|
302
|
+
|
303
|
+
assert_equal %w[], inst.installed_gems.map { |s| s.full_name }
|
304
|
+
end
|
305
|
+
|
306
|
+
def test_install_wrappers
|
307
|
+
FileUtils.mv @a1_gem, @cache_dir
|
308
|
+
inst = Gem::DependencyInstaller.new 'a', :wrappers => true
|
309
|
+
|
310
|
+
inst.install
|
311
|
+
|
312
|
+
assert_match %r|This file was generated by RubyGems.|,
|
313
|
+
File.read(File.join(@gemhome, 'bin', 'a_bin'))
|
314
|
+
end
|
315
|
+
|
316
|
+
def test_install_version
|
317
|
+
FileUtils.mv @d1_gem, @cache_dir
|
318
|
+
FileUtils.mv @d2_gem, @cache_dir
|
319
|
+
inst = Gem::DependencyInstaller.new 'd', '= 1'
|
320
|
+
|
321
|
+
inst.install
|
322
|
+
|
323
|
+
assert_equal %w[d-1], inst.installed_gems.map { |s| s.full_name }
|
324
|
+
end
|
325
|
+
|
326
|
+
def test_install_version_default
|
327
|
+
FileUtils.mv @d1_gem, @cache_dir
|
328
|
+
FileUtils.mv @d2_gem, @cache_dir
|
329
|
+
inst = Gem::DependencyInstaller.new 'd'
|
330
|
+
|
331
|
+
inst.install
|
332
|
+
|
333
|
+
assert_equal %w[d-2], inst.installed_gems.map { |s| s.full_name }
|
334
|
+
end
|
335
|
+
|
336
|
+
def test_download
|
337
|
+
a1_data = nil
|
338
|
+
File.open @a1_gem, 'rb' do |fp|
|
339
|
+
a1_data = fp.read
|
340
|
+
end
|
341
|
+
|
342
|
+
@fetcher.data['http://gems.example.com/gems/a-1.gem'] = a1_data
|
343
|
+
|
344
|
+
inst = Gem::DependencyInstaller.new 'a'
|
345
|
+
|
346
|
+
a1_cache_gem = File.join(@gemhome, 'cache', "#{@a1.full_name}.gem")
|
347
|
+
assert_equal a1_cache_gem, inst.download(@a1, 'http://gems.example.com')
|
348
|
+
|
349
|
+
assert File.exist?(a1_cache_gem)
|
350
|
+
end
|
351
|
+
|
352
|
+
def test_download_cached
|
353
|
+
FileUtils.mv @a1_gem, @cache_dir
|
354
|
+
|
355
|
+
inst = Gem::DependencyInstaller.new 'a'
|
356
|
+
|
357
|
+
assert_equal File.join(@gemhome, 'cache', "#{@a1.full_name}.gem"),
|
358
|
+
inst.download(@a1, 'http://gems.example.com')
|
359
|
+
end
|
360
|
+
|
361
|
+
def test_download_local
|
362
|
+
FileUtils.mv @a1_gem, @tempdir
|
363
|
+
local_path = File.join @tempdir, "#{@a1.full_name}.gem"
|
364
|
+
inst = nil
|
365
|
+
|
366
|
+
Dir.chdir @tempdir do
|
367
|
+
inst = Gem::DependencyInstaller.new 'a'
|
368
|
+
end
|
369
|
+
|
370
|
+
assert_equal File.join(@gemhome, 'cache', "#{@a1.full_name}.gem"),
|
371
|
+
inst.download(@a1, local_path)
|
372
|
+
end
|
373
|
+
|
374
|
+
def test_download_install_dir
|
375
|
+
a1_data = nil
|
376
|
+
File.open @a1_gem, 'rb' do |fp|
|
377
|
+
a1_data = fp.read
|
378
|
+
end
|
379
|
+
|
380
|
+
@fetcher.data['http://gems.example.com/gems/a-1.gem'] = a1_data
|
381
|
+
|
382
|
+
install_dir = File.join @tempdir, 'more_gems'
|
383
|
+
|
384
|
+
inst = Gem::DependencyInstaller.new 'a', nil, :install_dir => install_dir
|
385
|
+
|
386
|
+
a1_cache_gem = File.join install_dir, 'cache', "#{@a1.full_name}.gem"
|
387
|
+
assert_equal a1_cache_gem, inst.download(@a1, 'http://gems.example.com')
|
388
|
+
|
389
|
+
assert File.exist?(a1_cache_gem)
|
390
|
+
end
|
391
|
+
|
392
|
+
unless win_platform? then # File.chmod doesn't work
|
393
|
+
def test_download_local_read_only
|
394
|
+
FileUtils.mv @a1_gem, @tempdir
|
395
|
+
local_path = File.join @tempdir, "#{@a1.full_name}.gem"
|
396
|
+
inst = nil
|
397
|
+
File.chmod 0555, File.join(@gemhome, 'cache')
|
398
|
+
|
399
|
+
Dir.chdir @tempdir do
|
400
|
+
inst = Gem::DependencyInstaller.new 'a'
|
401
|
+
end
|
402
|
+
|
403
|
+
assert_equal File.join(@tempdir, "#{@a1.full_name}.gem"),
|
404
|
+
inst.download(@a1, local_path)
|
405
|
+
ensure
|
406
|
+
File.chmod 0755, File.join(@gemhome, 'cache')
|
407
|
+
end
|
408
|
+
end
|
409
|
+
|
410
|
+
def test_download_platform_legacy
|
411
|
+
original_platform = 'old-platform'
|
412
|
+
|
413
|
+
e1, e1_gem = util_gem 'e', '1' do |s|
|
414
|
+
s.platform = Gem::Platform::CURRENT
|
415
|
+
s.instance_variable_set :@original_platform, original_platform
|
416
|
+
end
|
417
|
+
|
418
|
+
e1_data = nil
|
419
|
+
File.open e1_gem, 'rb' do |fp|
|
420
|
+
e1_data = fp.read
|
421
|
+
end
|
422
|
+
|
423
|
+
@fetcher.data["http://gems.example.com/gems/e-1-#{original_platform}.gem"] = e1_data
|
424
|
+
|
425
|
+
inst = Gem::DependencyInstaller.new 'a'
|
426
|
+
|
427
|
+
e1_cache_gem = File.join(@gemhome, 'cache', "#{e1.full_name}.gem")
|
428
|
+
assert_equal e1_cache_gem, inst.download(e1, 'http://gems.example.com')
|
429
|
+
|
430
|
+
assert File.exist?(e1_cache_gem)
|
431
|
+
end
|
432
|
+
|
433
|
+
def test_download_unsupported
|
434
|
+
inst = Gem::DependencyInstaller.new 'a'
|
435
|
+
|
436
|
+
e = assert_raise Gem::InstallError do
|
437
|
+
inst.download @a1, 'ftp://gems.rubyforge.org'
|
438
|
+
end
|
439
|
+
|
440
|
+
assert_equal 'unsupported URI scheme ftp', e.message
|
441
|
+
end
|
442
|
+
|
443
|
+
def test_find_gems_gems_with_sources
|
444
|
+
inst = Gem::DependencyInstaller.new 'a'
|
445
|
+
dep = Gem::Dependency.new 'b', '>= 0'
|
446
|
+
|
447
|
+
assert_equal [[@b1, 'http://gems.example.com']],
|
448
|
+
inst.find_gems_with_sources(dep)
|
449
|
+
end
|
450
|
+
|
451
|
+
def test_find_gems_with_sources_local
|
452
|
+
FileUtils.mv @a1_gem, @tempdir
|
453
|
+
inst = Gem::DependencyInstaller.new 'b'
|
454
|
+
dep = Gem::Dependency.new 'a', '>= 0'
|
455
|
+
gems = nil
|
456
|
+
|
457
|
+
Dir.chdir @tempdir do
|
458
|
+
gems = inst.find_gems_with_sources dep
|
459
|
+
end
|
460
|
+
|
461
|
+
assert_equal 2, gems.length
|
462
|
+
remote = gems.first
|
463
|
+
assert_equal @a1, remote.first, 'remote spec'
|
464
|
+
assert_equal 'http://gems.example.com', remote.last, 'remote path'
|
465
|
+
|
466
|
+
local = gems.last
|
467
|
+
assert_equal 'a-1', local.first.full_name, 'local spec'
|
468
|
+
assert_equal File.join(@tempdir, "#{@a1.full_name}.gem"),
|
469
|
+
local.last, 'local path'
|
470
|
+
end
|
471
|
+
|
472
|
+
def test_gather_dependencies
|
473
|
+
inst = Gem::DependencyInstaller.new 'b'
|
474
|
+
|
475
|
+
assert_equal %w[a-1 b-1], inst.gems_to_install.map { |s| s.full_name }
|
476
|
+
end
|
477
|
+
|
478
|
+
def test_gather_dependencies_dropped
|
479
|
+
b2, = util_gem 'b', '2'
|
480
|
+
c1, = util_gem 'c', '1' do |s| s.add_dependency 'b' end
|
481
|
+
|
482
|
+
si = util_setup_source_info_cache @a1, @b1, b2, c1
|
483
|
+
|
484
|
+
@fetcher = FakeFetcher.new
|
485
|
+
Gem::RemoteFetcher.instance_variable_set :@fetcher, @fetcher
|
486
|
+
@fetcher.uri = URI.parse 'http://gems.example.com'
|
487
|
+
@fetcher.data['http://gems.example.com/gems/yaml'] = si.to_yaml
|
488
|
+
|
489
|
+
inst = Gem::DependencyInstaller.new 'c'
|
490
|
+
|
491
|
+
assert_equal %w[b-2 c-1], inst.gems_to_install.map { |s| s.full_name }
|
492
|
+
end
|
493
|
+
|
494
|
+
def test_gather_dependencies_platform_alternate
|
495
|
+
util_set_arch 'cpu-my_platform1'
|
496
|
+
|
497
|
+
inst = Gem::DependencyInstaller.new 'w'
|
498
|
+
|
499
|
+
assert_equal %w[x-1-cpu-my_platform-1 w-1],
|
500
|
+
inst.gems_to_install.map { |s| s.full_name }
|
501
|
+
end
|
502
|
+
|
503
|
+
def test_gather_dependencies_platform_bump
|
504
|
+
inst = Gem::DependencyInstaller.new 'z'
|
505
|
+
|
506
|
+
assert_equal %w[y-1 z-1], inst.gems_to_install.map { |s| s.full_name }
|
507
|
+
end
|
508
|
+
|
509
|
+
def test_gather_dependencies_old_required
|
510
|
+
e1, = util_gem 'e', '1' do |s| s.add_dependency 'd', '= 1' end
|
511
|
+
|
512
|
+
si = util_setup_source_info_cache @d1, @d2, e1
|
513
|
+
|
514
|
+
@fetcher = FakeFetcher.new
|
515
|
+
Gem::RemoteFetcher.instance_variable_set :@fetcher, @fetcher
|
516
|
+
@fetcher.uri = URI.parse 'http://gems.example.com'
|
517
|
+
@fetcher.data['http://gems.example.com/gems/yaml'] = si.to_yaml
|
518
|
+
|
519
|
+
inst = Gem::DependencyInstaller.new 'e'
|
520
|
+
|
521
|
+
assert_equal %w[d-1 e-1], inst.gems_to_install.map { |s| s.full_name }
|
522
|
+
end
|
523
|
+
|
524
|
+
def util_gem(name, version, &block)
|
525
|
+
spec = quick_gem(name, version, &block)
|
526
|
+
|
527
|
+
util_build_gem spec
|
528
|
+
|
529
|
+
cache_file = File.join @tempdir, 'gems', "#{spec.original_name}.gem"
|
530
|
+
FileUtils.mv File.join(@gemhome, 'cache', "#{spec.original_name}.gem"),
|
531
|
+
cache_file
|
532
|
+
FileUtils.rm File.join(@gemhome, 'specifications',
|
533
|
+
"#{spec.full_name}.gemspec")
|
534
|
+
|
535
|
+
spec.loaded_from = nil
|
536
|
+
spec.loaded = false
|
537
|
+
|
538
|
+
[spec, cache_file]
|
539
|
+
end
|
540
|
+
|
541
|
+
end
|
542
|
+
|