rubygems-update 1.5.3 → 1.6.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 +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
data/lib/rubygems/validator.rb
CHANGED
@@ -88,7 +88,7 @@ class Gem::Validator
|
|
88
88
|
next unless gems.include? gem_spec.name unless gems.empty?
|
89
89
|
|
90
90
|
install_dir = gem_spec.installation_path
|
91
|
-
gem_path =
|
91
|
+
gem_path = Gem.cache_gem(gem_spec.file_name, install_dir)
|
92
92
|
spec_path = File.join install_dir, "specifications", gem_spec.spec_name
|
93
93
|
gem_directory = gem_spec.full_gem_path
|
94
94
|
|
data/test/rubygems/test_gem.rb
CHANGED
@@ -20,6 +20,352 @@ class TestGem < Gem::TestCase
|
|
20
20
|
util_remove_interrupt_command
|
21
21
|
end
|
22
22
|
|
23
|
+
def assert_activate expected, *specs
|
24
|
+
specs.each do |spec|
|
25
|
+
case spec
|
26
|
+
when Array
|
27
|
+
Gem.activate(*spec)
|
28
|
+
when String
|
29
|
+
Gem.activate spec
|
30
|
+
else
|
31
|
+
Gem.activate spec.name
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
loaded = Gem.loaded_specs.values.map(&:full_name)
|
36
|
+
|
37
|
+
assert_equal expected.sort, loaded.sort if expected
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_self_activate
|
41
|
+
foo = util_spec 'foo', '1'
|
42
|
+
|
43
|
+
assert_activate %w[foo-1], foo
|
44
|
+
end
|
45
|
+
|
46
|
+
def loaded_spec_names
|
47
|
+
Gem.loaded_specs.values.map(&:full_name).sort
|
48
|
+
end
|
49
|
+
|
50
|
+
def unresolved_names
|
51
|
+
Gem.unresolved_deps.values.map(&:to_s).sort
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_self_activate_via_require
|
55
|
+
new_spec "a", "1", "b" => "= 1"
|
56
|
+
new_spec "b", "1", nil, "lib/b/c.rb"
|
57
|
+
new_spec "b", "2", nil, "lib/b/c.rb"
|
58
|
+
|
59
|
+
Gem.activate "a", "= 1"
|
60
|
+
require "b/c"
|
61
|
+
|
62
|
+
assert_equal %w(a-1 b-1), loaded_spec_names
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_self_activate_deep_unambiguous
|
66
|
+
a1 = new_spec "a", "1", "b" => "= 1"
|
67
|
+
b1 = new_spec "b", "1", "c" => "= 1"
|
68
|
+
b2 = new_spec "b", "2", "c" => "= 2"
|
69
|
+
c1 = new_spec "c", "1"
|
70
|
+
c2 = new_spec "c", "2"
|
71
|
+
|
72
|
+
install_specs a1, b1, b2, c1, c2
|
73
|
+
|
74
|
+
Gem.activate "a", "= 1"
|
75
|
+
assert_equal %w(a-1 b-1 c-1), loaded_spec_names
|
76
|
+
end
|
77
|
+
|
78
|
+
def save_loaded_features
|
79
|
+
old_loaded_features = $LOADED_FEATURES.dup
|
80
|
+
yield
|
81
|
+
ensure
|
82
|
+
$LOADED_FEATURES.replace old_loaded_features
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_self_activate_ambiguous_direct
|
86
|
+
save_loaded_features do
|
87
|
+
a1 = new_spec "a", "1", "b" => "> 0"
|
88
|
+
b1 = new_spec("b", "1", { "c" => ">= 1" }, "lib/d.rb")
|
89
|
+
b2 = new_spec("b", "2", { "c" => ">= 2" }, "lib/d.rb")
|
90
|
+
c1 = new_spec "c", "1"
|
91
|
+
c2 = new_spec "c", "2"
|
92
|
+
|
93
|
+
install_specs a1, b1, b2, c1, c2
|
94
|
+
|
95
|
+
Gem.activate "a", "= 1"
|
96
|
+
assert_equal %w(a-1), loaded_spec_names
|
97
|
+
assert_equal ["b (> 0)"], unresolved_names
|
98
|
+
|
99
|
+
require "d"
|
100
|
+
|
101
|
+
assert_equal %w(a-1 b-2 c-2), loaded_spec_names
|
102
|
+
assert_equal [], unresolved_names
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def test_self_activate_ambiguous_indirect
|
107
|
+
save_loaded_features do
|
108
|
+
a1 = new_spec "a", "1", "b" => "> 0"
|
109
|
+
b1 = new_spec "b", "1", "c" => ">= 1"
|
110
|
+
b2 = new_spec "b", "2", "c" => ">= 2"
|
111
|
+
c1 = new_spec "c", "1", nil, "lib/d.rb"
|
112
|
+
c2 = new_spec "c", "2", nil, "lib/d.rb"
|
113
|
+
|
114
|
+
install_specs a1, b1, b2, c1, c2
|
115
|
+
|
116
|
+
Gem.activate "a", "= 1"
|
117
|
+
assert_equal %w(a-1), loaded_spec_names
|
118
|
+
assert_equal ["b (> 0)"], unresolved_names
|
119
|
+
|
120
|
+
require "d"
|
121
|
+
|
122
|
+
assert_equal %w(a-1 b-2 c-2), loaded_spec_names
|
123
|
+
assert_equal [], unresolved_names
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
def test_self_activate_ambiguous_unrelated
|
128
|
+
save_loaded_features do
|
129
|
+
a1 = new_spec "a", "1", "b" => "> 0"
|
130
|
+
b1 = new_spec "b", "1", "c" => ">= 1"
|
131
|
+
b2 = new_spec "b", "2", "c" => ">= 2"
|
132
|
+
c1 = new_spec "c", "1"
|
133
|
+
c2 = new_spec "c", "2"
|
134
|
+
d1 = new_spec "d", "1", nil, "lib/d.rb"
|
135
|
+
|
136
|
+
install_specs a1, b1, b2, c1, c2, d1
|
137
|
+
|
138
|
+
Gem.activate "a", "= 1"
|
139
|
+
assert_equal %w(a-1), loaded_spec_names
|
140
|
+
assert_equal ["b (> 0)"], unresolved_names
|
141
|
+
|
142
|
+
require "d"
|
143
|
+
|
144
|
+
assert_equal %w(a-1 d-1), loaded_spec_names
|
145
|
+
assert_equal ["b (> 0)"], unresolved_names
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
def test_self_activate_ambiguous_indirect_conflict
|
150
|
+
save_loaded_features do
|
151
|
+
a1 = new_spec "a", "1", "b" => "> 0"
|
152
|
+
a2 = new_spec "a", "2", "b" => "> 0"
|
153
|
+
b1 = new_spec "b", "1", "c" => ">= 1"
|
154
|
+
b2 = new_spec "b", "2", "c" => ">= 2"
|
155
|
+
c1 = new_spec "c", "1", nil, "lib/d.rb"
|
156
|
+
c2 = new_spec("c", "2", { "a" => "1" }, "lib/d.rb") # conflicts with a-2
|
157
|
+
|
158
|
+
install_specs a1, a2, b1, b2, c1, c2
|
159
|
+
|
160
|
+
Gem.activate "a", "= 2"
|
161
|
+
assert_equal %w(a-2), loaded_spec_names
|
162
|
+
assert_equal ["b (> 0)"], unresolved_names
|
163
|
+
|
164
|
+
require "d"
|
165
|
+
|
166
|
+
assert_equal %w(a-2 b-1 c-1), loaded_spec_names
|
167
|
+
assert_equal [], unresolved_names
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
def test_require_missing
|
172
|
+
save_loaded_features do
|
173
|
+
assert_raises ::LoadError do
|
174
|
+
require "q"
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
def test_self_activate_loaded
|
180
|
+
util_spec 'foo', '1'
|
181
|
+
|
182
|
+
assert Gem.activate 'foo'
|
183
|
+
refute Gem.activate 'foo'
|
184
|
+
end
|
185
|
+
|
186
|
+
##
|
187
|
+
# [A] depends on
|
188
|
+
# [B] >= 1.0 (satisfied by 2.0)
|
189
|
+
# [C] depends on nothing
|
190
|
+
|
191
|
+
def test_self_activate_unrelated
|
192
|
+
a = util_spec 'a', '1.0', 'b' => '>= 1.0'
|
193
|
+
util_spec 'b', '1.0'
|
194
|
+
c = util_spec 'c', '1.0'
|
195
|
+
|
196
|
+
assert_activate %w[b-1.0 c-1.0 a-1.0], a, c, "b"
|
197
|
+
end
|
198
|
+
|
199
|
+
##
|
200
|
+
# [A] depends on
|
201
|
+
# [B] >= 1.0 (satisfied by 2.0)
|
202
|
+
# [C] = 1.0 depends on
|
203
|
+
# [B] ~> 1.0
|
204
|
+
#
|
205
|
+
# and should resolve using b-1.0
|
206
|
+
|
207
|
+
def test_self_activate_over
|
208
|
+
util_spec 'a', '1.0', 'b' => '>= 1.0', 'c' => '= 1.0'
|
209
|
+
util_spec 'b', '1.0'
|
210
|
+
util_spec 'b', '1.1'
|
211
|
+
util_spec 'b', '2.0'
|
212
|
+
util_spec 'c', '1.0', 'b' => '~> 1.0'
|
213
|
+
|
214
|
+
Gem.activate "a"
|
215
|
+
|
216
|
+
assert_equal %w[a-1.0 c-1.0], loaded_spec_names
|
217
|
+
assert_equal ["b (>= 1.0, ~> 1.0)"], unresolved_names
|
218
|
+
end
|
219
|
+
|
220
|
+
##
|
221
|
+
# [A] depends on
|
222
|
+
# [B] ~> 1.0 (satisfied by 1.1)
|
223
|
+
# [C] = 1.0 depends on
|
224
|
+
# [B] = 1.0
|
225
|
+
#
|
226
|
+
# and should resolve using b-1.0
|
227
|
+
#
|
228
|
+
# TODO: this is not under, but over... under would require depth
|
229
|
+
# first resolve through a dependency that is later pruned.
|
230
|
+
|
231
|
+
def test_self_activate_under
|
232
|
+
a, _ = util_spec 'a', '1.0', 'b' => '~> 1.0', 'c' => '= 1.0'
|
233
|
+
util_spec 'b', '1.0'
|
234
|
+
util_spec 'b', '1.1'
|
235
|
+
c, _ = util_spec 'c', '1.0', 'b' => '= 1.0'
|
236
|
+
|
237
|
+
assert_activate %w[b-1.0 c-1.0 a-1.0], a, c, "b"
|
238
|
+
end
|
239
|
+
|
240
|
+
##
|
241
|
+
# [A1] depends on
|
242
|
+
# [B] > 0 (satisfied by 2.0)
|
243
|
+
# [B1] depends on
|
244
|
+
# [C] > 0 (satisfied by 1.0)
|
245
|
+
# [B2] depends on nothing!
|
246
|
+
# [C1] depends on nothing
|
247
|
+
|
248
|
+
def test_self_activate_dropped
|
249
|
+
a1, = util_spec 'a', '1', 'b' => nil
|
250
|
+
util_spec 'b', '1', 'c' => nil
|
251
|
+
util_spec 'b', '2'
|
252
|
+
util_spec 'c', '1'
|
253
|
+
|
254
|
+
assert_activate %w[b-2 a-1], a1, "b"
|
255
|
+
end
|
256
|
+
|
257
|
+
##
|
258
|
+
# [A] depends on
|
259
|
+
# [B] >= 1.0 (satisfied by 1.1) depends on
|
260
|
+
# [Z]
|
261
|
+
# [C] >= 1.0 depends on
|
262
|
+
# [B] = 1.0
|
263
|
+
#
|
264
|
+
# and should backtrack to resolve using b-1.0, pruning Z from the
|
265
|
+
# resolve.
|
266
|
+
|
267
|
+
def test_self_activate_raggi_the_edgecase_generator
|
268
|
+
a, _ = util_spec 'a', '1.0', 'b' => '>= 1.0', 'c' => '>= 1.0'
|
269
|
+
util_spec 'b', '1.0'
|
270
|
+
util_spec 'b', '1.1', 'z' => '>= 1.0'
|
271
|
+
c, _ = util_spec 'c', '1.0', 'b' => '= 1.0'
|
272
|
+
|
273
|
+
assert_activate %w[b-1.0 c-1.0 a-1.0], a, c, "b"
|
274
|
+
end
|
275
|
+
|
276
|
+
def test_self_activate_conflict
|
277
|
+
util_spec 'b', '1.0'
|
278
|
+
util_spec 'b', '2.0'
|
279
|
+
|
280
|
+
gem "b", "= 1.0"
|
281
|
+
|
282
|
+
assert_raises Gem::LoadError do
|
283
|
+
gem "b", "= 2.0"
|
284
|
+
end
|
285
|
+
end
|
286
|
+
|
287
|
+
##
|
288
|
+
# [A] depends on
|
289
|
+
# [B] ~> 1.0 (satisfied by 1.0)
|
290
|
+
# [C] = 1.0 depends on
|
291
|
+
# [B] = 2.0
|
292
|
+
|
293
|
+
def test_self_activate_divergent
|
294
|
+
a, _ = util_spec 'a', '1.0', 'b' => '~> 1.0', 'c' => '= 1.0'
|
295
|
+
util_spec 'b', '1.0'
|
296
|
+
util_spec 'b', '2.0'
|
297
|
+
c, _ = util_spec 'c', '1.0', 'b' => '= 2.0'
|
298
|
+
|
299
|
+
e = assert_raises Gem::LoadError do
|
300
|
+
assert_activate nil, a, c, "b"
|
301
|
+
end
|
302
|
+
|
303
|
+
assert_match(/Unable to activate c-1.0,/, e.message)
|
304
|
+
assert_match(/because b-1.0 conflicts with b .= 2.0/, e.message)
|
305
|
+
end
|
306
|
+
|
307
|
+
##
|
308
|
+
# DOC
|
309
|
+
|
310
|
+
def test_self_activate_platform_alternate
|
311
|
+
@x1_m = util_spec 'x', '1' do |s|
|
312
|
+
s.platform = Gem::Platform.new %w[cpu my_platform 1]
|
313
|
+
end
|
314
|
+
|
315
|
+
@x1_o = util_spec 'x', '1' do |s|
|
316
|
+
s.platform = Gem::Platform.new %w[cpu other_platform 1]
|
317
|
+
end
|
318
|
+
|
319
|
+
@w1 = util_spec 'w', '1', 'x' => nil
|
320
|
+
|
321
|
+
util_set_arch 'cpu-my_platform1'
|
322
|
+
|
323
|
+
assert_activate %w[x-1-cpu-my_platform-1 w-1], @w1, @x1_m
|
324
|
+
end
|
325
|
+
|
326
|
+
##
|
327
|
+
# DOC
|
328
|
+
|
329
|
+
def test_self_activate_platform_bump
|
330
|
+
@y1 = util_spec 'y', '1'
|
331
|
+
|
332
|
+
@y1_1_p = util_spec 'y', '1.1' do |s|
|
333
|
+
s.platform = Gem::Platform.new %w[cpu my_platform 1]
|
334
|
+
end
|
335
|
+
|
336
|
+
@z1 = util_spec 'z', '1', 'y' => nil
|
337
|
+
|
338
|
+
assert_activate %w[y-1 z-1], @z1, @y1
|
339
|
+
end
|
340
|
+
|
341
|
+
##
|
342
|
+
# [C] depends on
|
343
|
+
# [A] = 1.a
|
344
|
+
# [B] = 1.0 depends on
|
345
|
+
# [A] >= 0 (satisfied by 1.a)
|
346
|
+
|
347
|
+
def test_self_activate_prerelease
|
348
|
+
@c1_pre = util_spec 'c', '1.a', "a" => "1.a", "b" => "1"
|
349
|
+
@a1_pre = util_spec 'a', '1.a'
|
350
|
+
@b1 = util_spec 'b', '1' do |s|
|
351
|
+
s.add_dependency 'a'
|
352
|
+
s.add_development_dependency 'aa'
|
353
|
+
end
|
354
|
+
|
355
|
+
assert_activate %w[a-1.a b-1 c-1.a], @c1_pre, @a1_pre, @b1
|
356
|
+
end
|
357
|
+
|
358
|
+
##
|
359
|
+
# DOC
|
360
|
+
|
361
|
+
def test_self_activate_old_required
|
362
|
+
e1, = util_spec 'e', '1', 'd' => '= 1'
|
363
|
+
@d1 = util_spec 'd', '1'
|
364
|
+
@d2 = util_spec 'd', '2'
|
365
|
+
|
366
|
+
assert_activate %w[d-1 e-1], e1, "d"
|
367
|
+
end
|
368
|
+
|
23
369
|
def test_self_all_load_paths
|
24
370
|
util_make_gems
|
25
371
|
|
@@ -65,7 +411,7 @@ class TestGem < Gem::TestCase
|
|
65
411
|
end
|
66
412
|
|
67
413
|
def test_self_bin_path_nonexistent_binfile
|
68
|
-
|
414
|
+
quick_spec 'a', '2' do |s|
|
69
415
|
s.executables = ['exec']
|
70
416
|
end
|
71
417
|
assert_raises(Gem::GemNotFoundException) do
|
@@ -74,7 +420,7 @@ class TestGem < Gem::TestCase
|
|
74
420
|
end
|
75
421
|
|
76
422
|
def test_self_bin_path_no_bin_file
|
77
|
-
|
423
|
+
quick_spec 'a', '1'
|
78
424
|
assert_raises(Gem::Exception) do
|
79
425
|
Gem.bin_path('a', nil, '1')
|
80
426
|
end
|
@@ -88,7 +434,7 @@ class TestGem < Gem::TestCase
|
|
88
434
|
|
89
435
|
def test_self_bin_path_bin_file_gone_in_latest
|
90
436
|
util_exec_gem
|
91
|
-
|
437
|
+
quick_spec 'a', '10' do |s|
|
92
438
|
s.executables = []
|
93
439
|
s.default_executable = nil
|
94
440
|
end
|
@@ -144,7 +490,7 @@ class TestGem < Gem::TestCase
|
|
144
490
|
fp.puts 'blah'
|
145
491
|
end
|
146
492
|
|
147
|
-
foo =
|
493
|
+
foo = quick_spec 'foo' do |s| s.files = %w[data/foo.txt] end
|
148
494
|
install_gem foo
|
149
495
|
end
|
150
496
|
|
@@ -206,7 +552,7 @@ class TestGem < Gem::TestCase
|
|
206
552
|
|
207
553
|
Gem.ensure_gem_subdirectories @gemhome
|
208
554
|
|
209
|
-
assert File.directory?(
|
555
|
+
assert File.directory?(Gem.cache_dir(@gemhome))
|
210
556
|
end
|
211
557
|
|
212
558
|
def test_self_ensure_gem_directories_missing_parents
|
@@ -218,7 +564,7 @@ class TestGem < Gem::TestCase
|
|
218
564
|
|
219
565
|
Gem.ensure_gem_subdirectories gemdir
|
220
566
|
|
221
|
-
assert File.directory?(
|
567
|
+
assert File.directory?(Gem.cache_dir(gemdir))
|
222
568
|
end
|
223
569
|
|
224
570
|
unless win_platform? then # only for FS that support write protection
|
@@ -232,7 +578,7 @@ class TestGem < Gem::TestCase
|
|
232
578
|
|
233
579
|
Gem.ensure_gem_subdirectories gemdir
|
234
580
|
|
235
|
-
refute File.exist?(
|
581
|
+
refute File.exist?(Gem.cache_dir(gemdir))
|
236
582
|
ensure
|
237
583
|
FileUtils.chmod 0600, gemdir
|
238
584
|
end
|
@@ -249,7 +595,7 @@ class TestGem < Gem::TestCase
|
|
249
595
|
|
250
596
|
Gem.ensure_gem_subdirectories gemdir
|
251
597
|
|
252
|
-
refute File.exist?(
|
598
|
+
refute File.exist?(Gem.cache_dir(gemdir))
|
253
599
|
ensure
|
254
600
|
FileUtils.chmod 0600, parent
|
255
601
|
end
|
@@ -270,8 +616,8 @@ class TestGem < Gem::TestCase
|
|
270
616
|
|
271
617
|
def test_self_find_files
|
272
618
|
discover_path = File.join 'lib', 'sff', 'discover.rb'
|
273
|
-
cwd = File.expand_path
|
274
|
-
$LOAD_PATH.unshift cwd
|
619
|
+
cwd = File.expand_path("test/rubygems", @@project_dir)
|
620
|
+
$LOAD_PATH.unshift cwd
|
275
621
|
|
276
622
|
foo1 = quick_gem 'sff', '1' do |s|
|
277
623
|
s.files << discover_path
|
@@ -295,7 +641,7 @@ class TestGem < Gem::TestCase
|
|
295
641
|
Gem.searcher = nil
|
296
642
|
|
297
643
|
expected = [
|
298
|
-
File.expand_path('
|
644
|
+
File.expand_path('test/rubygems/sff/discover.rb', @@project_dir),
|
299
645
|
File.join(foo2.full_gem_path, discover_path),
|
300
646
|
File.join(foo1.full_gem_path, discover_path),
|
301
647
|
]
|
@@ -321,7 +667,7 @@ class TestGem < Gem::TestCase
|
|
321
667
|
end
|
322
668
|
|
323
669
|
def test_self_loaded_specs
|
324
|
-
foo =
|
670
|
+
foo = quick_spec 'foo'
|
325
671
|
install_gem foo
|
326
672
|
Gem.source_index = nil
|
327
673
|
|
@@ -424,22 +770,12 @@ class TestGem < Gem::TestCase
|
|
424
770
|
end
|
425
771
|
|
426
772
|
def test_self_prefix
|
427
|
-
|
428
|
-
|
429
|
-
prefix = File.dirname File.dirname(file_name)
|
430
|
-
prefix = File.dirname prefix if File.basename(prefix) == 'test'
|
431
|
-
|
432
|
-
assert_equal prefix, Gem.prefix
|
773
|
+
assert_equal @@project_dir, Gem.prefix
|
433
774
|
end
|
434
775
|
|
435
776
|
def test_self_prefix_libdir
|
436
777
|
orig_libdir = Gem::ConfigMap[:libdir]
|
437
|
-
|
438
|
-
file_name = File.expand_path __FILE__
|
439
|
-
prefix = File.dirname File.dirname(file_name)
|
440
|
-
prefix = File.dirname prefix if File.basename(prefix) == 'test'
|
441
|
-
|
442
|
-
Gem::ConfigMap[:libdir] = prefix
|
778
|
+
Gem::ConfigMap[:libdir] = @@project_dir
|
443
779
|
|
444
780
|
assert_nil Gem.prefix
|
445
781
|
ensure
|
@@ -448,12 +784,7 @@ class TestGem < Gem::TestCase
|
|
448
784
|
|
449
785
|
def test_self_prefix_sitelibdir
|
450
786
|
orig_sitelibdir = Gem::ConfigMap[:sitelibdir]
|
451
|
-
|
452
|
-
file_name = File.expand_path __FILE__
|
453
|
-
prefix = File.dirname File.dirname(file_name)
|
454
|
-
prefix = File.dirname prefix if File.basename(prefix) == 'test'
|
455
|
-
|
456
|
-
Gem::ConfigMap[:sitelibdir] = prefix
|
787
|
+
Gem::ConfigMap[:sitelibdir] = @@project_dir
|
457
788
|
|
458
789
|
assert_nil Gem.prefix
|
459
790
|
ensure
|
@@ -617,6 +948,20 @@ class TestGem < Gem::TestCase
|
|
617
948
|
end
|
618
949
|
end
|
619
950
|
|
951
|
+
def test_self_cache_dir
|
952
|
+
util_ensure_gem_dirs
|
953
|
+
|
954
|
+
assert_equal File.join(@gemhome, 'cache'), Gem.cache_dir
|
955
|
+
assert_equal File.join(@userhome, '.gem', Gem.ruby_engine, Gem::ConfigMap[:ruby_version], 'cache'), Gem.cache_dir(Gem.user_dir)
|
956
|
+
end
|
957
|
+
|
958
|
+
def test_self_cache_gem
|
959
|
+
util_ensure_gem_dirs
|
960
|
+
|
961
|
+
assert_equal File.join(@gemhome, 'cache', 'test.gem'), Gem.cache_gem('test.gem')
|
962
|
+
assert_equal File.join(@userhome, '.gem', Gem.ruby_engine, Gem::ConfigMap[:ruby_version], 'cache', 'test.gem'), Gem.cache_gem('test.gem', Gem.user_dir)
|
963
|
+
end
|
964
|
+
|
620
965
|
if Gem.win_platform? then
|
621
966
|
def test_self_user_home_userprofile
|
622
967
|
skip 'Ruby 1.9 properly handles ~ path expansion' unless '1.9' > RUBY_VERSION
|
@@ -668,10 +1013,10 @@ class TestGem < Gem::TestCase
|
|
668
1013
|
Dir.chdir @tempdir do
|
669
1014
|
FileUtils.mkdir_p 'lib'
|
670
1015
|
File.open plugin_path, "w" do |fp|
|
671
|
-
fp.puts "TestGem
|
1016
|
+
fp.puts "class TestGem; TEST_SPEC_PLUGIN_LOAD = :loaded; end"
|
672
1017
|
end
|
673
1018
|
|
674
|
-
foo =
|
1019
|
+
foo = quick_spec 'foo', '1' do |s|
|
675
1020
|
s.files << plugin_path
|
676
1021
|
end
|
677
1022
|
|
@@ -679,6 +1024,7 @@ class TestGem < Gem::TestCase
|
|
679
1024
|
end
|
680
1025
|
|
681
1026
|
Gem.source_index = nil
|
1027
|
+
Gem.searcher = nil
|
682
1028
|
|
683
1029
|
gem 'foo'
|
684
1030
|
|
@@ -689,23 +1035,24 @@ class TestGem < Gem::TestCase
|
|
689
1035
|
|
690
1036
|
def test_load_env_plugins
|
691
1037
|
with_plugin('load') { Gem.load_env_plugins }
|
692
|
-
assert_equal :loaded, TEST_PLUGIN_LOAD
|
1038
|
+
assert_equal :loaded, TEST_PLUGIN_LOAD rescue nil
|
693
1039
|
|
694
1040
|
util_remove_interrupt_command
|
695
1041
|
|
696
1042
|
# Should attempt to cause a StandardError
|
697
1043
|
with_plugin('standarderror') { Gem.load_env_plugins }
|
698
|
-
assert_equal :loaded, TEST_PLUGIN_STANDARDERROR
|
1044
|
+
assert_equal :loaded, TEST_PLUGIN_STANDARDERROR rescue nil
|
699
1045
|
|
700
1046
|
util_remove_interrupt_command
|
701
1047
|
|
702
1048
|
# Should attempt to cause an Exception
|
703
1049
|
with_plugin('exception') { Gem.load_env_plugins }
|
704
|
-
assert_equal :loaded, TEST_PLUGIN_EXCEPTION
|
1050
|
+
assert_equal :loaded, TEST_PLUGIN_EXCEPTION rescue nil
|
705
1051
|
end
|
706
1052
|
|
707
1053
|
def with_plugin(path)
|
708
|
-
test_plugin_path = File.expand_path
|
1054
|
+
test_plugin_path = File.expand_path("test/rubygems/plugin/#{path}",
|
1055
|
+
@@project_dir)
|
709
1056
|
|
710
1057
|
# A single test plugin should get loaded once only, in order to preserve
|
711
1058
|
# sane test semantics.
|
@@ -727,7 +1074,7 @@ class TestGem < Gem::TestCase
|
|
727
1074
|
end
|
728
1075
|
|
729
1076
|
def util_exec_gem
|
730
|
-
spec, _ =
|
1077
|
+
spec, _ = quick_spec 'a', '4' do |s|
|
731
1078
|
s.default_executable = 'exec'
|
732
1079
|
s.executables = ['exec', 'abin']
|
733
1080
|
end
|
@@ -771,6 +1118,5 @@ class TestGem < Gem::TestCase
|
|
771
1118
|
Gem::Commands.send :remove_const, :InterruptCommand if
|
772
1119
|
Gem::Commands.const_defined? :InterruptCommand
|
773
1120
|
end
|
774
|
-
|
775
1121
|
end
|
776
1122
|
|