rubygems-update 1.5.3 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of rubygems-update might be problematic. Click here for more details.
- data.tar.gz.sig +2 -1
- data/History.txt +60 -9
- data/Manifest.txt +1 -1
- data/Rakefile +0 -2
- data/lib/rubygems.rb +142 -65
- data/lib/rubygems/commands/owner_command.rb +3 -2
- data/lib/rubygems/commands/pristine_command.rb +5 -3
- data/lib/rubygems/commands/push_command.rb +8 -4
- data/lib/rubygems/commands/setup_command.rb +1 -2
- data/lib/rubygems/commands/uninstall_command.rb +5 -0
- data/lib/rubygems/commands/unpack_command.rb +10 -16
- data/lib/rubygems/config_file.rb +12 -5
- data/lib/rubygems/custom_require.rb +27 -7
- data/lib/rubygems/dependency.rb +33 -8
- data/lib/rubygems/dependency_installer.rb +21 -6
- data/lib/rubygems/dependency_list.rb +35 -3
- data/lib/rubygems/doc_manager.rb +6 -4
- data/lib/rubygems/gem_path_searcher.rb +45 -1
- data/lib/rubygems/gemcutter_utilities.rb +33 -0
- data/lib/rubygems/indexer.rb +1 -0
- data/lib/rubygems/installer.rb +11 -7
- data/lib/rubygems/installer_test_case.rb +23 -15
- data/lib/rubygems/mock_gem_ui.rb +1 -1
- data/lib/rubygems/remote_fetcher.rb +29 -10
- data/lib/rubygems/requirement.rb +1 -1
- data/lib/rubygems/security.rb +1 -0
- data/lib/rubygems/source_index.rb +3 -2
- data/lib/rubygems/spec_fetcher.rb +3 -1
- data/lib/rubygems/specification.rb +54 -12
- data/lib/rubygems/test_case.rb +99 -28
- data/lib/rubygems/test_utilities.rb +11 -1
- data/lib/rubygems/uninstaller.rb +22 -11
- data/lib/rubygems/user_interaction.rb +50 -29
- data/lib/rubygems/validator.rb +1 -1
- data/test/rubygems/fix_openssl_warnings.rb +12 -0
- data/test/rubygems/plugin/load/rubygems_plugin.rb +3 -1
- data/test/rubygems/test_gem.rb +384 -38
- data/test/rubygems/test_gem_builder.rb +1 -1
- data/test/rubygems/test_gem_command_manager.rb +2 -2
- data/test/rubygems/test_gem_commands_build_command.rb +1 -1
- data/test/rubygems/test_gem_commands_cert_command.rb +2 -1
- data/test/rubygems/test_gem_commands_dependency_command.rb +6 -5
- data/test/rubygems/test_gem_commands_fetch_command.rb +4 -4
- data/test/rubygems/test_gem_commands_install_command.rb +21 -18
- data/test/rubygems/test_gem_commands_lock_command.rb +1 -1
- data/test/rubygems/test_gem_commands_outdated_command.rb +2 -5
- data/test/rubygems/test_gem_commands_owner_command.rb +42 -0
- data/test/rubygems/test_gem_commands_pristine_command.rb +28 -8
- data/test/rubygems/test_gem_commands_push_command.rb +31 -5
- data/test/rubygems/test_gem_commands_specification_command.rb +8 -8
- data/test/rubygems/test_gem_commands_stale_command.rb +4 -2
- data/test/rubygems/test_gem_commands_uninstall_command.rb +23 -4
- data/test/rubygems/test_gem_commands_unpack_command.rb +10 -8
- data/test/rubygems/test_gem_commands_update_command.rb +16 -13
- data/test/rubygems/test_gem_commands_which_command.rb +1 -1
- data/test/rubygems/test_gem_config_file.rb +14 -0
- data/test/rubygems/test_gem_dependency.rb +39 -0
- data/test/rubygems/test_gem_dependency_installer.rb +213 -92
- data/test/rubygems/test_gem_dependency_list.rb +37 -17
- data/test/rubygems/test_gem_doc_manager.rb +5 -4
- data/test/rubygems/test_gem_format.rb +2 -2
- data/test/rubygems/test_gem_gemcutter_utilities.rb +48 -0
- data/test/rubygems/test_gem_indexer.rb +11 -10
- data/test/rubygems/test_gem_install_update_options.rb +0 -2
- data/test/rubygems/test_gem_installer.rb +151 -78
- data/test/rubygems/test_gem_package_tar_output.rb +3 -0
- data/test/rubygems/test_gem_remote_fetcher.rb +23 -14
- data/test/rubygems/test_gem_requirement.rb +4 -0
- data/test/rubygems/test_gem_security.rb +1 -0
- data/test/rubygems/test_gem_source_index.rb +17 -16
- data/test/rubygems/test_gem_spec_fetcher.rb +6 -1
- data/test/rubygems/test_gem_specification.rb +81 -31
- data/test/rubygems/test_gem_stream_ui.rb +11 -1
- data/test/rubygems/test_gem_uninstaller.rb +70 -10
- data/test/rubygems/test_gem_validator.rb +1 -1
- data/test/rubygems/test_kernel.rb +1 -1
- metadata +7 -7
- metadata.gz.sig +0 -0
- data/ChangeLog +0 -5811
@@ -10,7 +10,7 @@ class TestGemCommandsSpecificationCommand < Gem::TestCase
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def test_execute
|
13
|
-
foo =
|
13
|
+
foo = quick_spec 'foo'
|
14
14
|
Gem.source_index.add_spec foo
|
15
15
|
|
16
16
|
@cmd.options[:args] = %w[foo]
|
@@ -25,8 +25,8 @@ class TestGemCommandsSpecificationCommand < Gem::TestCase
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def test_execute_all
|
28
|
-
|
29
|
-
|
28
|
+
quick_spec 'foo', '0.0.1'
|
29
|
+
quick_spec 'foo', '0.0.2'
|
30
30
|
|
31
31
|
@cmd.options[:args] = %w[foo]
|
32
32
|
@cmd.options[:all] = true
|
@@ -56,8 +56,8 @@ class TestGemCommandsSpecificationCommand < Gem::TestCase
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def test_execute_exact_match
|
59
|
-
|
60
|
-
|
59
|
+
quick_spec 'foo'
|
60
|
+
quick_spec 'foo_bar'
|
61
61
|
|
62
62
|
@cmd.options[:args] = %w[foo]
|
63
63
|
|
@@ -71,7 +71,7 @@ class TestGemCommandsSpecificationCommand < Gem::TestCase
|
|
71
71
|
end
|
72
72
|
|
73
73
|
def test_execute_field
|
74
|
-
foo =
|
74
|
+
foo = quick_spec 'foo'
|
75
75
|
Gem.source_index.add_spec foo
|
76
76
|
|
77
77
|
@cmd.options[:args] = %w[foo name]
|
@@ -84,7 +84,7 @@ class TestGemCommandsSpecificationCommand < Gem::TestCase
|
|
84
84
|
end
|
85
85
|
|
86
86
|
def test_execute_marshal
|
87
|
-
foo =
|
87
|
+
foo = quick_spec 'foo'
|
88
88
|
Gem.source_index.add_spec foo
|
89
89
|
|
90
90
|
@cmd.options[:args] = %w[foo]
|
@@ -120,7 +120,7 @@ class TestGemCommandsSpecificationCommand < Gem::TestCase
|
|
120
120
|
end
|
121
121
|
|
122
122
|
def test_execute_ruby
|
123
|
-
foo =
|
123
|
+
foo = quick_spec 'foo'
|
124
124
|
Gem.source_index.add_spec foo
|
125
125
|
|
126
126
|
@cmd.options[:args] = %w[foo]
|
@@ -10,10 +10,11 @@ class TestGemCommandsStaleCommand < Gem::TestCase
|
|
10
10
|
|
11
11
|
def test_execute_sorts
|
12
12
|
files = %w[lib/foo_bar.rb Rakefile]
|
13
|
-
foo_bar =
|
13
|
+
foo_bar = quick_spec 'foo_bar' do |gem|
|
14
14
|
gem.files = files
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
|
+
bar_baz = quick_spec 'bar_baz' do |gem|
|
17
18
|
gem.files = files
|
18
19
|
end
|
19
20
|
|
@@ -30,6 +31,7 @@ class TestGemCommandsStaleCommand < Gem::TestCase
|
|
30
31
|
use_ui @ui do
|
31
32
|
@cmd.execute
|
32
33
|
end
|
34
|
+
|
33
35
|
lines = @ui.output.split("\n")
|
34
36
|
assert_equal("#{foo_bar.name}-#{foo_bar.version}", lines[0].split.first)
|
35
37
|
assert_equal("#{bar_baz.name}-#{bar_baz.version}", lines[1].split.first)
|
@@ -27,7 +27,7 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
if win_platform?
|
30
|
+
if win_platform? then
|
31
31
|
assert File.exist?(@executable)
|
32
32
|
else
|
33
33
|
assert File.symlink?(@executable)
|
@@ -36,9 +36,9 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase
|
|
36
36
|
# Evil hack to prevent false removal success
|
37
37
|
FileUtils.rm_f @executable
|
38
38
|
|
39
|
-
open
|
39
|
+
open @executable, "wb+" do |f| f.puts "binary" end
|
40
40
|
|
41
|
-
@cmd.options[:args] =
|
41
|
+
@cmd.options[:args] = [@spec.name]
|
42
42
|
use_ui @ui do
|
43
43
|
@cmd.execute
|
44
44
|
end
|
@@ -50,6 +50,25 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase
|
|
50
50
|
assert_nil output.shift, "UI output should have contained only two lines"
|
51
51
|
end
|
52
52
|
|
53
|
+
def test_execute_removes_formatted_executable
|
54
|
+
FileUtils.rm_f @executable # Wish this didn't happen in #setup
|
55
|
+
|
56
|
+
Gem::Installer.exec_format = 'foo-%s-bar'
|
57
|
+
|
58
|
+
@installer.format_executable = true
|
59
|
+
@installer.install
|
60
|
+
|
61
|
+
formatted_executable = File.join @gemhome, 'bin', 'foo-executable-bar'
|
62
|
+
assert_equal true, File.exist?(formatted_executable)
|
63
|
+
|
64
|
+
@cmd.options[:format_executable] = true
|
65
|
+
@cmd.execute
|
66
|
+
|
67
|
+
assert_equal false, File.exist?(formatted_executable)
|
68
|
+
rescue
|
69
|
+
Gem::Installer.exec_format = nil
|
70
|
+
end
|
71
|
+
|
53
72
|
def test_execute_not_installed
|
54
73
|
@cmd.options[:args] = ["foo"]
|
55
74
|
e = assert_raises Gem::InstallError do
|
@@ -64,7 +83,7 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase
|
|
64
83
|
end
|
65
84
|
|
66
85
|
def test_execute_prerelease
|
67
|
-
@spec =
|
86
|
+
@spec = quick_spec "pre", "2.b"
|
68
87
|
@gem = File.join @tempdir, @spec.file_name
|
69
88
|
FileUtils.touch @gem
|
70
89
|
|
@@ -16,7 +16,7 @@ class TestGemCommandsUnpackCommand < Gem::TestCase
|
|
16
16
|
|
17
17
|
assert_equal(
|
18
18
|
@cmd.find_in_cache(@a1.file_name),
|
19
|
-
|
19
|
+
Gem.cache_gem(@a1.file_name, @gemhome),
|
20
20
|
'found a-1.gem in the cache'
|
21
21
|
)
|
22
22
|
end
|
@@ -28,7 +28,7 @@ class TestGemCommandsUnpackCommand < Gem::TestCase
|
|
28
28
|
|
29
29
|
a1_data = nil
|
30
30
|
|
31
|
-
open
|
31
|
+
open Gem.cache_gem(@a1.file_name, @gemhome), 'rb' do |fp|
|
32
32
|
a1_data = fp.read
|
33
33
|
end
|
34
34
|
|
@@ -38,15 +38,15 @@ class TestGemCommandsUnpackCommand < Gem::TestCase
|
|
38
38
|
dep = Gem::Dependency.new(@a1.name, @a1.version)
|
39
39
|
assert_equal(
|
40
40
|
@cmd.get_path(dep),
|
41
|
-
|
41
|
+
Gem.cache_gem(@a1.file_name, @gemhome),
|
42
42
|
'fetches a-1 and returns the cache path'
|
43
43
|
)
|
44
44
|
|
45
|
-
FileUtils.rm
|
45
|
+
FileUtils.rm Gem.cache_gem(@a1.file_name, @gemhome)
|
46
46
|
|
47
47
|
assert_equal(
|
48
48
|
@cmd.get_path(dep),
|
49
|
-
|
49
|
+
Gem.cache_gem(@a1.file_name, @gemhome),
|
50
50
|
'when removed from cache, refetches a-1'
|
51
51
|
)
|
52
52
|
end
|
@@ -68,6 +68,8 @@ class TestGemCommandsUnpackCommand < Gem::TestCase
|
|
68
68
|
|
69
69
|
def test_execute_gem_path
|
70
70
|
util_make_gems
|
71
|
+
util_setup_spec_fetcher
|
72
|
+
util_setup_fake_fetcher
|
71
73
|
|
72
74
|
Gem.clear_paths
|
73
75
|
|
@@ -115,7 +117,7 @@ class TestGemCommandsUnpackCommand < Gem::TestCase
|
|
115
117
|
util_clear_gems
|
116
118
|
|
117
119
|
a2_data = nil
|
118
|
-
open
|
120
|
+
open Gem.cache_gem(@a2.file_name, @gemhome), 'rb' do |fp|
|
119
121
|
a2_data = fp.read
|
120
122
|
end
|
121
123
|
|
@@ -169,8 +171,8 @@ class TestGemCommandsUnpackCommand < Gem::TestCase
|
|
169
171
|
end
|
170
172
|
|
171
173
|
def test_execute_exact_match
|
172
|
-
foo_spec =
|
173
|
-
foo_bar_spec =
|
174
|
+
foo_spec = quick_spec 'foo'
|
175
|
+
foo_bar_spec = quick_spec 'foo_bar'
|
174
176
|
|
175
177
|
use_ui @ui do
|
176
178
|
Dir.chdir @tempdir do
|
@@ -1,6 +1,12 @@
|
|
1
1
|
require 'rubygems/test_case'
|
2
2
|
require 'rubygems/commands/update_command'
|
3
3
|
|
4
|
+
begin
|
5
|
+
gem "rdoc"
|
6
|
+
rescue Gem::LoadError
|
7
|
+
# ignore
|
8
|
+
end
|
9
|
+
|
4
10
|
class TestGemCommandsUpdateCommand < Gem::TestCase
|
5
11
|
|
6
12
|
def setup
|
@@ -13,8 +19,8 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
|
|
13
19
|
|
14
20
|
util_setup_fake_fetcher
|
15
21
|
|
16
|
-
@a1_path =
|
17
|
-
@a2_path =
|
22
|
+
@a1_path = Gem.cache_gem(@a1.file_name, @gemhome)
|
23
|
+
@a2_path = Gem.cache_gem(@a2.file_name, @gemhome)
|
18
24
|
|
19
25
|
util_setup_spec_fetcher @a1, @a2
|
20
26
|
|
@@ -30,8 +36,8 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
|
|
30
36
|
Gem::Installer.new(@a1_path).install
|
31
37
|
|
32
38
|
@cmd.options[:args] = []
|
33
|
-
@cmd.options[:generate_rdoc] =
|
34
|
-
@cmd.options[:generate_ri] =
|
39
|
+
@cmd.options[:generate_rdoc] = false
|
40
|
+
@cmd.options[:generate_ri] = false
|
35
41
|
|
36
42
|
use_ui @ui do
|
37
43
|
@cmd.execute
|
@@ -42,14 +48,11 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
|
|
42
48
|
assert_equal "Updating #{@a2.name}", out.shift
|
43
49
|
assert_equal "Successfully installed #{@a2.full_name}", out.shift
|
44
50
|
assert_equal "Gems updated: #{@a2.name}", out.shift
|
45
|
-
assert_equal "Installing ri documentation for a-2...", out.shift
|
46
|
-
assert_equal "Installing RDoc documentation for a-2...", out.shift
|
47
|
-
|
48
51
|
assert_empty out
|
49
52
|
end
|
50
53
|
|
51
54
|
def util_setup_rubygem version
|
52
|
-
gem =
|
55
|
+
gem = quick_spec('rubygems-update', version.to_s) do |s|
|
53
56
|
s.files = %w[setup.rb]
|
54
57
|
end
|
55
58
|
write_file File.join(*%W[gems #{gem.original_name} setup.rb])
|
@@ -72,7 +75,7 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
|
|
72
75
|
|
73
76
|
def util_add_to_fetcher *specs
|
74
77
|
specs.each do |spec|
|
75
|
-
gem_file =
|
78
|
+
gem_file = Gem.cache_gem(spec.file_name, @gemhome)
|
76
79
|
|
77
80
|
@fetcher.data["http://gems.example.com/gems/#{spec.file_name}"] =
|
78
81
|
Gem.read_binary gem_file
|
@@ -201,7 +204,7 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
|
|
201
204
|
def test_execute_dependencies
|
202
205
|
@a1.add_dependency 'c', '1.2'
|
203
206
|
|
204
|
-
@c2 =
|
207
|
+
@c2 = quick_spec 'c', '2' do |s|
|
205
208
|
s.files = %w[lib/code.rb]
|
206
209
|
s.require_paths = %w[lib]
|
207
210
|
end
|
@@ -209,9 +212,9 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
|
|
209
212
|
@a2.add_dependency 'c', '2'
|
210
213
|
@a2.add_dependency 'b', '2'
|
211
214
|
|
212
|
-
@b2_path =
|
213
|
-
@c1_2_path =
|
214
|
-
@c2_path =
|
215
|
+
@b2_path = Gem.cache_gem(@b2.file_name, @gemhome)
|
216
|
+
@c1_2_path = Gem.cache_gem(@c1_2.file_name, @gemhome)
|
217
|
+
@c2_path = Gem.cache_gem(@c2.file_name, @gemhome)
|
215
218
|
|
216
219
|
@source_index = Gem::SourceIndex.new
|
217
220
|
@source_index.add_spec @a1
|
@@ -277,6 +277,20 @@ class TestGemConfigFile < Gem::TestCase
|
|
277
277
|
assert_equal "701229f217cdf23b1344c7b4b54ca97", @cfg.rubygems_api_key
|
278
278
|
end
|
279
279
|
|
280
|
+
def test_load_api_keys_from_config
|
281
|
+
temp_cred = File.join Gem.user_home, '.gem', 'credentials'
|
282
|
+
FileUtils.mkdir File.dirname(temp_cred)
|
283
|
+
File.open temp_cred, 'w' do |fp|
|
284
|
+
fp.puts ":rubygems_api_key: 701229f217cdf23b1344c7b4b54ca97"
|
285
|
+
fp.puts ":other: a5fdbb6ba150cbb83aad2bb2fede64c"
|
286
|
+
end
|
287
|
+
|
288
|
+
util_config_file
|
289
|
+
|
290
|
+
assert_equal({:rubygems => '701229f217cdf23b1344c7b4b54ca97',
|
291
|
+
:other => 'a5fdbb6ba150cbb83aad2bb2fede64c'}, @cfg.api_keys)
|
292
|
+
end
|
293
|
+
|
280
294
|
def util_config_file(args = @cfg_args)
|
281
295
|
@cfg = Gem::ConfigFile.new args
|
282
296
|
end
|
@@ -100,6 +100,45 @@ class TestGemDependency < Gem::TestCase
|
|
100
100
|
refute_equal dep("pkg", :development), dep("pkg", :runtime), "type"
|
101
101
|
end
|
102
102
|
|
103
|
+
def test_merge
|
104
|
+
a1 = dep 'a', '~> 1.0'
|
105
|
+
a2 = dep 'a', '= 1.0'
|
106
|
+
|
107
|
+
a3 = a1.merge a2
|
108
|
+
|
109
|
+
assert_equal dep('a', '~> 1.0', '= 1.0'), a3
|
110
|
+
end
|
111
|
+
|
112
|
+
def test_merge_default
|
113
|
+
a1 = dep 'a'
|
114
|
+
a2 = dep 'a', '1'
|
115
|
+
|
116
|
+
a3 = a1.merge a2
|
117
|
+
|
118
|
+
assert_equal dep('a', '1'), a3
|
119
|
+
end
|
120
|
+
|
121
|
+
def test_merge_name_mismatch
|
122
|
+
a = dep 'a'
|
123
|
+
b = dep 'b'
|
124
|
+
|
125
|
+
e = assert_raises ArgumentError do
|
126
|
+
a.merge b
|
127
|
+
end
|
128
|
+
|
129
|
+
assert_equal 'a (>= 0) and b (>= 0) have different names',
|
130
|
+
e.message
|
131
|
+
end
|
132
|
+
|
133
|
+
def test_merge_other_default
|
134
|
+
a1 = dep 'a', '1'
|
135
|
+
a2 = dep 'a'
|
136
|
+
|
137
|
+
a3 = a1.merge a2
|
138
|
+
|
139
|
+
assert_equal dep('a', '1'), a3
|
140
|
+
end
|
141
|
+
|
103
142
|
def test_prerelease_eh
|
104
143
|
d = dep "pkg", "= 1"
|
105
144
|
|
@@ -1,65 +1,27 @@
|
|
1
1
|
require 'rubygems/test_case'
|
2
2
|
require 'rubygems/dependency_installer'
|
3
|
+
require 'rubygems/security'
|
3
4
|
|
4
5
|
class TestGemDependencyInstaller < Gem::TestCase
|
5
6
|
|
6
7
|
def setup
|
7
8
|
super
|
8
9
|
|
9
|
-
@gems_dir
|
10
|
-
@cache_dir =
|
11
|
-
FileUtils.mkdir @gems_dir
|
10
|
+
@gems_dir = File.join @tempdir, 'gems'
|
11
|
+
@cache_dir = Gem.cache_dir(@gemhome)
|
12
12
|
|
13
|
-
|
14
|
-
fp.puts "#!/usr/bin/ruby"
|
15
|
-
end
|
13
|
+
FileUtils.mkdir @gems_dir
|
16
14
|
|
17
|
-
@a1, @a1_gem
|
18
|
-
@aa1, @aa1_gem = util_gem 'aa', '1'
|
15
|
+
@a1, @a1_gem = util_gem 'a', '1' do |s| s.executables << 'a_bin' end
|
19
16
|
@a1_pre, @a1_pre_gem = util_gem 'a', '1.a'
|
20
|
-
|
21
|
-
@b1, @b1_gem = util_gem 'b', '1' do |s|
|
22
|
-
s.add_dependency 'a'
|
23
|
-
s.add_development_dependency 'aa'
|
24
|
-
end
|
25
|
-
|
26
|
-
@b1_pre, @b1_pre_gem = util_gem 'b', '1.a' do |s|
|
17
|
+
@b1, @b1_gem = util_gem 'b', '1' do |s|
|
27
18
|
s.add_dependency 'a'
|
28
19
|
s.add_development_dependency 'aa'
|
29
20
|
end
|
30
21
|
|
31
|
-
|
32
|
-
s.add_dependency 'a', '1.a'
|
33
|
-
s.add_dependency 'b', '1'
|
34
|
-
end
|
35
|
-
|
36
|
-
@d1, @d1_gem = util_gem 'd', '1'
|
37
|
-
@d2, @d2_gem = util_gem 'd', '2'
|
38
|
-
|
39
|
-
@x1_m, @x1_m_gem = util_gem 'x', '1' do |s|
|
40
|
-
s.platform = Gem::Platform.new %w[cpu my_platform 1]
|
41
|
-
end
|
42
|
-
|
43
|
-
@x1_o, @x1_o_gem = util_gem 'x', '1' do |s|
|
44
|
-
s.platform = Gem::Platform.new %w[cpu other_platform 1]
|
45
|
-
end
|
46
|
-
|
47
|
-
@w1, @w1_gem = util_gem 'w', '1', 'x' => nil
|
48
|
-
|
49
|
-
@y1, @y1_gem = util_gem 'y', '1'
|
50
|
-
@y1_1_p, @y1_1_p_gem = util_gem 'y', '1.1' do |s|
|
51
|
-
s.platform = Gem::Platform.new %w[cpu my_platform 1]
|
52
|
-
end
|
53
|
-
|
54
|
-
@z1, @z1_gem = util_gem 'z', '1', 'y' => nil
|
55
|
-
|
56
|
-
@fetcher = Gem::FakeFetcher.new
|
57
|
-
Gem::RemoteFetcher.fetcher = @fetcher
|
58
|
-
|
59
|
-
util_setup_spec_fetcher(@a1, @a1_pre, @b1, @b1_pre, @c1_pre, @d1, @d2,
|
60
|
-
@x1_m, @x1_o, @w1, @y1, @y1_1_p, @z1)
|
22
|
+
Gem::RemoteFetcher.fetcher = @fetcher = Gem::FakeFetcher.new
|
61
23
|
|
62
|
-
|
24
|
+
util_reset_gems
|
63
25
|
end
|
64
26
|
|
65
27
|
def test_install
|
@@ -114,8 +76,8 @@ class TestGemDependencyInstaller < Gem::TestCase
|
|
114
76
|
|
115
77
|
assert_equal %w[a-1 b-1], inst.installed_gems.map { |s| s.full_name }
|
116
78
|
|
117
|
-
assert
|
118
|
-
assert
|
79
|
+
assert Gem.cache_gem(@a1.file_name, @gemhome)
|
80
|
+
assert Gem.cache_gem(@b1.file_name, @gemhome)
|
119
81
|
end
|
120
82
|
|
121
83
|
def test_install_dependencies_satisfied
|
@@ -162,6 +124,10 @@ class TestGemDependencyInstaller < Gem::TestCase
|
|
162
124
|
end
|
163
125
|
|
164
126
|
def test_install_dependency_development
|
127
|
+
@aa1, @aa1_gem = util_gem 'aa', '1'
|
128
|
+
|
129
|
+
util_reset_gems
|
130
|
+
|
165
131
|
FileUtils.mv @a1_gem, @tempdir
|
166
132
|
FileUtils.mv @aa1_gem, @tempdir
|
167
133
|
FileUtils.mv @b1_gem, @tempdir
|
@@ -315,7 +281,7 @@ class TestGemDependencyInstaller < Gem::TestCase
|
|
315
281
|
assert_equal %w[a-1], inst.installed_gems.map { |s| s.full_name }
|
316
282
|
|
317
283
|
assert File.exist?(File.join(gemhome2, 'specifications', @a1.spec_name))
|
318
|
-
assert File.exist?(
|
284
|
+
assert File.exist?(Gem.cache_gem(@a1.file_name, gemhome2))
|
319
285
|
end
|
320
286
|
|
321
287
|
def test_install_domain_both
|
@@ -370,12 +336,13 @@ class TestGemDependencyInstaller < Gem::TestCase
|
|
370
336
|
Gem.source_index.remove_spec @a1_pre.full_name
|
371
337
|
|
372
338
|
Dir.chdir @tempdir do
|
373
|
-
e = assert_raises Gem::
|
339
|
+
e = assert_raises Gem::DependencyError do
|
374
340
|
inst = Gem::DependencyInstaller.new :domain => :local
|
375
341
|
inst.install 'b'
|
376
342
|
end
|
377
343
|
|
378
|
-
|
344
|
+
expected = "Unable to resolve dependencies: b requires a (>= 0)"
|
345
|
+
assert_equal expected, e.message
|
379
346
|
end
|
380
347
|
|
381
348
|
assert_equal [], inst.installed_gems.map { |s| s.full_name }
|
@@ -419,6 +386,22 @@ class TestGemDependencyInstaller < Gem::TestCase
|
|
419
386
|
assert_equal %w[b-1], inst.installed_gems.map { |s| s.full_name }
|
420
387
|
end
|
421
388
|
|
389
|
+
def test_install_reinstall
|
390
|
+
Gem::Installer.new(@a1_gem).install
|
391
|
+
FileUtils.mv @a1_gem, @tempdir
|
392
|
+
inst = nil
|
393
|
+
|
394
|
+
Dir.chdir @tempdir do
|
395
|
+
inst = Gem::DependencyInstaller.new
|
396
|
+
inst.install 'a'
|
397
|
+
end
|
398
|
+
|
399
|
+
assert_equal Gem::SourceIndex.new(@a1.full_name => @a1),
|
400
|
+
Gem::SourceIndex.from_installed_gems
|
401
|
+
|
402
|
+
assert_equal %w[a-1], inst.installed_gems.map { |s| s.full_name }
|
403
|
+
end
|
404
|
+
|
422
405
|
def test_install_remote
|
423
406
|
a1_data = nil
|
424
407
|
File.open @a1_gem, 'rb' do |fp|
|
@@ -454,7 +437,7 @@ class TestGemDependencyInstaller < Gem::TestCase
|
|
454
437
|
assert_equal %w[a-1], inst.installed_gems.map { |s| s.full_name }
|
455
438
|
end
|
456
439
|
|
457
|
-
def
|
440
|
+
def test_install_remote_platform_newer
|
458
441
|
a2_o, a2_o_gem = util_gem 'a', '2' do |s|
|
459
442
|
s.platform = Gem::Platform.new %w[cpu other_platform 1]
|
460
443
|
end
|
@@ -482,22 +465,6 @@ class TestGemDependencyInstaller < Gem::TestCase
|
|
482
465
|
assert_equal %w[a-1], inst.installed_gems.map { |s| s.full_name }
|
483
466
|
end
|
484
467
|
|
485
|
-
def test_install_reinstall
|
486
|
-
Gem::Installer.new(@a1_gem).install
|
487
|
-
FileUtils.mv @a1_gem, @tempdir
|
488
|
-
inst = nil
|
489
|
-
|
490
|
-
Dir.chdir @tempdir do
|
491
|
-
inst = Gem::DependencyInstaller.new
|
492
|
-
inst.install 'a'
|
493
|
-
end
|
494
|
-
|
495
|
-
assert_equal Gem::SourceIndex.new(@a1.full_name => @a1),
|
496
|
-
Gem::SourceIndex.from_installed_gems
|
497
|
-
|
498
|
-
assert_equal %w[a-1], inst.installed_gems.map { |s| s.full_name }
|
499
|
-
end
|
500
|
-
|
501
468
|
if defined? OpenSSL then
|
502
469
|
def test_install_security_policy
|
503
470
|
data = File.open(@a1_gem, 'rb') { |f| f.read }
|
@@ -533,6 +500,8 @@ class TestGemDependencyInstaller < Gem::TestCase
|
|
533
500
|
end
|
534
501
|
|
535
502
|
def test_install_version
|
503
|
+
util_setup_d
|
504
|
+
|
536
505
|
data = File.open(@d2_gem, 'rb') { |f| f.read }
|
537
506
|
@fetcher.data['http://gems.example.com/gems/d-2.gem'] = data
|
538
507
|
|
@@ -547,6 +516,8 @@ class TestGemDependencyInstaller < Gem::TestCase
|
|
547
516
|
end
|
548
517
|
|
549
518
|
def test_install_version_default
|
519
|
+
util_setup_d
|
520
|
+
|
550
521
|
data = File.open(@d2_gem, 'rb') { |f| f.read }
|
551
522
|
@fetcher.data['http://gems.example.com/gems/d-2.gem'] = data
|
552
523
|
|
@@ -613,7 +584,22 @@ class TestGemDependencyInstaller < Gem::TestCase
|
|
613
584
|
util_setup_spec_fetcher(*specs)
|
614
585
|
|
615
586
|
inst = Gem::DependencyInstaller.new
|
616
|
-
inst.find_spec_by_name_and_version
|
587
|
+
inst.find_spec_by_name_and_version specs.first.name
|
588
|
+
inst.gather_dependencies
|
589
|
+
|
590
|
+
actual = inst.gems_to_install.map { |s| s.full_name }
|
591
|
+
assert_equal expected, actual
|
592
|
+
end
|
593
|
+
|
594
|
+
def assert_resolve_pre expected, *specs
|
595
|
+
util_clear_gems
|
596
|
+
|
597
|
+
util_setup_spec_fetcher(*specs)
|
598
|
+
|
599
|
+
spec = specs.first
|
600
|
+
|
601
|
+
inst = Gem::DependencyInstaller.new :prerelease => true
|
602
|
+
inst.find_spec_by_name_and_version spec.name, spec.version
|
617
603
|
inst.gather_dependencies
|
618
604
|
|
619
605
|
actual = inst.gems_to_install.map { |s| s.full_name }
|
@@ -628,47 +614,182 @@ class TestGemDependencyInstaller < Gem::TestCase
|
|
628
614
|
assert_equal %w[a-1 b-1], inst.gems_to_install.map { |s| s.full_name }
|
629
615
|
end
|
630
616
|
|
617
|
+
##
|
618
|
+
# [A1] depends on
|
619
|
+
# [B] > 0 (satisfied by 2.0)
|
620
|
+
# [B1] depends on
|
621
|
+
# [C] > 0 (satisfied by 1.0)
|
622
|
+
# [B2] depends on nothing!
|
623
|
+
# [C1] depends on nothing
|
624
|
+
|
625
|
+
def test_gather_dependencies_dropped
|
626
|
+
a1, = util_spec 'a', '1', 'b' => nil
|
627
|
+
b1, = util_spec 'b', '1', 'c' => nil
|
628
|
+
b2, = util_spec 'b', '2'
|
629
|
+
c1, = util_spec 'c', '1'
|
630
|
+
|
631
|
+
assert_resolve %w[b-2 a-1], a1, b1, b2, c1
|
632
|
+
end
|
633
|
+
|
634
|
+
##
|
635
|
+
# [A] depends on
|
636
|
+
# [B] >= 1.0 (satisfied by 1.1) depends on
|
637
|
+
# [Z]
|
638
|
+
# [C] >= 1.0 depends on
|
639
|
+
# [B] = 1.0
|
640
|
+
#
|
641
|
+
# and should backtrack to resolve using b-1.0, pruning Z from the
|
642
|
+
# resolve.
|
643
|
+
|
644
|
+
def test_gather_dependencies_raggi_the_edgecase_generator
|
645
|
+
a, _ = util_spec 'a', '1.0', 'b' => '>= 1.0', 'c' => '>= 1.0'
|
646
|
+
b1, _ = util_spec 'b', '1.0'
|
647
|
+
b2, _ = util_spec 'b', '1.1', 'z' => '>= 1.0'
|
648
|
+
c, _ = util_spec 'c', '1.0', 'b' => '= 1.0'
|
649
|
+
|
650
|
+
assert_resolve %w[b-1.0 c-1.0 a-1.0], a, b1, b2, c
|
651
|
+
end
|
652
|
+
|
653
|
+
##
|
654
|
+
# [A] depends on
|
655
|
+
# [B] >= 1.0 (satisfied by 2.0)
|
656
|
+
# [C] = 1.0 depends on
|
657
|
+
# [B] ~> 1.0
|
658
|
+
#
|
659
|
+
# and should resolve using b-1.0
|
660
|
+
|
661
|
+
def test_gather_dependencies_over
|
662
|
+
a, _ = util_spec 'a', '1.0', 'b' => '>= 1.0', 'c' => '= 1.0'
|
663
|
+
b1, _ = util_spec 'b', '1.0'
|
664
|
+
b2, _ = util_spec 'b', '2.0'
|
665
|
+
c, _ = util_spec 'c', '1.0', 'b' => '~> 1.0'
|
666
|
+
|
667
|
+
assert_resolve %w[b-1.0 c-1.0 a-1.0], a, b1, b2, c
|
668
|
+
end
|
669
|
+
|
670
|
+
##
|
671
|
+
# [A] depends on
|
672
|
+
# [B] ~> 1.0 (satisfied by 1.1)
|
673
|
+
# [C] = 1.0 depends on
|
674
|
+
# [B] = 1.0
|
675
|
+
#
|
676
|
+
# and should resolve using b-1.0
|
677
|
+
#
|
678
|
+
# TODO: this is not under, but over... under would require depth
|
679
|
+
# first resolve through a dependency that is later pruned.
|
680
|
+
|
681
|
+
def test_gather_dependencies_under
|
682
|
+
a, _ = util_spec 'a', '1.0', 'b' => '~> 1.0', 'c' => '= 1.0'
|
683
|
+
b10, _ = util_spec 'b', '1.0'
|
684
|
+
b11, _ = util_spec 'b', '1.1'
|
685
|
+
c, _ = util_spec 'c', '1.0', 'b' => '= 1.0'
|
686
|
+
|
687
|
+
assert_resolve %w[b-1.0 c-1.0 a-1.0], a, b10, b11, c
|
688
|
+
end
|
689
|
+
|
690
|
+
# under
|
691
|
+
#
|
692
|
+
# [A] depends on
|
693
|
+
# [B] ~> 1.0 (satisfied by 1.0)
|
694
|
+
# [C] = 1.0 depends on
|
695
|
+
# [B] = 2.0
|
696
|
+
|
697
|
+
def test_gather_dependencies_divergent
|
698
|
+
a, _ = util_spec 'a', '1.0', 'b' => '~> 1.0', 'c' => '= 1.0'
|
699
|
+
b1, _ = util_spec 'b', '1.0'
|
700
|
+
b2, _ = util_spec 'b', '2.0'
|
701
|
+
c, _ = util_spec 'c', '1.0', 'b' => '= 2.0'
|
702
|
+
|
703
|
+
assert_raises Gem::DependencyError do
|
704
|
+
assert_resolve :ignored, a, b1, b2, c
|
705
|
+
end
|
706
|
+
end
|
707
|
+
|
631
708
|
def test_gather_dependencies_platform_alternate
|
709
|
+
util_setup_wxyz
|
632
710
|
util_set_arch 'cpu-my_platform1'
|
633
711
|
|
634
|
-
|
635
|
-
inst.find_spec_by_name_and_version 'w'
|
636
|
-
inst.gather_dependencies
|
637
|
-
|
638
|
-
assert_equal %w[x-1-cpu-my_platform-1 w-1],
|
639
|
-
inst.gems_to_install.map { |s| s.full_name }
|
712
|
+
assert_resolve %w[x-1-cpu-my_platform-1 w-1], @w1, @x1_m
|
640
713
|
end
|
641
714
|
|
642
715
|
def test_gather_dependencies_platform_bump
|
643
|
-
|
644
|
-
inst.find_spec_by_name_and_version 'z'
|
645
|
-
inst.gather_dependencies
|
716
|
+
util_setup_wxyz
|
646
717
|
|
647
|
-
|
718
|
+
assert_resolve %w[y-1 z-1], @z1, @y1
|
648
719
|
end
|
649
720
|
|
650
721
|
def test_gather_dependencies_prerelease
|
651
|
-
|
652
|
-
inst.find_spec_by_name_and_version 'c', '1.a'
|
653
|
-
inst.gather_dependencies
|
722
|
+
util_setup_c1_pre
|
654
723
|
|
655
|
-
|
656
|
-
inst.gems_to_install.map { |s| s.full_name }
|
724
|
+
assert_resolve_pre %w[a-1.a b-1 c-1.a], @c1_pre, @a1_pre, @b1
|
657
725
|
end
|
658
726
|
|
659
727
|
def test_gather_dependencies_old_required
|
660
|
-
|
661
|
-
|
728
|
+
util_setup_d
|
729
|
+
e1, = util_spec 'e', '1', 'd' => '= 1'
|
662
730
|
util_clear_gems
|
663
731
|
|
664
|
-
|
732
|
+
assert_resolve %w[d-1 e-1], e1, @d1, @d2
|
733
|
+
end
|
665
734
|
|
666
|
-
|
667
|
-
|
668
|
-
|
735
|
+
def util_write_a1_bin
|
736
|
+
write_file File.join('gems', 'a-1', 'bin', 'a_bin') do |fp|
|
737
|
+
fp.puts "#!/usr/bin/ruby"
|
738
|
+
end
|
739
|
+
end
|
740
|
+
|
741
|
+
def util_setup_c1_pre
|
742
|
+
@c1_pre, @c1_pre_gem = util_spec 'c', '1.a' do |s|
|
743
|
+
s.add_dependency 'a', '1.a'
|
744
|
+
s.add_dependency 'b', '1'
|
745
|
+
end
|
669
746
|
|
670
|
-
|
747
|
+
util_reset_gems
|
671
748
|
end
|
672
749
|
|
673
|
-
|
750
|
+
def util_setup_d
|
751
|
+
@d1, @d1_gem = util_gem 'd', '1'
|
752
|
+
@d2, @d2_gem = util_gem 'd', '2'
|
753
|
+
|
754
|
+
util_reset_gems
|
755
|
+
end
|
674
756
|
|
757
|
+
def util_setup_wxyz
|
758
|
+
@x1_m, @x1_m_gem = util_spec 'x', '1' do |s|
|
759
|
+
s.platform = Gem::Platform.new %w[cpu my_platform 1]
|
760
|
+
end
|
761
|
+
|
762
|
+
@x1_o, @x1_o_gem = util_spec 'x', '1' do |s|
|
763
|
+
s.platform = Gem::Platform.new %w[cpu other_platform 1]
|
764
|
+
end
|
765
|
+
|
766
|
+
@w1, @w1_gem = util_spec 'w', '1', 'x' => nil
|
767
|
+
|
768
|
+
@y1, @y1_gem = util_spec 'y', '1'
|
769
|
+
@y1_1_p, @y1_1_p_gem = util_spec 'y', '1.1' do |s|
|
770
|
+
s.platform = Gem::Platform.new %w[cpu my_platform 1]
|
771
|
+
end
|
772
|
+
|
773
|
+
@z1, @z1_gem = util_spec 'z', '1', 'y' => nil
|
774
|
+
|
775
|
+
util_reset_gems
|
776
|
+
end
|
777
|
+
|
778
|
+
def util_reset_gems
|
779
|
+
@c1_pre ||= nil
|
780
|
+
@d1 ||= nil
|
781
|
+
@d2 ||= nil
|
782
|
+
@w1 ||= nil
|
783
|
+
@x1_m ||= nil
|
784
|
+
@x1_o ||= nil
|
785
|
+
@y1 ||= nil
|
786
|
+
@y1_1_p ||= nil
|
787
|
+
@z1 ||= nil
|
788
|
+
|
789
|
+
util_setup_spec_fetcher(*[@a1, @a1_pre, @b1, @c1_pre,
|
790
|
+
@d1, @d2, @x1_m, @x1_o, @w1, @y1,
|
791
|
+
@y1_1_p, @z1].compact)
|
792
|
+
|
793
|
+
util_clear_gems
|
794
|
+
end
|
795
|
+
end
|