rubygems-update 1.7.2 → 1.8.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/.autotest +5 -1
- data/History.txt +101 -4
- data/LICENSE.txt +42 -37
- data/MIT.txt +20 -0
- data/Manifest.txt +5 -4
- data/Rakefile +6 -7
- data/lib/rubygems.rb +175 -278
- data/lib/rubygems/builder.rb +7 -6
- data/lib/rubygems/command_manager.rb +16 -2
- data/lib/rubygems/commands/build_command.rb +13 -11
- data/lib/rubygems/commands/cert_command.rb +1 -1
- data/lib/rubygems/commands/cleanup_command.rb +10 -19
- data/lib/rubygems/commands/contents_command.rb +5 -5
- data/lib/rubygems/commands/dependency_command.rb +17 -40
- data/lib/rubygems/commands/fetch_command.rb +1 -1
- data/lib/rubygems/commands/install_command.rb +2 -1
- data/lib/rubygems/commands/lock_command.rb +4 -4
- data/lib/rubygems/commands/outdated_command.rb +18 -6
- data/lib/rubygems/commands/pristine_command.rb +25 -15
- data/lib/rubygems/commands/query_command.rb +9 -6
- data/lib/rubygems/commands/setup_command.rb +1 -1
- data/lib/rubygems/commands/specification_command.rb +8 -23
- data/lib/rubygems/commands/stale_command.rb +2 -1
- data/lib/rubygems/commands/unpack_command.rb +7 -5
- data/lib/rubygems/commands/update_command.rb +2 -4
- data/lib/rubygems/commands/which_command.rb +5 -9
- data/lib/rubygems/config_file.rb +9 -7
- data/lib/rubygems/custom_require.rb +6 -4
- data/lib/rubygems/defaults.rb +30 -14
- data/lib/rubygems/dependency.rb +44 -1
- data/lib/rubygems/dependency_installer.rb +37 -41
- data/lib/rubygems/dependency_list.rb +20 -9
- data/lib/rubygems/deprecate.rb +3 -3
- data/lib/rubygems/doc_manager.rb +10 -11
- data/lib/rubygems/ext/rake_builder.rb +1 -1
- data/lib/rubygems/gem_path_searcher.rb +19 -4
- data/lib/rubygems/gem_runner.rb +1 -1
- data/lib/rubygems/indexer.rb +117 -123
- data/lib/rubygems/installer.rb +101 -94
- data/lib/rubygems/installer_test_case.rb +28 -30
- data/lib/rubygems/local_remote_options.rb +1 -1
- data/lib/rubygems/mock_gem_ui.rb +10 -3
- data/lib/rubygems/package.rb +0 -26
- data/lib/rubygems/package/tar_input.rb +5 -6
- data/lib/rubygems/package_task.rb +1 -1
- data/lib/rubygems/path_support.rb +72 -0
- data/lib/rubygems/platform.rb +12 -2
- data/lib/rubygems/remote_fetcher.rb +7 -6
- data/lib/rubygems/requirement.rb +3 -0
- data/lib/rubygems/security.rb +1 -1
- data/lib/rubygems/server.rb +67 -67
- data/lib/rubygems/source_index.rb +58 -29
- data/lib/rubygems/spec_fetcher.rb +5 -1
- data/lib/rubygems/specification.rb +1422 -877
- data/lib/rubygems/test_case.rb +114 -64
- data/lib/rubygems/test_utilities.rb +4 -3
- data/lib/rubygems/text.rb +1 -1
- data/lib/rubygems/uninstaller.rb +37 -44
- data/test/rubygems/test_gem.rb +131 -102
- data/test/rubygems/test_gem_builder.rb +18 -1
- data/test/rubygems/test_gem_command_manager.rb +2 -0
- data/test/rubygems/test_gem_commands_build_command.rb +31 -3
- data/test/rubygems/test_gem_commands_cleanup_command.rb +51 -0
- data/test/rubygems/test_gem_commands_dependency_command.rb +1 -10
- data/test/rubygems/test_gem_commands_fetch_command.rb +5 -4
- data/test/rubygems/test_gem_commands_help_command.rb +58 -0
- data/test/rubygems/test_gem_commands_install_command.rb +25 -24
- data/test/rubygems/test_gem_commands_list_command.rb +1 -4
- data/test/rubygems/test_gem_commands_outdated_command.rb +10 -9
- data/test/rubygems/test_gem_commands_pristine_command.rb +63 -22
- data/test/rubygems/test_gem_commands_push_command.rb +1 -1
- data/test/rubygems/test_gem_commands_query_command.rb +15 -82
- data/test/rubygems/test_gem_commands_sources_command.rb +8 -9
- data/test/rubygems/test_gem_commands_specification_command.rb +10 -6
- data/test/rubygems/test_gem_commands_stale_command.rb +4 -4
- data/test/rubygems/test_gem_commands_unpack_command.rb +20 -21
- data/test/rubygems/test_gem_commands_update_command.rb +19 -23
- data/test/rubygems/test_gem_commands_which_command.rb +7 -4
- data/test/rubygems/test_gem_dependency.rb +14 -8
- data/test/rubygems/test_gem_dependency_installer.rb +87 -33
- data/test/rubygems/test_gem_dependency_list.rb +7 -3
- data/test/rubygems/test_gem_doc_manager.rb +3 -3
- data/test/rubygems/test_gem_format.rb +1 -1
- data/test/rubygems/test_gem_gem_path_searcher.rb +45 -29
- data/test/rubygems/test_gem_indexer.rb +48 -47
- data/test/rubygems/test_gem_install_update_options.rb +6 -5
- data/test/rubygems/test_gem_installer.rb +61 -37
- data/test/rubygems/test_gem_path_support.rb +58 -0
- data/test/rubygems/test_gem_platform.rb +5 -5
- data/test/rubygems/test_gem_remote_fetcher.rb +18 -21
- data/test/rubygems/test_gem_server.rb +23 -15
- data/test/rubygems/test_gem_source_index.rb +165 -127
- data/test/rubygems/test_gem_spec_fetcher.rb +42 -49
- data/test/rubygems/test_gem_specification.rb +104 -74
- data/test/rubygems/test_gem_text.rb +15 -0
- data/test/rubygems/test_gem_uninstaller.rb +15 -26
- data/test/rubygems/test_kernel.rb +1 -2
- metadata +64 -14
- metadata.gz.sig +0 -0
- data/GPL.txt +0 -340
- data/pkgs/sources/lib/sources.rb +0 -3
- data/pkgs/sources/sources.gemspec +0 -14
- data/test/rubygems/functional.rb +0 -92
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'rubygems/test_case'
|
2
|
+
require 'rubygems'
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
class TestGemPathSupport < Gem::TestCase
|
6
|
+
def setup
|
7
|
+
super
|
8
|
+
|
9
|
+
ENV["GEM_HOME"] = @tempdir
|
10
|
+
ENV["GEM_PATH"] = [@tempdir, "something"].join(File::PATH_SEPARATOR)
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_initialize
|
14
|
+
ps = Gem::PathSupport.new
|
15
|
+
|
16
|
+
assert_equal ENV["GEM_HOME"], ps.home
|
17
|
+
|
18
|
+
expected = util_path
|
19
|
+
assert_equal expected, ps.path, "defaults to GEM_PATH"
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_initialize_home
|
23
|
+
ps = Gem::PathSupport.new "GEM_HOME" => "#{@tempdir}/foo"
|
24
|
+
|
25
|
+
assert_equal File.join(@tempdir, "foo"), ps.home
|
26
|
+
|
27
|
+
expected = util_path + [File.join(@tempdir, 'foo')]
|
28
|
+
assert_equal expected, ps.path
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_initialize_path
|
32
|
+
ps = Gem::PathSupport.new "GEM_PATH" => %W[#{@tempdir}/foo #{@tempdir}/bar]
|
33
|
+
|
34
|
+
assert_equal ENV["GEM_HOME"], ps.home
|
35
|
+
|
36
|
+
expected = [
|
37
|
+
File.join(@tempdir, 'foo'),
|
38
|
+
File.join(@tempdir, 'bar'),
|
39
|
+
ENV["GEM_HOME"],
|
40
|
+
]
|
41
|
+
|
42
|
+
assert_equal expected, ps.path
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_initialize_home_path
|
46
|
+
ps = Gem::PathSupport.new("GEM_HOME" => "#{@tempdir}/foo",
|
47
|
+
"GEM_PATH" => %W[#{@tempdir}/foo #{@tempdir}/bar])
|
48
|
+
|
49
|
+
assert_equal File.join(@tempdir, "foo"), ps.home
|
50
|
+
|
51
|
+
expected = [File.join(@tempdir, 'foo'), File.join(@tempdir, 'bar')]
|
52
|
+
assert_equal expected, ps.path
|
53
|
+
end
|
54
|
+
|
55
|
+
def util_path
|
56
|
+
ENV["GEM_PATH"].split(File::PATH_SEPARATOR)
|
57
|
+
end
|
58
|
+
end
|
@@ -138,7 +138,7 @@ class TestGemPlatform < Gem::TestCase
|
|
138
138
|
def test_empty
|
139
139
|
platform = Gem::Platform.new 'cpu-other_platform1'
|
140
140
|
assert_respond_to platform, :empty?
|
141
|
-
assert_equal false, platform.empty?
|
141
|
+
assert_equal false, Deprecate.skip_during { platform.empty? }
|
142
142
|
end
|
143
143
|
|
144
144
|
def test_to_s
|
@@ -229,7 +229,7 @@ class TestGemPlatform < Gem::TestCase
|
|
229
229
|
util_set_arch 'java'
|
230
230
|
assert_match 'java', Gem::Platform.local
|
231
231
|
assert_match 'jruby', Gem::Platform.local
|
232
|
-
|
232
|
+
|
233
233
|
util_set_arch 'universal-dotnet2.0'
|
234
234
|
assert_match 'universal-dotnet', Gem::Platform.local
|
235
235
|
assert_match 'universal-dotnet-2.0', Gem::Platform.local
|
@@ -237,13 +237,13 @@ class TestGemPlatform < Gem::TestCase
|
|
237
237
|
assert_match 'dotnet', Gem::Platform.local
|
238
238
|
assert_match 'dotnet-2.0', Gem::Platform.local
|
239
239
|
refute_match 'dotnet-4.0', Gem::Platform.local
|
240
|
-
|
240
|
+
|
241
241
|
util_set_arch 'universal-dotnet4.0'
|
242
242
|
assert_match 'universal-dotnet', Gem::Platform.local
|
243
|
-
refute_match 'universal-dotnet-2.0', Gem::Platform.local
|
243
|
+
refute_match 'universal-dotnet-2.0', Gem::Platform.local
|
244
244
|
assert_match 'universal-dotnet-4.0', Gem::Platform.local
|
245
245
|
assert_match 'dotnet', Gem::Platform.local
|
246
|
-
refute_match 'dotnet-2.0', Gem::Platform.local
|
246
|
+
refute_match 'dotnet-2.0', Gem::Platform.local
|
247
247
|
assert_match 'dotnet-4.0', Gem::Platform.local
|
248
248
|
|
249
249
|
util_set_arch 'powerpc-darwin'
|
@@ -93,7 +93,7 @@ gems:
|
|
93
93
|
|
94
94
|
# REFACTOR: copied from test_gem_dependency_installer.rb
|
95
95
|
@gems_dir = File.join @tempdir, 'gems'
|
96
|
-
@cache_dir =
|
96
|
+
@cache_dir = File.join @gemhome, "cache"
|
97
97
|
FileUtils.mkdir @gems_dir
|
98
98
|
|
99
99
|
# TODO: why does the remote fetcher need it written to disk?
|
@@ -203,7 +203,7 @@ gems:
|
|
203
203
|
|
204
204
|
fetcher = util_fuck_with_fetcher a1_data
|
205
205
|
|
206
|
-
a1_cache_gem =
|
206
|
+
a1_cache_gem = @a1.cache_file
|
207
207
|
assert_equal a1_cache_gem, fetcher.download(@a1, 'http://gems.example.com')
|
208
208
|
assert_equal("http://gems.example.com/gems/a-1.gem",
|
209
209
|
fetcher.instance_variable_get(:@test_arg).to_s)
|
@@ -215,8 +215,7 @@ gems:
|
|
215
215
|
|
216
216
|
inst = Gem::RemoteFetcher.fetcher
|
217
217
|
|
218
|
-
assert_equal
|
219
|
-
inst.download(@a1, 'http://gems.example.com')
|
218
|
+
assert_equal @a1.cache_file, inst.download(@a1, 'http://gems.example.com')
|
220
219
|
end
|
221
220
|
|
222
221
|
def test_download_local
|
@@ -228,8 +227,7 @@ gems:
|
|
228
227
|
inst = Gem::RemoteFetcher.fetcher
|
229
228
|
end
|
230
229
|
|
231
|
-
assert_equal
|
232
|
-
inst.download(@a1, local_path)
|
230
|
+
assert_equal @a1.cache_file, inst.download(@a1, local_path)
|
233
231
|
end
|
234
232
|
|
235
233
|
def test_download_local_space
|
@@ -243,21 +241,19 @@ gems:
|
|
243
241
|
inst = Gem::RemoteFetcher.fetcher
|
244
242
|
end
|
245
243
|
|
246
|
-
assert_equal
|
247
|
-
inst.download(@a1, local_path)
|
244
|
+
assert_equal @a1.cache_file, inst.download(@a1, local_path)
|
248
245
|
end
|
249
246
|
|
250
247
|
def test_download_install_dir
|
251
|
-
a1_data =
|
252
|
-
|
253
|
-
a1_data = fp.read
|
248
|
+
a1_data = File.open @a1_gem, 'rb' do |fp|
|
249
|
+
fp.read
|
254
250
|
end
|
255
251
|
|
256
252
|
fetcher = util_fuck_with_fetcher a1_data
|
257
253
|
|
258
254
|
install_dir = File.join @tempdir, 'more_gems'
|
259
255
|
|
260
|
-
a1_cache_gem =
|
256
|
+
a1_cache_gem = File.join install_dir, "cache", @a1.file_name
|
261
257
|
FileUtils.mkdir_p(File.dirname(a1_cache_gem))
|
262
258
|
actual = fetcher.download(@a1, 'http://gems.example.com', install_dir)
|
263
259
|
|
@@ -273,7 +269,7 @@ gems:
|
|
273
269
|
FileUtils.mv @a1_gem, @tempdir
|
274
270
|
local_path = File.join @tempdir, @a1.file_name
|
275
271
|
inst = nil
|
276
|
-
|
272
|
+
FileUtils.chmod 0555, @a1.cache_dir
|
277
273
|
|
278
274
|
Dir.chdir @tempdir do
|
279
275
|
inst = Gem::RemoteFetcher.fetcher
|
@@ -282,19 +278,20 @@ gems:
|
|
282
278
|
assert_equal File.join(@tempdir, @a1.file_name),
|
283
279
|
inst.download(@a1, local_path)
|
284
280
|
ensure
|
285
|
-
|
281
|
+
FileUtils.chmod 0755, @a1.cache_dir
|
286
282
|
end
|
287
283
|
|
288
284
|
def test_download_read_only
|
289
|
-
|
290
|
-
|
285
|
+
FileUtils.chmod 0555, @a1.cache_dir
|
286
|
+
FileUtils.chmod 0555, @gemhome
|
291
287
|
|
292
288
|
fetcher = util_fuck_with_fetcher File.read(@a1_gem)
|
293
289
|
fetcher.download(@a1, 'http://gems.example.com')
|
294
|
-
|
290
|
+
a1_cache_gem = File.join Gem.user_dir, "cache", @a1.file_name
|
291
|
+
assert File.exist? a1_cache_gem
|
295
292
|
ensure
|
296
|
-
|
297
|
-
|
293
|
+
FileUtils.chmod 0755, @gemhome
|
294
|
+
FileUtils.chmod 0755, @a1.cache_dir
|
298
295
|
end
|
299
296
|
end
|
300
297
|
|
@@ -313,7 +310,7 @@ gems:
|
|
313
310
|
|
314
311
|
fetcher = util_fuck_with_fetcher e1_data, :blow_chunks
|
315
312
|
|
316
|
-
e1_cache_gem =
|
313
|
+
e1_cache_gem = e1.cache_file
|
317
314
|
|
318
315
|
assert_equal e1_cache_gem, fetcher.download(e1, 'http://gems.example.com')
|
319
316
|
|
@@ -331,7 +328,7 @@ gems:
|
|
331
328
|
inst = Gem::RemoteFetcher.fetcher
|
332
329
|
end
|
333
330
|
|
334
|
-
cache_path =
|
331
|
+
cache_path = @a1.cache_file
|
335
332
|
FileUtils.mv local_path, cache_path
|
336
333
|
|
337
334
|
gem = Gem::Format.from_file_by_path cache_path
|
@@ -3,12 +3,10 @@ require 'rubygems/server'
|
|
3
3
|
require 'stringio'
|
4
4
|
|
5
5
|
class Gem::Server
|
6
|
-
attr_accessor :source_index
|
7
6
|
attr_reader :server
|
8
7
|
end
|
9
8
|
|
10
9
|
class TestGemServer < Gem::TestCase
|
11
|
-
|
12
10
|
def setup
|
13
11
|
super
|
14
12
|
|
@@ -35,52 +33,64 @@ class TestGemServer < Gem::TestCase
|
|
35
33
|
data = StringIO.new "GET /Marshal.#{Gem.marshal_version} HTTP/1.0\r\n\r\n"
|
36
34
|
@req.parse data
|
37
35
|
|
38
|
-
|
36
|
+
Deprecate.skip_during do
|
37
|
+
@server.Marshal @req, @res
|
38
|
+
end
|
39
39
|
|
40
40
|
assert_equal 200, @res.status, @res.body
|
41
41
|
assert_match %r| \d\d:\d\d:\d\d |, @res['date']
|
42
42
|
assert_equal 'application/octet-stream', @res['content-type']
|
43
43
|
|
44
|
-
|
45
|
-
|
44
|
+
Deprecate.skip_during do
|
45
|
+
si = Gem::SourceIndex.new
|
46
|
+
si.add_specs @a1, @a2
|
46
47
|
|
47
|
-
|
48
|
+
assert_equal si, Marshal.load(@res.body)
|
49
|
+
end
|
48
50
|
end
|
49
51
|
|
50
52
|
def test_Marshal_Z
|
51
53
|
data = StringIO.new "GET /Marshal.#{Gem.marshal_version}.Z HTTP/1.0\r\n\r\n"
|
52
54
|
@req.parse data
|
53
55
|
|
54
|
-
|
56
|
+
Deprecate.skip_during do
|
57
|
+
@server.Marshal @req, @res
|
58
|
+
end
|
55
59
|
|
56
60
|
assert_equal 200, @res.status, @res.body
|
57
61
|
assert_match %r| \d\d:\d\d:\d\d |, @res['date']
|
58
62
|
assert_equal 'application/x-deflate', @res['content-type']
|
59
63
|
|
60
|
-
|
61
|
-
|
64
|
+
Deprecate.skip_during do
|
65
|
+
si = Gem::SourceIndex.new
|
66
|
+
si.add_specs @a1, @a2
|
62
67
|
|
63
|
-
|
68
|
+
assert_equal si, Marshal.load(Gem.inflate(@res.body))
|
69
|
+
end
|
64
70
|
end
|
65
71
|
|
66
72
|
def test_latest_specs
|
67
73
|
data = StringIO.new "GET /latest_specs.#{Gem.marshal_version} HTTP/1.0\r\n\r\n"
|
68
74
|
@req.parse data
|
69
75
|
|
70
|
-
|
76
|
+
Deprecate.skip_during do
|
77
|
+
@server.latest_specs @req, @res
|
78
|
+
end
|
71
79
|
|
72
80
|
assert_equal 200, @res.status, @res.body
|
73
81
|
assert_match %r| \d\d:\d\d:\d\d |, @res['date']
|
74
82
|
assert_equal 'application/octet-stream', @res['content-type']
|
75
83
|
assert_equal [['a', Gem::Version.new(2), Gem::Platform::RUBY]],
|
76
|
-
|
84
|
+
Marshal.load(@res.body)
|
77
85
|
end
|
78
86
|
|
79
87
|
def test_latest_specs_gz
|
80
88
|
data = StringIO.new "GET /latest_specs.#{Gem.marshal_version}.gz HTTP/1.0\r\n\r\n"
|
81
89
|
@req.parse data
|
82
90
|
|
83
|
-
|
91
|
+
Deprecate.skip_during do
|
92
|
+
@server.latest_specs @req, @res
|
93
|
+
end
|
84
94
|
|
85
95
|
assert_equal 200, @res.status, @res.body
|
86
96
|
assert_match %r| \d\d:\d\d:\d\d |, @res['date']
|
@@ -221,6 +231,4 @@ class TestGemServer < Gem::TestCase
|
|
221
231
|
|
222
232
|
@server.instance_variable_set :@server, webrick
|
223
233
|
end
|
224
|
-
|
225
234
|
end
|
226
|
-
|
@@ -4,209 +4,247 @@ require 'rubygems/config_file'
|
|
4
4
|
require 'rubygems/deprecate'
|
5
5
|
|
6
6
|
class TestGemSourceIndex < Gem::TestCase
|
7
|
-
|
8
7
|
def setup
|
9
8
|
super
|
10
9
|
|
11
10
|
util_setup_fake_fetcher
|
11
|
+
|
12
|
+
@source_index = Deprecate.skip_during { Gem.source_index }
|
12
13
|
end
|
13
14
|
|
14
15
|
def test_find_name
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
Deprecate.skip_during do
|
17
|
+
assert_equal [@a1, @a2, @a3a], @source_index.find_name('a')
|
18
|
+
assert_equal [@a2], @source_index.find_name('a', '= 2')
|
19
|
+
assert_equal [], @source_index.find_name('bogusstring')
|
20
|
+
assert_equal [], @source_index.find_name('a', '= 3')
|
19
21
|
|
20
|
-
|
21
|
-
|
22
|
-
|
22
|
+
source_index = Gem::SourceIndex.new
|
23
|
+
source_index.add_spec @a1
|
24
|
+
source_index.add_spec @a2
|
23
25
|
|
24
|
-
|
26
|
+
assert_equal [@a1], source_index.find_name(@a1.name, '= 1')
|
25
27
|
|
26
|
-
|
27
|
-
|
28
|
+
r1 = Gem::Requirement.create '= 1'
|
29
|
+
assert_equal [@a1], source_index.find_name(@a1.name, r1)
|
30
|
+
end
|
28
31
|
end
|
29
32
|
|
30
33
|
def test_find_name_empty_cache
|
31
|
-
|
32
|
-
|
34
|
+
Deprecate.skip_during do
|
35
|
+
empty_source_index = Gem::SourceIndex.new
|
36
|
+
assert_equal [], empty_source_index.find_name("foo")
|
37
|
+
end
|
33
38
|
end
|
34
39
|
|
40
|
+
# HACK: deprecated impl is failing tests, but I may want to port it over
|
35
41
|
def test_latest_specs
|
36
|
-
|
37
|
-
|
38
|
-
|
42
|
+
Deprecate.skip_during do
|
43
|
+
p1_ruby = quick_spec 'p', '1'
|
44
|
+
p1_platform = quick_spec 'p', '1' do |spec|
|
45
|
+
spec.platform = Gem::Platform::CURRENT
|
46
|
+
end
|
47
|
+
|
48
|
+
a1_platform = quick_spec @a1.name, (@a1.version) do |s|
|
49
|
+
s.platform = Gem::Platform.new 'x86-my_platform1'
|
50
|
+
end
|
51
|
+
|
52
|
+
a2_platform = quick_spec @a2.name, (@a2.version) do |s|
|
53
|
+
s.platform = Gem::Platform.new 'x86-my_platform1'
|
54
|
+
end
|
55
|
+
|
56
|
+
a2_platform_other = quick_spec @a2.name, (@a2.version) do |s|
|
57
|
+
s.platform = Gem::Platform.new 'x86-other_platform1'
|
58
|
+
end
|
59
|
+
|
60
|
+
a3_platform_other = quick_spec @a2.name, (@a2.version.bump) do |s|
|
61
|
+
s.platform = Gem::Platform.new 'x86-other_platform1'
|
62
|
+
end
|
63
|
+
|
64
|
+
@source_index.add_spec p1_ruby
|
65
|
+
@source_index.add_spec p1_platform
|
66
|
+
@source_index.add_spec a1_platform
|
67
|
+
@source_index.add_spec a2_platform
|
68
|
+
@source_index.add_spec a2_platform_other
|
69
|
+
@source_index.add_spec a3_platform_other
|
70
|
+
|
71
|
+
expected = [
|
72
|
+
@a2.full_name,
|
73
|
+
a2_platform.full_name,
|
74
|
+
a3_platform_other.full_name,
|
75
|
+
@b2.full_name,
|
76
|
+
@c1_2.full_name,
|
77
|
+
@a_evil9.full_name,
|
78
|
+
p1_ruby.full_name,
|
79
|
+
p1_platform.full_name,
|
80
|
+
@pl1.full_name
|
81
|
+
].sort
|
82
|
+
|
83
|
+
latest_specs = @source_index.latest_specs.map { |s| s.full_name }.sort
|
84
|
+
|
85
|
+
assert_equal expected, latest_specs
|
39
86
|
end
|
40
|
-
|
41
|
-
a1_platform = quick_spec @a1.name, (@a1.version) do |s|
|
42
|
-
s.platform = Gem::Platform.new 'x86-my_platform1'
|
43
|
-
end
|
44
|
-
|
45
|
-
a2_platform = quick_spec @a2.name, (@a2.version) do |s|
|
46
|
-
s.platform = Gem::Platform.new 'x86-my_platform1'
|
47
|
-
end
|
48
|
-
|
49
|
-
a2_platform_other = quick_spec @a2.name, (@a2.version) do |s|
|
50
|
-
s.platform = Gem::Platform.new 'x86-other_platform1'
|
51
|
-
end
|
52
|
-
|
53
|
-
a3_platform_other = quick_spec @a2.name, (@a2.version.bump) do |s|
|
54
|
-
s.platform = Gem::Platform.new 'x86-other_platform1'
|
55
|
-
end
|
56
|
-
|
57
|
-
@source_index.add_spec p1_ruby
|
58
|
-
@source_index.add_spec p1_platform
|
59
|
-
@source_index.add_spec a1_platform
|
60
|
-
@source_index.add_spec a2_platform
|
61
|
-
@source_index.add_spec a2_platform_other
|
62
|
-
@source_index.add_spec a3_platform_other
|
63
|
-
|
64
|
-
expected = [
|
65
|
-
@a2.full_name,
|
66
|
-
a2_platform.full_name,
|
67
|
-
a3_platform_other.full_name,
|
68
|
-
@c1_2.full_name,
|
69
|
-
@a_evil9.full_name,
|
70
|
-
p1_ruby.full_name,
|
71
|
-
p1_platform.full_name,
|
72
|
-
].sort
|
73
|
-
|
74
|
-
latest_specs = @source_index.latest_specs.map { |s| s.full_name }.sort
|
75
|
-
|
76
|
-
assert_equal expected, latest_specs
|
77
87
|
end
|
78
88
|
|
79
89
|
def test_load_gems_in
|
80
|
-
|
81
|
-
|
90
|
+
Deprecate.skip_during do
|
91
|
+
spec_dir1 = File.join @gemhome, 'specifications'
|
92
|
+
spec_dir2 = File.join @tempdir, 'gemhome2', 'specifications'
|
82
93
|
|
83
|
-
|
94
|
+
FileUtils.rm_r spec_dir1
|
84
95
|
|
85
|
-
|
86
|
-
|
96
|
+
FileUtils.mkdir_p spec_dir1
|
97
|
+
FileUtils.mkdir_p spec_dir2
|
87
98
|
|
88
|
-
|
89
|
-
|
99
|
+
a1 = quick_spec 'a', '1' do |spec| spec.author = 'author 1' end
|
100
|
+
a2 = quick_spec 'a', '1' do |spec| spec.author = 'author 2' end
|
90
101
|
|
91
|
-
|
92
|
-
|
93
|
-
end
|
102
|
+
path1 = File.join(spec_dir1, a1.spec_name)
|
103
|
+
path2 = File.join(spec_dir2, a2.spec_name)
|
94
104
|
|
95
|
-
|
96
|
-
|
97
|
-
|
105
|
+
File.open path1, 'w' do |fp|
|
106
|
+
fp.write a1.to_ruby
|
107
|
+
end
|
98
108
|
|
99
|
-
|
109
|
+
File.open path2, 'w' do |fp|
|
110
|
+
fp.write a2.to_ruby
|
111
|
+
end
|
100
112
|
|
101
|
-
|
113
|
+
@source_index.load_gems_in File.dirname(path1), File.dirname(path2)
|
114
|
+
|
115
|
+
assert_equal a1.author, @source_index.specification(a1.full_name).author
|
116
|
+
end
|
102
117
|
end
|
103
118
|
|
119
|
+
# REFACTOR: move to test_gem_commands_outdated_command.rb
|
104
120
|
def test_outdated
|
105
|
-
|
121
|
+
Deprecate.skip_during do
|
122
|
+
util_setup_spec_fetcher
|
106
123
|
|
107
|
-
|
124
|
+
assert_equal [], @source_index.outdated
|
108
125
|
|
109
|
-
|
110
|
-
|
126
|
+
updated = quick_spec @a2.name, (@a2.version.bump)
|
127
|
+
util_setup_spec_fetcher updated
|
111
128
|
|
112
|
-
|
129
|
+
assert_equal [updated.name], @source_index.outdated
|
113
130
|
|
114
|
-
|
115
|
-
|
116
|
-
|
131
|
+
updated_platform = quick_spec @a2.name, (updated.version.bump) do |s|
|
132
|
+
s.platform = Gem::Platform.new 'x86-other_platform1'
|
133
|
+
end
|
117
134
|
|
118
|
-
|
135
|
+
util_setup_spec_fetcher updated, updated_platform
|
119
136
|
|
120
|
-
|
137
|
+
assert_equal [updated_platform.name], @source_index.outdated
|
138
|
+
end
|
121
139
|
end
|
122
140
|
|
123
141
|
def test_prerelease_specs_kept_in_right_place
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
142
|
+
Deprecate.skip_during do
|
143
|
+
gem_a1_alpha = quick_spec 'abba', '1.a'
|
144
|
+
@source_index.add_spec gem_a1_alpha
|
145
|
+
|
146
|
+
refute_includes @source_index.latest_specs, gem_a1_alpha
|
147
|
+
assert_includes @source_index.latest_specs(true), gem_a1_alpha
|
148
|
+
assert_empty @source_index.find_name gem_a1_alpha.full_name
|
149
|
+
assert_includes @source_index.prerelease_specs, gem_a1_alpha
|
150
|
+
end
|
131
151
|
end
|
132
152
|
|
133
153
|
def test_refresh_bang
|
134
|
-
|
154
|
+
Deprecate.skip_during do
|
155
|
+
a1_spec = File.join @gemhome, "specifications", @a1.spec_name
|
135
156
|
|
136
|
-
|
157
|
+
FileUtils.mv a1_spec, @tempdir
|
137
158
|
|
138
|
-
|
159
|
+
Gem::Specification.reset
|
160
|
+
Gem.send :class_variable_set, :@@source_index, nil
|
161
|
+
source_index = Gem.source_index
|
139
162
|
|
140
|
-
|
163
|
+
refute_includes source_index.gems.keys.sort, @a1.full_name
|
141
164
|
|
142
|
-
|
165
|
+
FileUtils.mv File.join(@tempdir, @a1.spec_name), a1_spec
|
143
166
|
|
144
|
-
|
167
|
+
source_index.refresh!
|
145
168
|
|
146
|
-
|
169
|
+
assert source_index.gems.include?(@a1.full_name)
|
170
|
+
end
|
147
171
|
end
|
148
172
|
|
149
173
|
def test_remove_spec
|
150
|
-
|
174
|
+
Deprecate.skip_during do
|
175
|
+
si = Gem.source_index
|
151
176
|
|
152
|
-
|
153
|
-
@source_index.gems.values.map { |s| s.full_name }.sort
|
177
|
+
expected = si.gems.keys.sort
|
154
178
|
|
155
|
-
|
179
|
+
expected.delete "a-1"
|
180
|
+
@source_index.remove_spec 'a-1'
|
156
181
|
|
157
|
-
|
158
|
-
|
182
|
+
assert_equal expected, si.gems.keys.sort
|
183
|
+
|
184
|
+
expected.delete "a-3.a"
|
185
|
+
@source_index.remove_spec 'a-3.a'
|
186
|
+
|
187
|
+
assert_equal expected, si.gems.keys.sort
|
188
|
+
end
|
159
189
|
end
|
160
190
|
|
161
191
|
def test_search
|
162
|
-
|
163
|
-
|
164
|
-
|
192
|
+
Deprecate.skip_during do
|
193
|
+
requirement = Gem::Requirement.create '= 9'
|
194
|
+
with_version = Gem::Dependency.new(/^a/, requirement)
|
195
|
+
assert_equal [@a_evil9], @source_index.search(with_version)
|
165
196
|
|
166
|
-
|
167
|
-
|
197
|
+
with_default = Gem::Dependency.new(/^a/, Gem::Requirement.default)
|
198
|
+
assert_equal [@a1, @a2, @a3a, @a_evil9], @source_index.search(with_default)
|
168
199
|
|
169
|
-
|
170
|
-
|
200
|
+
c1_1_dep = Gem::Dependency.new 'c', '~> 1.1'
|
201
|
+
assert_equal [@c1_2], @source_index.search(c1_1_dep)
|
202
|
+
end
|
171
203
|
end
|
172
204
|
|
173
205
|
def test_search_platform
|
174
|
-
|
206
|
+
Deprecate.skip_during do
|
207
|
+
util_set_arch 'x86-my_platform1'
|
175
208
|
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
209
|
+
a1 = quick_spec 'a', '1'
|
210
|
+
a1_mine = quick_spec 'a', '1' do |s|
|
211
|
+
s.platform = Gem::Platform.new 'x86-my_platform1'
|
212
|
+
end
|
213
|
+
a1_other = quick_spec 'a', '1' do |s|
|
214
|
+
s.platform = Gem::Platform.new 'x86-other_platform1'
|
215
|
+
end
|
183
216
|
|
184
|
-
|
185
|
-
|
217
|
+
si = Gem::SourceIndex.new
|
218
|
+
si.add_specs a1, a1_mine, a1_other
|
186
219
|
|
187
|
-
|
220
|
+
dep = Gem::Dependency.new 'a', Gem::Requirement.new('1')
|
188
221
|
|
189
|
-
|
222
|
+
gems = si.search dep, true
|
190
223
|
|
191
|
-
|
224
|
+
assert_equal [a1, a1_mine], gems.sort
|
225
|
+
end
|
192
226
|
end
|
193
227
|
|
194
228
|
def test_signature
|
195
|
-
|
196
|
-
|
197
|
-
|
229
|
+
Deprecate.skip_during do
|
230
|
+
sig = @source_index.gem_signature('foo-1.2.3')
|
231
|
+
assert_equal 64, sig.length
|
232
|
+
assert_match(/^[a-f0-9]{64}$/, sig)
|
233
|
+
end
|
198
234
|
end
|
199
235
|
|
200
236
|
def test_specification
|
201
|
-
|
237
|
+
Deprecate.skip_during do
|
238
|
+
assert_equal @a1, @source_index.specification(@a1.full_name)
|
202
239
|
|
203
|
-
|
240
|
+
assert_nil @source_index.specification("foo-1.2.4")
|
241
|
+
end
|
204
242
|
end
|
205
243
|
|
206
244
|
def test_index_signature
|
207
|
-
|
208
|
-
|
245
|
+
Deprecate.skip_during do
|
246
|
+
sig = @source_index.index_signature
|
247
|
+
assert_match(/^[a-f0-9]{64}$/, sig)
|
248
|
+
end
|
209
249
|
end
|
210
|
-
|
211
250
|
end
|
212
|
-
|