rubygems-update 1.0.1 → 1.1.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.
- data.tar.gz.sig +0 -0
- data/ChangeLog +248 -0
- data/README +2 -0
- data/Rakefile +47 -23
- data/bin/gem +9 -4
- data/bin/update_rubygems +15 -1
- data/examples/application/bin/myapp +0 -0
- data/lib/rubygems.rb +506 -373
- data/lib/rubygems/builder.rb +14 -7
- data/lib/rubygems/command.rb +9 -9
- data/lib/rubygems/command_manager.rb +1 -0
- data/lib/rubygems/commands/cleanup_command.rb +67 -69
- data/lib/rubygems/commands/environment_command.rb +16 -10
- data/lib/rubygems/commands/fetch_command.rb +7 -9
- data/lib/rubygems/commands/install_command.rb +9 -3
- data/lib/rubygems/commands/list_command.rb +2 -4
- data/lib/rubygems/commands/mirror_command.rb +1 -1
- data/lib/rubygems/commands/query_command.rb +52 -5
- data/lib/rubygems/commands/sources_command.rb +19 -10
- data/lib/rubygems/commands/specification_command.rb +10 -6
- data/lib/rubygems/commands/uninstall_command.rb +23 -6
- data/lib/rubygems/commands/unpack_command.rb +15 -3
- data/lib/rubygems/commands/update_command.rb +27 -25
- data/lib/rubygems/custom_require.rb +1 -1
- data/lib/rubygems/defaults.rb +8 -1
- data/lib/rubygems/dependency_installer.rb +72 -104
- data/lib/rubygems/digest/digest_adapter.rb +0 -0
- data/lib/rubygems/digest/md5.rb +0 -0
- data/lib/rubygems/digest/sha1.rb +0 -0
- data/lib/rubygems/digest/sha2.rb +0 -0
- data/lib/rubygems/exceptions.rb +22 -1
- data/lib/rubygems/format.rb +16 -10
- data/lib/rubygems/indexer.rb +46 -33
- data/lib/rubygems/indexer/abstract_index_builder.rb +10 -2
- data/lib/rubygems/indexer/latest_index_builder.rb +35 -0
- data/lib/rubygems/indexer/master_index_builder.rb +9 -8
- data/lib/rubygems/indexer/quick_index_builder.rb +5 -3
- data/lib/rubygems/install_update_options.rb +7 -1
- data/lib/rubygems/installer.rb +8 -5
- data/lib/rubygems/package.rb +17 -774
- data/lib/rubygems/package/f_sync_dir.rb +24 -0
- data/lib/rubygems/package/tar_header.rb +245 -0
- data/lib/rubygems/package/tar_input.rb +219 -0
- data/lib/rubygems/package/tar_output.rb +143 -0
- data/lib/rubygems/package/tar_reader.rb +86 -0
- data/lib/rubygems/package/tar_reader/entry.rb +99 -0
- data/lib/rubygems/package/tar_writer.rb +180 -0
- data/lib/rubygems/remote_fetcher.rb +131 -16
- data/lib/rubygems/requirement.rb +2 -0
- data/lib/rubygems/rubygems_version.rb +1 -1
- data/lib/rubygems/security.rb +1 -0
- data/lib/rubygems/server.rb +85 -104
- data/lib/rubygems/source_index.rb +412 -329
- data/lib/rubygems/source_info_cache.rb +232 -99
- data/lib/rubygems/source_info_cache_entry.rb +14 -4
- data/lib/rubygems/specification.rb +9 -10
- data/lib/rubygems/timer.rb +0 -0
- data/lib/rubygems/uninstaller.rb +56 -32
- data/lib/rubygems/user_interaction.rb +4 -10
- data/lib/rubygems/validator.rb +0 -0
- data/scripts/gemdoc.rb +0 -0
- data/scripts/specdoc.rb +0 -0
- data/setup.rb +56 -19
- data/test/gem_installer_test_case.rb +86 -0
- data/test/gem_installer_test_case.rbc +0 -0
- data/test/gem_package_tar_test_case.rb +146 -0
- data/test/gem_package_tar_test_case.rbc +0 -0
- data/test/gemutilities.rb +123 -38
- data/test/gemutilities.rbc +0 -0
- data/test/mockgemui.rb +5 -13
- data/test/mockgemui.rbc +0 -0
- data/test/private_key.pem +27 -0
- data/test/public_cert.pem +20 -0
- data/test/simple_gem.rbc +0 -0
- data/test/test_config.rbc +0 -0
- data/test/test_gem.rb +46 -4
- data/test/test_gem.rbc +0 -0
- data/test/test_gem_builder.rbc +0 -0
- data/test/test_gem_command.rbc +0 -0
- data/test/test_gem_command_manager.rb +4 -2
- data/test/test_gem_command_manager.rbc +0 -0
- data/test/test_gem_commands_build_command.rbc +0 -0
- data/test/test_gem_commands_cert_command.rb +5 -1
- data/test/test_gem_commands_cert_command.rbc +0 -0
- data/test/test_gem_commands_check_command.rbc +0 -0
- data/test/test_gem_commands_contents_command.rbc +0 -0
- data/test/test_gem_commands_dependency_command.rbc +0 -0
- data/test/test_gem_commands_environment_command.rb +17 -1
- data/test/test_gem_commands_environment_command.rbc +0 -0
- data/test/test_gem_commands_fetch_command.rb +6 -5
- data/test/test_gem_commands_fetch_command.rbc +0 -0
- data/test/test_gem_commands_generate_index_command.rbc +0 -0
- data/test/test_gem_commands_install_command.rb +36 -28
- data/test/test_gem_commands_install_command.rbc +0 -0
- data/test/test_gem_commands_mirror_command.rbc +0 -0
- data/test/test_gem_commands_pristine_command.rbc +0 -0
- data/test/test_gem_commands_query_command.rb +143 -19
- data/test/test_gem_commands_query_command.rbc +0 -0
- data/test/test_gem_commands_server_command.rb +1 -1
- data/test/test_gem_commands_server_command.rbc +0 -0
- data/test/test_gem_commands_sources_command.rb +67 -9
- data/test/test_gem_commands_sources_command.rbc +0 -0
- data/test/test_gem_commands_specification_command.rb +3 -2
- data/test/test_gem_commands_specification_command.rbc +0 -0
- data/test/test_gem_commands_unpack_command.rb +46 -4
- data/test/test_gem_commands_unpack_command.rbc +0 -0
- data/test/test_gem_commands_update_command.rb +174 -0
- data/test/test_gem_commands_update_command.rbc +0 -0
- data/test/test_gem_config_file.rbc +0 -0
- data/test/test_gem_dependency.rbc +0 -0
- data/test/test_gem_dependency_installer.rb +172 -187
- data/test/test_gem_dependency_installer.rbc +0 -0
- data/test/test_gem_dependency_list.rbc +0 -0
- data/test/test_gem_digest.rb +0 -0
- data/test/test_gem_digest.rbc +0 -0
- data/test/test_gem_doc_manager.rbc +0 -0
- data/test/test_gem_ext_configure_builder.rb +9 -6
- data/test/test_gem_ext_configure_builder.rbc +0 -0
- data/test/test_gem_ext_ext_conf_builder.rbc +0 -0
- data/test/test_gem_ext_rake_builder.rbc +0 -0
- data/test/test_gem_format.rb +1 -1
- data/test/test_gem_format.rbc +0 -0
- data/test/test_gem_gem_path_searcher.rbc +0 -0
- data/test/test_gem_gem_runner.rbc +0 -0
- data/test/test_gem_indexer.rb +7 -2
- data/test/test_gem_indexer.rbc +0 -0
- data/test/test_gem_install_update_options.rbc +0 -0
- data/test/test_gem_installer.rb +5 -84
- data/test/test_gem_installer.rbc +0 -0
- data/test/test_gem_local_remote_options.rbc +0 -0
- data/test/test_gem_outdated_command.rbc +0 -0
- data/test/test_gem_package_tar_header.rb +137 -0
- data/test/test_gem_package_tar_header.rbc +0 -0
- data/test/test_gem_package_tar_input.rb +119 -0
- data/test/test_gem_package_tar_input.rbc +0 -0
- data/test/test_gem_package_tar_output.rb +104 -0
- data/test/test_gem_package_tar_output.rbc +0 -0
- data/test/test_gem_package_tar_reader.rb +53 -0
- data/test/test_gem_package_tar_reader.rbc +0 -0
- data/test/test_gem_package_tar_reader_entry.rb +116 -0
- data/test/test_gem_package_tar_reader_entry.rbc +0 -0
- data/test/test_gem_package_tar_writer.rb +151 -0
- data/test/test_gem_package_tar_writer.rbc +0 -0
- data/test/test_gem_platform.rbc +0 -0
- data/test/test_gem_remote_fetcher.rb +189 -17
- data/test/test_gem_remote_fetcher.rbc +0 -0
- data/test/test_gem_requirement.rbc +0 -0
- data/test/test_gem_server.rb +13 -12
- data/test/test_gem_server.rbc +0 -0
- data/test/test_gem_source_index.rb +305 -56
- data/test/test_gem_source_index.rbc +0 -0
- data/test/test_gem_source_info_cache.rb +179 -53
- data/test/test_gem_source_info_cache.rbc +0 -0
- data/test/test_gem_source_info_cache_entry.rb +41 -10
- data/test/test_gem_source_info_cache_entry.rbc +0 -0
- data/test/test_gem_specification.rb +7 -7
- data/test/test_gem_specification.rbc +0 -0
- data/test/test_gem_stream_ui.rbc +0 -0
- data/test/test_gem_uninstaller.rb +43 -0
- data/test/test_gem_uninstaller.rbc +0 -0
- data/test/test_gem_validator.rbc +0 -0
- data/test/test_gem_version.rb +1 -1
- data/test/test_gem_version.rbc +0 -0
- data/test/test_gem_version_option.rbc +0 -0
- data/test/test_kernel.rb +1 -0
- data/test/test_kernel.rbc +0 -0
- metadata +85 -8
- metadata.gz.sig +0 -0
- data/lib/rubygems/gem_open_uri.rb +0 -7
- data/lib/rubygems/open-uri.rb +0 -773
- data/test/test_open_uri.rb +0 -13
- data/test/test_package.rb +0 -608
Binary file
|
@@ -20,7 +20,7 @@ class TestGemCommandsServerCommand < RubyGemTestCase
|
|
20
20
|
@cmd.send :handle_options, %w[-p 9999 -d /nonexistent --daemon]
|
21
21
|
|
22
22
|
assert_equal true, @cmd.options[:daemon]
|
23
|
-
assert_equal '/nonexistent', @cmd.options[:gemdir]
|
23
|
+
assert_equal File.expand_path('/nonexistent'), @cmd.options[:gemdir]
|
24
24
|
assert_equal 9999, @cmd.options[:port]
|
25
25
|
end
|
26
26
|
end
|
Binary file
|
@@ -31,10 +31,11 @@ class TestGemCommandsSourcesCommand < RubyGemTestCase
|
|
31
31
|
def test_execute_add
|
32
32
|
util_setup_fake_fetcher
|
33
33
|
|
34
|
-
|
34
|
+
si = Gem::SourceIndex.new
|
35
|
+
si.add_spec @a1
|
35
36
|
|
36
37
|
@fetcher.data["http://beta-gems.example.com/Marshal.#{@marshal_version}"] =
|
37
|
-
|
38
|
+
si.dump
|
38
39
|
|
39
40
|
@cmd.handle_options %w[--add http://beta-gems.example.com]
|
40
41
|
|
@@ -45,7 +46,7 @@ class TestGemCommandsSourcesCommand < RubyGemTestCase
|
|
45
46
|
end
|
46
47
|
|
47
48
|
expected = <<-EOF
|
48
|
-
Bulk updating Gem source index for: http://beta-gems.example.com
|
49
|
+
Bulk updating Gem source index for: http://beta-gems.example.com/
|
49
50
|
http://beta-gems.example.com added to sources
|
50
51
|
EOF
|
51
52
|
|
@@ -60,14 +61,11 @@ http://beta-gems.example.com added to sources
|
|
60
61
|
def test_execute_add_nonexistent_source
|
61
62
|
util_setup_fake_fetcher
|
62
63
|
|
63
|
-
@si = Gem::SourceIndex.new @gem1.full_name => @gem1.name
|
64
|
-
|
65
64
|
@fetcher.data["http://beta-gems.example.com/Marshal.#{@marshal_version}"] =
|
66
65
|
proc do
|
67
66
|
raise Gem::RemoteFetcher::FetchError, 'it died'
|
68
67
|
end
|
69
68
|
|
70
|
-
|
71
69
|
Gem::RemoteFetcher.instance_variable_set :@fetcher, @fetcher
|
72
70
|
|
73
71
|
@cmd.handle_options %w[--add http://beta-gems.example.com]
|
@@ -104,6 +102,41 @@ beta-gems.example.com is not a URI
|
|
104
102
|
assert_equal '', @ui.error
|
105
103
|
end
|
106
104
|
|
105
|
+
def test_execute_clear_all
|
106
|
+
@cmd.handle_options %w[--clear-all]
|
107
|
+
|
108
|
+
util_setup_source_info_cache
|
109
|
+
|
110
|
+
cache = Gem::SourceInfoCache.cache
|
111
|
+
cache.update
|
112
|
+
cache.write_cache
|
113
|
+
|
114
|
+
assert File.exist?(cache.system_cache_file),
|
115
|
+
'system cache file'
|
116
|
+
assert File.exist?(cache.latest_system_cache_file),
|
117
|
+
'latest system cache file'
|
118
|
+
|
119
|
+
use_ui @ui do
|
120
|
+
@cmd.execute
|
121
|
+
end
|
122
|
+
|
123
|
+
expected = <<-EOF
|
124
|
+
*** Removed user source cache ***
|
125
|
+
*** Removed latest user source cache ***
|
126
|
+
*** Removed system source cache ***
|
127
|
+
*** Removed latest system source cache ***
|
128
|
+
EOF
|
129
|
+
|
130
|
+
assert_equal expected, @ui.output
|
131
|
+
assert_equal '', @ui.error
|
132
|
+
|
133
|
+
assert !File.exist?(cache.system_cache_file),
|
134
|
+
'system cache file'
|
135
|
+
assert !File.exist?(cache.latest_system_cache_file),
|
136
|
+
'latest system cache file'
|
137
|
+
|
138
|
+
end
|
139
|
+
|
107
140
|
def test_execute_remove
|
108
141
|
@cmd.handle_options %W[--remove #{@gem_repo}]
|
109
142
|
|
@@ -122,20 +155,45 @@ beta-gems.example.com is not a URI
|
|
122
155
|
assert_equal [], Gem::SourceInfoCache.cache_data.keys
|
123
156
|
end
|
124
157
|
|
158
|
+
def test_execute_remove_no_network
|
159
|
+
@cmd.handle_options %W[--remove #{@gem_repo}]
|
160
|
+
|
161
|
+
util_setup_fake_fetcher
|
162
|
+
|
163
|
+
@fetcher.data["#{@gem_repo}/Marshal.#{Gem.marshal_version}"] = proc do
|
164
|
+
raise Gem::RemoteFetcher::FetchError
|
165
|
+
end
|
166
|
+
|
167
|
+
use_ui @ui do
|
168
|
+
@cmd.execute
|
169
|
+
end
|
170
|
+
|
171
|
+
expected = "#{@gem_repo} removed from sources\n"
|
172
|
+
|
173
|
+
assert_equal expected, @ui.output
|
174
|
+
assert_equal '', @ui.error
|
175
|
+
|
176
|
+
Gem::SourceInfoCache.cache.flush
|
177
|
+
assert_equal [], Gem::SourceInfoCache.cache_data.keys
|
178
|
+
end
|
179
|
+
|
125
180
|
def test_execute_update
|
126
181
|
@cmd.handle_options %w[--update]
|
127
182
|
|
128
183
|
util_setup_source_info_cache
|
184
|
+
Gem::SourceInfoCache.reset
|
185
|
+
|
129
186
|
util_setup_fake_fetcher
|
130
|
-
|
131
|
-
|
187
|
+
si = Gem::SourceIndex.new
|
188
|
+
si.add_spec @a1
|
189
|
+
@fetcher.data["#{@gem_repo}/Marshal.#{@marshal_version}"] = si.dump
|
132
190
|
|
133
191
|
use_ui @ui do
|
134
192
|
@cmd.execute
|
135
193
|
end
|
136
194
|
|
137
195
|
expected = <<-EOF
|
138
|
-
Bulk updating Gem source index for: #{@gem_repo}
|
196
|
+
Bulk updating Gem source index for: #{@gem_repo}/
|
139
197
|
source cache successfully updated
|
140
198
|
EOF
|
141
199
|
|
Binary file
|
@@ -12,6 +12,7 @@ class TestGemCommandsSpecificationCommand < RubyGemTestCase
|
|
12
12
|
|
13
13
|
def test_execute
|
14
14
|
foo = quick_gem 'foo'
|
15
|
+
Gem.source_index.add_spec foo
|
15
16
|
|
16
17
|
@cmd.options[:args] = %w[foo]
|
17
18
|
|
@@ -85,8 +86,8 @@ class TestGemCommandsSpecificationCommand < RubyGemTestCase
|
|
85
86
|
@cmd.execute
|
86
87
|
end
|
87
88
|
|
88
|
-
|
89
|
-
|
89
|
+
assert_match %r|\A--- !ruby/object:Gem::Specification|, @ui.output
|
90
|
+
assert_match %r|name: foo|, @ui.output
|
90
91
|
end
|
91
92
|
|
92
93
|
end
|
Binary file
|
@@ -17,15 +17,57 @@ class TestGemCommandsUnpackCommand < RubyGemTestCase
|
|
17
17
|
|
18
18
|
@cmd.options[:args] = %w[a]
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
use_ui @ui do
|
21
|
+
Dir.chdir @tempdir do
|
22
|
+
@cmd.execute
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
assert File.exist?(File.join(@tempdir, 'a-2'))
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_execute_gem_path
|
30
|
+
util_make_gems
|
31
|
+
|
32
|
+
Gem.clear_paths
|
33
|
+
|
34
|
+
gemhome2 = File.join @tempdir, 'gemhome2'
|
35
|
+
|
36
|
+
Gem.send :set_paths, [gemhome2, @gemhome].join(File::PATH_SEPARATOR)
|
37
|
+
Gem.send :set_home, gemhome2
|
38
|
+
|
39
|
+
@cmd.options[:args] = %w[a]
|
40
|
+
|
41
|
+
use_ui @ui do
|
42
|
+
Dir.chdir @tempdir do
|
43
|
+
@cmd.execute
|
24
44
|
end
|
45
|
+
end
|
25
46
|
|
26
47
|
assert File.exist?(File.join(@tempdir, 'a-2'))
|
27
48
|
end
|
28
49
|
|
50
|
+
def test_execute_gem_path_missing
|
51
|
+
util_make_gems
|
52
|
+
|
53
|
+
Gem.clear_paths
|
54
|
+
|
55
|
+
gemhome2 = File.join @tempdir, 'gemhome2'
|
56
|
+
|
57
|
+
Gem.send :set_paths, [gemhome2, @gemhome].join(File::PATH_SEPARATOR)
|
58
|
+
Gem.send :set_home, gemhome2
|
59
|
+
|
60
|
+
@cmd.options[:args] = %w[z]
|
61
|
+
|
62
|
+
use_ui @ui do
|
63
|
+
Dir.chdir @tempdir do
|
64
|
+
@cmd.execute
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
assert_equal '', @ui.output
|
69
|
+
end
|
70
|
+
|
29
71
|
def test_execute_with_target_option
|
30
72
|
util_make_gems
|
31
73
|
|
Binary file
|
@@ -0,0 +1,174 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
3
|
+
require 'rubygems/commands/update_command'
|
4
|
+
|
5
|
+
class TestGemCommandsUpdateCommand < RubyGemTestCase
|
6
|
+
|
7
|
+
def setup
|
8
|
+
super
|
9
|
+
|
10
|
+
@cmd = Gem::Commands::UpdateCommand.new
|
11
|
+
|
12
|
+
util_setup_fake_fetcher
|
13
|
+
|
14
|
+
@a1_path = File.join @gemhome, 'cache', "#{@a1.full_name}.gem"
|
15
|
+
@a2_path = File.join @gemhome, 'cache', "#{@a2.full_name}.gem"
|
16
|
+
|
17
|
+
@fetcher.data["#{@gem_repo}/Marshal.#{@marshal_version}"] =
|
18
|
+
@source_index.dump
|
19
|
+
@fetcher.data["#{@gem_repo}/gems/#{@a1.full_name}.gem"] = read_binary @a1_path
|
20
|
+
@fetcher.data["#{@gem_repo}/gems/#{@a2.full_name}.gem"] = read_binary @a2_path
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_execute
|
24
|
+
util_remove_gems
|
25
|
+
|
26
|
+
Gem::Installer.new(@a1_path).install
|
27
|
+
|
28
|
+
@cmd.options[:args] = []
|
29
|
+
|
30
|
+
use_ui @ui do
|
31
|
+
@cmd.execute
|
32
|
+
end
|
33
|
+
|
34
|
+
out = @ui.output.split "\n"
|
35
|
+
assert_equal "Updating installed gems", out.shift
|
36
|
+
assert_match %r|Bulk updating|, out.shift
|
37
|
+
assert_equal "Updating #{@a2.name}", out.shift
|
38
|
+
assert_equal "Successfully installed #{@a2.full_name}", out.shift
|
39
|
+
assert_equal "Gems updated: #{@a2.name}", out.shift
|
40
|
+
|
41
|
+
assert out.empty?, out.inspect
|
42
|
+
end
|
43
|
+
|
44
|
+
# before:
|
45
|
+
# a1 -> c1.2
|
46
|
+
# after:
|
47
|
+
# a2 -> b2 # new dependency
|
48
|
+
# a2 -> c2
|
49
|
+
|
50
|
+
def test_execute_dependencies
|
51
|
+
@a1.add_dependency 'c', '1.2'
|
52
|
+
|
53
|
+
@c2 = quick_gem 'c', '2' do |s|
|
54
|
+
s.files = %w[lib/code.rb]
|
55
|
+
s.require_paths = %w[lib]
|
56
|
+
end
|
57
|
+
|
58
|
+
@a2.add_dependency 'c', '2'
|
59
|
+
@a2.add_dependency 'b', '2'
|
60
|
+
|
61
|
+
@b2_path = File.join @gemhome, 'cache', "#{@b2.full_name}.gem"
|
62
|
+
@c1_2_path = File.join @gemhome, 'cache', "#{@c1_2.full_name}.gem"
|
63
|
+
@c2_path = File.join @gemhome, 'cache', "#{@c2.full_name}.gem"
|
64
|
+
|
65
|
+
@source_index = Gem::SourceIndex.new
|
66
|
+
@source_index.add_spec @a1
|
67
|
+
@source_index.add_spec @a2
|
68
|
+
@source_index.add_spec @b2
|
69
|
+
@source_index.add_spec @c1_2
|
70
|
+
@source_index.add_spec @c2
|
71
|
+
|
72
|
+
util_build_gem @a1
|
73
|
+
util_build_gem @a2
|
74
|
+
util_build_gem @c2
|
75
|
+
|
76
|
+
@fetcher.data["#{@gem_repo}/Marshal.#{@marshal_version}"] =
|
77
|
+
@source_index.dump
|
78
|
+
@fetcher.data["#{@gem_repo}/gems/#{@a1.full_name}.gem"] = read_binary @a1_path
|
79
|
+
@fetcher.data["#{@gem_repo}/gems/#{@a2.full_name}.gem"] = read_binary @a2_path
|
80
|
+
@fetcher.data["#{@gem_repo}/gems/#{@b2.full_name}.gem"] = read_binary @b2_path
|
81
|
+
@fetcher.data["#{@gem_repo}/gems/#{@c1_2.full_name}.gem"] =
|
82
|
+
read_binary @c1_2_path
|
83
|
+
@fetcher.data["#{@gem_repo}/gems/#{@c2.full_name}.gem"] = read_binary @c2_path
|
84
|
+
|
85
|
+
util_remove_gems
|
86
|
+
|
87
|
+
Gem::Installer.new(@c1_2_path).install
|
88
|
+
Gem::Installer.new(@a1_path).install
|
89
|
+
|
90
|
+
@cmd.options[:args] = []
|
91
|
+
|
92
|
+
use_ui @ui do
|
93
|
+
@cmd.execute
|
94
|
+
end
|
95
|
+
|
96
|
+
out = @ui.output.split "\n"
|
97
|
+
assert_equal "Updating installed gems", out.shift
|
98
|
+
assert_match %r|Bulk updating|, out.shift
|
99
|
+
assert_equal "Updating #{@a2.name}", out.shift
|
100
|
+
assert_equal "Successfully installed #{@c2.full_name}", out.shift
|
101
|
+
assert_equal "Successfully installed #{@b2.full_name}", out.shift
|
102
|
+
assert_equal "Successfully installed #{@a2.full_name}", out.shift
|
103
|
+
assert_equal "Gems updated: #{@c2.name}, #{@b2.name}, #{@a2.name}",
|
104
|
+
out.shift
|
105
|
+
|
106
|
+
assert out.empty?, out.inspect
|
107
|
+
end
|
108
|
+
|
109
|
+
def test_execute_named
|
110
|
+
util_remove_gems
|
111
|
+
|
112
|
+
Gem::Installer.new(@a1_path).install
|
113
|
+
|
114
|
+
@cmd.options[:args] = [@a1.name]
|
115
|
+
|
116
|
+
use_ui @ui do
|
117
|
+
@cmd.execute
|
118
|
+
end
|
119
|
+
|
120
|
+
out = @ui.output.split "\n"
|
121
|
+
assert_equal "Updating installed gems", out.shift
|
122
|
+
assert_match %r|Bulk updating|, out.shift
|
123
|
+
assert_equal "Updating #{@a2.name}", out.shift
|
124
|
+
assert_equal "Successfully installed #{@a2.full_name}", out.shift
|
125
|
+
assert_equal "Gems updated: #{@a2.name}", out.shift
|
126
|
+
|
127
|
+
assert out.empty?, out.inspect
|
128
|
+
end
|
129
|
+
|
130
|
+
def test_execute_named_up_to_date
|
131
|
+
util_remove_gems
|
132
|
+
|
133
|
+
Gem::Installer.new(@a2_path).install
|
134
|
+
|
135
|
+
@cmd.options[:args] = [@a2.name]
|
136
|
+
|
137
|
+
use_ui @ui do
|
138
|
+
@cmd.execute
|
139
|
+
end
|
140
|
+
|
141
|
+
out = @ui.output.split "\n"
|
142
|
+
assert_equal "Updating installed gems", out.shift
|
143
|
+
assert_match %r|Bulk updating|, out.shift
|
144
|
+
assert_equal "Nothing to update", out.shift
|
145
|
+
|
146
|
+
assert out.empty?, out.inspect
|
147
|
+
end
|
148
|
+
|
149
|
+
def test_execute_up_to_date
|
150
|
+
util_remove_gems
|
151
|
+
|
152
|
+
Gem::Installer.new(@a2_path).install
|
153
|
+
|
154
|
+
@cmd.options[:args] = []
|
155
|
+
|
156
|
+
use_ui @ui do
|
157
|
+
@cmd.execute
|
158
|
+
end
|
159
|
+
|
160
|
+
out = @ui.output.split "\n"
|
161
|
+
assert_equal "Updating installed gems", out.shift
|
162
|
+
assert_match %r|Bulk updating|, out.shift
|
163
|
+
assert_equal "Nothing to update", out.shift
|
164
|
+
|
165
|
+
assert out.empty?, out.inspect
|
166
|
+
end
|
167
|
+
|
168
|
+
def util_remove_gems
|
169
|
+
FileUtils.rm_r File.join(@gemhome, 'gems')
|
170
|
+
FileUtils.rm_r File.join(@gemhome, 'specifications')
|
171
|
+
end
|
172
|
+
|
173
|
+
end
|
174
|
+
|
Binary file
|
Binary file
|
Binary file
|
@@ -54,8 +54,8 @@ class TestGemDependencyInstaller < RubyGemTestCase
|
|
54
54
|
inst = nil
|
55
55
|
|
56
56
|
Dir.chdir @tempdir do
|
57
|
-
inst = Gem::DependencyInstaller.new
|
58
|
-
inst.install
|
57
|
+
inst = Gem::DependencyInstaller.new
|
58
|
+
inst.install 'a'
|
59
59
|
end
|
60
60
|
|
61
61
|
assert_equal Gem::SourceIndex.new(@a1.full_name => @a1),
|
@@ -70,8 +70,8 @@ class TestGemDependencyInstaller < RubyGemTestCase
|
|
70
70
|
inst = nil
|
71
71
|
|
72
72
|
Dir.chdir @tempdir do
|
73
|
-
inst = Gem::DependencyInstaller.new
|
74
|
-
inst.install
|
73
|
+
inst = Gem::DependencyInstaller.new
|
74
|
+
inst.install 'b'
|
75
75
|
end
|
76
76
|
|
77
77
|
assert_equal %w[a-1 b-1], inst.installed_gems.map { |s| s.full_name }
|
@@ -84,8 +84,8 @@ class TestGemDependencyInstaller < RubyGemTestCase
|
|
84
84
|
inst = nil
|
85
85
|
|
86
86
|
Dir.chdir @tempdir do
|
87
|
-
inst = Gem::DependencyInstaller.new
|
88
|
-
inst.install
|
87
|
+
inst = Gem::DependencyInstaller.new
|
88
|
+
inst.install 'b'
|
89
89
|
end
|
90
90
|
|
91
91
|
assert_equal %w[b-1], inst.installed_gems.map { |s| s.full_name }
|
@@ -102,8 +102,8 @@ class TestGemDependencyInstaller < RubyGemTestCase
|
|
102
102
|
inst = nil
|
103
103
|
|
104
104
|
Dir.chdir @tempdir do
|
105
|
-
inst = Gem::DependencyInstaller.new
|
106
|
-
inst.install
|
105
|
+
inst = Gem::DependencyInstaller.new
|
106
|
+
inst.install 'f'
|
107
107
|
end
|
108
108
|
|
109
109
|
assert_equal %w[f-2], inst.installed_gems.map { |s| s.full_name }
|
@@ -114,19 +114,49 @@ class TestGemDependencyInstaller < RubyGemTestCase
|
|
114
114
|
inst = nil
|
115
115
|
|
116
116
|
Dir.chdir @tempdir do
|
117
|
-
inst = Gem::DependencyInstaller.new
|
118
|
-
inst.install
|
117
|
+
inst = Gem::DependencyInstaller.new :domain => :local
|
118
|
+
inst.install 'a-1.gem'
|
119
119
|
end
|
120
120
|
|
121
121
|
assert_equal %w[a-1], inst.installed_gems.map { |s| s.full_name }
|
122
122
|
end
|
123
123
|
|
124
|
+
def test_install_local_dependency
|
125
|
+
FileUtils.mv @a1_gem, @tempdir
|
126
|
+
FileUtils.mv @b1_gem, @tempdir
|
127
|
+
|
128
|
+
inst = nil
|
129
|
+
|
130
|
+
Dir.chdir @tempdir do
|
131
|
+
inst = Gem::DependencyInstaller.new :domain => :local
|
132
|
+
inst.install 'b-1.gem'
|
133
|
+
end
|
134
|
+
|
135
|
+
assert_equal %w[a-1 b-1], inst.installed_gems.map { |s| s.full_name }
|
136
|
+
end
|
137
|
+
|
138
|
+
def test_install_local_dependency_installed
|
139
|
+
FileUtils.mv @a1_gem, @tempdir
|
140
|
+
FileUtils.mv @b1_gem, @tempdir
|
141
|
+
|
142
|
+
inst = nil
|
143
|
+
|
144
|
+
Dir.chdir @tempdir do
|
145
|
+
Gem::Installer.new('a-1.gem').install
|
146
|
+
|
147
|
+
inst = Gem::DependencyInstaller.new :domain => :local
|
148
|
+
inst.install 'b-1.gem'
|
149
|
+
end
|
150
|
+
|
151
|
+
assert_equal %w[b-1], inst.installed_gems.map { |s| s.full_name }
|
152
|
+
end
|
153
|
+
|
124
154
|
def test_install_local_subdir
|
125
155
|
inst = nil
|
126
|
-
|
156
|
+
|
127
157
|
Dir.chdir @tempdir do
|
128
|
-
inst = Gem::DependencyInstaller.new
|
129
|
-
inst.install
|
158
|
+
inst = Gem::DependencyInstaller.new :domain => :local
|
159
|
+
inst.install 'gems/a-1.gem'
|
130
160
|
end
|
131
161
|
|
132
162
|
assert_equal %w[a-1], inst.installed_gems.map { |s| s.full_name }
|
@@ -137,12 +167,11 @@ class TestGemDependencyInstaller < RubyGemTestCase
|
|
137
167
|
inst = nil
|
138
168
|
|
139
169
|
Dir.chdir @tempdir do
|
140
|
-
inst = Gem::DependencyInstaller.new
|
141
|
-
|
142
|
-
inst.install
|
170
|
+
inst = Gem::DependencyInstaller.new :env_shebang => true, :wrappers => true
|
171
|
+
inst.install 'a'
|
143
172
|
end
|
144
173
|
|
145
|
-
assert_match %r|\A#!/usr/bin/env
|
174
|
+
assert_match %r|\A#!/usr/bin/env #{Gem::ConfigMap[:RUBY_INSTALL_NAME]}\n|,
|
146
175
|
File.read(File.join(@gemhome, 'bin', 'a_bin'))
|
147
176
|
end
|
148
177
|
|
@@ -153,8 +182,8 @@ class TestGemDependencyInstaller < RubyGemTestCase
|
|
153
182
|
inst = nil
|
154
183
|
|
155
184
|
Dir.chdir @tempdir do
|
156
|
-
inst = Gem::DependencyInstaller.new
|
157
|
-
inst.install
|
185
|
+
inst = Gem::DependencyInstaller.new :force => true
|
186
|
+
inst.install 'b'
|
158
187
|
end
|
159
188
|
|
160
189
|
assert_equal %w[b-1], inst.installed_gems.map { |s| s.full_name }
|
@@ -165,8 +194,8 @@ class TestGemDependencyInstaller < RubyGemTestCase
|
|
165
194
|
inst = nil
|
166
195
|
|
167
196
|
Dir.chdir @tempdir do
|
168
|
-
inst = Gem::DependencyInstaller.new
|
169
|
-
inst.install
|
197
|
+
inst = Gem::DependencyInstaller.new :ignore_dependencies => true
|
198
|
+
inst.install 'b'
|
170
199
|
end
|
171
200
|
|
172
201
|
assert_equal %w[b-1], inst.installed_gems.map { |s| s.full_name }
|
@@ -179,8 +208,8 @@ class TestGemDependencyInstaller < RubyGemTestCase
|
|
179
208
|
inst = nil
|
180
209
|
|
181
210
|
Dir.chdir @tempdir do
|
182
|
-
inst = Gem::DependencyInstaller.new
|
183
|
-
inst.install
|
211
|
+
inst = Gem::DependencyInstaller.new :install_dir => gemhome2
|
212
|
+
inst.install 'a'
|
184
213
|
end
|
185
214
|
|
186
215
|
assert_equal %w[a-1], inst.installed_gems.map { |s| s.full_name }
|
@@ -201,8 +230,8 @@ class TestGemDependencyInstaller < RubyGemTestCase
|
|
201
230
|
inst = nil
|
202
231
|
|
203
232
|
Dir.chdir @tempdir do
|
204
|
-
inst = Gem::DependencyInstaller.new
|
205
|
-
inst.install
|
233
|
+
inst = Gem::DependencyInstaller.new :domain => :both
|
234
|
+
inst.install 'b'
|
206
235
|
end
|
207
236
|
|
208
237
|
assert_equal %w[a-1 b-1], inst.installed_gems.map { |s| s.full_name }
|
@@ -217,14 +246,34 @@ class TestGemDependencyInstaller < RubyGemTestCase
|
|
217
246
|
assert_equal b1_expected, b1.loaded_from
|
218
247
|
end
|
219
248
|
|
249
|
+
def test_install_domain_both_no_network
|
250
|
+
Gem::SourceInfoCache.instance_variable_set :@cache, nil
|
251
|
+
|
252
|
+
@fetcher.data["http://gems.example.com/gems/Marshal.#{@marshal_version}"] =
|
253
|
+
proc do
|
254
|
+
raise Gem::RemoteFetcher::FetchError
|
255
|
+
end
|
256
|
+
|
257
|
+
FileUtils.mv @a1_gem, @tempdir
|
258
|
+
FileUtils.mv @b1_gem, @tempdir
|
259
|
+
inst = nil
|
260
|
+
|
261
|
+
Dir.chdir @tempdir do
|
262
|
+
inst = Gem::DependencyInstaller.new :domain => :both
|
263
|
+
inst.install 'b'
|
264
|
+
end
|
265
|
+
|
266
|
+
assert_equal %w[a-1 b-1], inst.installed_gems.map { |s| s.full_name }
|
267
|
+
end
|
268
|
+
|
220
269
|
def test_install_domain_local
|
221
270
|
FileUtils.mv @b1_gem, @tempdir
|
222
271
|
inst = nil
|
223
272
|
|
224
273
|
Dir.chdir @tempdir do
|
225
274
|
e = assert_raise Gem::InstallError do
|
226
|
-
inst = Gem::DependencyInstaller.new
|
227
|
-
inst.install
|
275
|
+
inst = Gem::DependencyInstaller.new :domain => :local
|
276
|
+
inst.install 'b'
|
228
277
|
end
|
229
278
|
assert_equal 'b requires a (>= 0)', e.message
|
230
279
|
end
|
@@ -240,8 +289,43 @@ class TestGemDependencyInstaller < RubyGemTestCase
|
|
240
289
|
|
241
290
|
@fetcher.data['http://gems.example.com/gems/a-1.gem'] = a1_data
|
242
291
|
|
243
|
-
inst = Gem::DependencyInstaller.new
|
244
|
-
inst.install
|
292
|
+
inst = Gem::DependencyInstaller.new :domain => :remote
|
293
|
+
inst.install 'a'
|
294
|
+
|
295
|
+
assert_equal %w[a-1], inst.installed_gems.map { |s| s.full_name }
|
296
|
+
end
|
297
|
+
|
298
|
+
def test_install_remote
|
299
|
+
a1_data = nil
|
300
|
+
File.open @a1_gem, 'rb' do |fp|
|
301
|
+
a1_data = fp.read
|
302
|
+
end
|
303
|
+
|
304
|
+
@fetcher.data['http://gems.example.com/gems/a-1.gem'] = a1_data
|
305
|
+
|
306
|
+
inst = Gem::DependencyInstaller.new
|
307
|
+
|
308
|
+
Dir.chdir @tempdir do
|
309
|
+
inst.install 'a'
|
310
|
+
end
|
311
|
+
|
312
|
+
assert_equal %w[a-1], inst.installed_gems.map { |s| s.full_name }
|
313
|
+
end
|
314
|
+
|
315
|
+
def test_install_remote_dep
|
316
|
+
a1_data = nil
|
317
|
+
File.open @a1_gem, 'rb' do |fp|
|
318
|
+
a1_data = fp.read
|
319
|
+
end
|
320
|
+
|
321
|
+
@fetcher.data['http://gems.example.com/gems/a-1.gem'] = a1_data
|
322
|
+
|
323
|
+
inst = Gem::DependencyInstaller.new
|
324
|
+
|
325
|
+
Dir.chdir @tempdir do
|
326
|
+
dep = Gem::Dependency.new @a1.name, @a1.version
|
327
|
+
inst.install dep
|
328
|
+
end
|
245
329
|
|
246
330
|
assert_equal %w[a-1], inst.installed_gems.map { |s| s.full_name }
|
247
331
|
end
|
@@ -266,8 +350,8 @@ class TestGemDependencyInstaller < RubyGemTestCase
|
|
266
350
|
@fetcher.data["http://gems.example.com/gems/#{a2_o.full_name}.gem"] =
|
267
351
|
a2_o_data
|
268
352
|
|
269
|
-
inst = Gem::DependencyInstaller.new
|
270
|
-
inst.install
|
353
|
+
inst = Gem::DependencyInstaller.new :domain => :remote
|
354
|
+
inst.install 'a'
|
271
355
|
|
272
356
|
assert_equal %w[a-1], inst.installed_gems.map { |s| s.full_name }
|
273
357
|
end
|
@@ -278,8 +362,8 @@ class TestGemDependencyInstaller < RubyGemTestCase
|
|
278
362
|
inst = nil
|
279
363
|
|
280
364
|
Dir.chdir @tempdir do
|
281
|
-
inst = Gem::DependencyInstaller.new
|
282
|
-
inst.install
|
365
|
+
inst = Gem::DependencyInstaller.new
|
366
|
+
inst.install 'a'
|
283
367
|
end
|
284
368
|
|
285
369
|
assert_equal Gem::SourceIndex.new(@a1.full_name => @a1),
|
@@ -288,160 +372,69 @@ class TestGemDependencyInstaller < RubyGemTestCase
|
|
288
372
|
assert_equal %w[a-1], inst.installed_gems.map { |s| s.full_name }
|
289
373
|
end
|
290
374
|
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
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
|
375
|
+
if defined? OpenSSL then
|
376
|
+
def test_install_security_policy
|
377
|
+
data = File.open(@a1_gem, 'rb') { |f| f.read }
|
378
|
+
@fetcher.data['http://gems.example.com/gems/a-1.gem'] = data
|
309
379
|
|
310
|
-
|
380
|
+
data = File.open(@b1_gem, 'rb') { |f| f.read }
|
381
|
+
@fetcher.data['http://gems.example.com/gems/b-1.gem'] = data
|
311
382
|
|
312
|
-
|
313
|
-
|
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'
|
383
|
+
policy = Gem::Security::HighSecurity
|
384
|
+
inst = Gem::DependencyInstaller.new :security_policy => policy
|
320
385
|
|
321
|
-
|
322
|
-
|
323
|
-
|
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'
|
386
|
+
e = assert_raise Gem::Exception do
|
387
|
+
inst.install 'b'
|
388
|
+
end
|
330
389
|
|
331
|
-
|
390
|
+
assert_equal 'Unsigned gem', e.message
|
332
391
|
|
333
|
-
|
334
|
-
end
|
335
|
-
|
336
|
-
def test_download
|
337
|
-
a1_data = nil
|
338
|
-
File.open @a1_gem, 'rb' do |fp|
|
339
|
-
a1_data = fp.read
|
392
|
+
assert_equal %w[], inst.installed_gems.map { |s| s.full_name }
|
340
393
|
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
394
|
end
|
351
395
|
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
assert_equal File.join(@gemhome, 'cache', "#{@a1.full_name}.gem"),
|
358
|
-
inst.download(@a1, 'http://gems.example.com')
|
359
|
-
end
|
396
|
+
# Wrappers don't work on mswin
|
397
|
+
unless win_platform? then
|
398
|
+
def test_install_no_wrappers
|
399
|
+
@fetcher.data['http://gems.example.com/gems/a-1.gem'] = read_binary(@a1_gem)
|
360
400
|
|
361
|
-
|
362
|
-
|
363
|
-
local_path = File.join @tempdir, "#{@a1.full_name}.gem"
|
364
|
-
inst = nil
|
401
|
+
inst = Gem::DependencyInstaller.new :wrappers => false
|
402
|
+
inst.install 'a'
|
365
403
|
|
366
|
-
|
367
|
-
|
404
|
+
assert_no_match(%r|This file was generated by RubyGems.|,
|
405
|
+
File.read(File.join(@gemhome, 'bin', 'a_bin')))
|
368
406
|
end
|
369
|
-
|
370
|
-
assert_equal File.join(@gemhome, 'cache', "#{@a1.full_name}.gem"),
|
371
|
-
inst.download(@a1, local_path)
|
372
407
|
end
|
373
408
|
|
374
|
-
def
|
375
|
-
|
376
|
-
|
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')
|
409
|
+
def test_install_version
|
410
|
+
data = File.open(@d2_gem, 'rb') { |f| f.read }
|
411
|
+
@fetcher.data['http://gems.example.com/gems/d-2.gem'] = data
|
388
412
|
|
389
|
-
|
390
|
-
|
413
|
+
data = File.open(@d1_gem, 'rb') { |f| f.read }
|
414
|
+
@fetcher.data['http://gems.example.com/gems/d-1.gem'] = data
|
391
415
|
|
392
|
-
|
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')
|
416
|
+
inst = Gem::DependencyInstaller.new
|
398
417
|
|
399
|
-
|
400
|
-
inst = Gem::DependencyInstaller.new 'a'
|
401
|
-
end
|
418
|
+
inst.install 'd', '= 1'
|
402
419
|
|
403
|
-
|
404
|
-
inst.download(@a1, local_path)
|
405
|
-
ensure
|
406
|
-
File.chmod 0755, File.join(@gemhome, 'cache')
|
407
|
-
end
|
420
|
+
assert_equal %w[d-1], inst.installed_gems.map { |s| s.full_name }
|
408
421
|
end
|
409
422
|
|
410
|
-
def
|
411
|
-
|
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
|
423
|
+
def test_install_version_default
|
424
|
+
data = File.open(@d2_gem, 'rb') { |f| f.read }
|
425
|
+
@fetcher.data['http://gems.example.com/gems/d-2.gem'] = data
|
432
426
|
|
433
|
-
|
434
|
-
|
427
|
+
data = File.open(@d1_gem, 'rb') { |f| f.read }
|
428
|
+
@fetcher.data['http://gems.example.com/gems/d-1.gem'] = data
|
435
429
|
|
436
|
-
|
437
|
-
|
438
|
-
end
|
430
|
+
inst = Gem::DependencyInstaller.new
|
431
|
+
inst.install 'd'
|
439
432
|
|
440
|
-
assert_equal
|
433
|
+
assert_equal %w[d-2], inst.installed_gems.map { |s| s.full_name }
|
441
434
|
end
|
442
435
|
|
443
436
|
def test_find_gems_gems_with_sources
|
444
|
-
inst = Gem::DependencyInstaller.new
|
437
|
+
inst = Gem::DependencyInstaller.new
|
445
438
|
dep = Gem::Dependency.new 'b', '>= 0'
|
446
439
|
|
447
440
|
assert_equal [[@b1, 'http://gems.example.com']],
|
@@ -450,7 +443,7 @@ class TestGemDependencyInstaller < RubyGemTestCase
|
|
450
443
|
|
451
444
|
def test_find_gems_with_sources_local
|
452
445
|
FileUtils.mv @a1_gem, @tempdir
|
453
|
-
inst = Gem::DependencyInstaller.new
|
446
|
+
inst = Gem::DependencyInstaller.new
|
454
447
|
dep = Gem::Dependency.new 'a', '>= 0'
|
455
448
|
gems = nil
|
456
449
|
|
@@ -460,7 +453,7 @@ class TestGemDependencyInstaller < RubyGemTestCase
|
|
460
453
|
|
461
454
|
assert_equal 2, gems.length
|
462
455
|
remote = gems.first
|
463
|
-
assert_equal
|
456
|
+
assert_equal 'a-1', remote.first.full_name, 'remote spec'
|
464
457
|
assert_equal 'http://gems.example.com', remote.last, 'remote path'
|
465
458
|
|
466
459
|
local = gems.last
|
@@ -470,7 +463,9 @@ class TestGemDependencyInstaller < RubyGemTestCase
|
|
470
463
|
end
|
471
464
|
|
472
465
|
def test_gather_dependencies
|
473
|
-
inst = Gem::DependencyInstaller.new
|
466
|
+
inst = Gem::DependencyInstaller.new
|
467
|
+
inst.find_spec_by_name_and_version 'b'
|
468
|
+
inst.gather_dependencies
|
474
469
|
|
475
470
|
assert_equal %w[a-1 b-1], inst.gems_to_install.map { |s| s.full_name }
|
476
471
|
end
|
@@ -486,7 +481,9 @@ class TestGemDependencyInstaller < RubyGemTestCase
|
|
486
481
|
@fetcher.uri = URI.parse 'http://gems.example.com'
|
487
482
|
@fetcher.data['http://gems.example.com/gems/yaml'] = si.to_yaml
|
488
483
|
|
489
|
-
inst = Gem::DependencyInstaller.new
|
484
|
+
inst = Gem::DependencyInstaller.new
|
485
|
+
inst.find_spec_by_name_and_version 'c'
|
486
|
+
inst.gather_dependencies
|
490
487
|
|
491
488
|
assert_equal %w[b-2 c-1], inst.gems_to_install.map { |s| s.full_name }
|
492
489
|
end
|
@@ -494,14 +491,18 @@ class TestGemDependencyInstaller < RubyGemTestCase
|
|
494
491
|
def test_gather_dependencies_platform_alternate
|
495
492
|
util_set_arch 'cpu-my_platform1'
|
496
493
|
|
497
|
-
inst = Gem::DependencyInstaller.new
|
494
|
+
inst = Gem::DependencyInstaller.new
|
495
|
+
inst.find_spec_by_name_and_version 'w'
|
496
|
+
inst.gather_dependencies
|
498
497
|
|
499
498
|
assert_equal %w[x-1-cpu-my_platform-1 w-1],
|
500
499
|
inst.gems_to_install.map { |s| s.full_name }
|
501
500
|
end
|
502
501
|
|
503
502
|
def test_gather_dependencies_platform_bump
|
504
|
-
inst = Gem::DependencyInstaller.new
|
503
|
+
inst = Gem::DependencyInstaller.new
|
504
|
+
inst.find_spec_by_name_and_version 'z'
|
505
|
+
inst.gather_dependencies
|
505
506
|
|
506
507
|
assert_equal %w[y-1 z-1], inst.gems_to_install.map { |s| s.full_name }
|
507
508
|
end
|
@@ -516,27 +517,11 @@ class TestGemDependencyInstaller < RubyGemTestCase
|
|
516
517
|
@fetcher.uri = URI.parse 'http://gems.example.com'
|
517
518
|
@fetcher.data['http://gems.example.com/gems/yaml'] = si.to_yaml
|
518
519
|
|
519
|
-
inst = Gem::DependencyInstaller.new
|
520
|
+
inst = Gem::DependencyInstaller.new
|
521
|
+
inst.find_spec_by_name_and_version 'e'
|
522
|
+
inst.gather_dependencies
|
520
523
|
|
521
524
|
assert_equal %w[d-1 e-1], inst.gems_to_install.map { |s| s.full_name }
|
522
525
|
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
526
|
end
|
542
527
|
|