rubygems-update 1.6.2 → 1.7.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.

Files changed (40) hide show
  1. data.tar.gz.sig +0 -0
  2. data/.autotest +0 -1
  3. data/History.txt +70 -4
  4. data/README.rdoc +3 -0
  5. data/Rakefile +76 -0
  6. data/lib/rubygems.rb +57 -27
  7. data/lib/rubygems/command.rb +6 -4
  8. data/lib/rubygems/commands/contents_command.rb +14 -11
  9. data/lib/rubygems/commands/fetch_command.rb +6 -3
  10. data/lib/rubygems/commands/outdated_command.rb +2 -1
  11. data/lib/rubygems/commands/pristine_command.rb +4 -3
  12. data/lib/rubygems/commands/unpack_command.rb +46 -4
  13. data/lib/rubygems/commands/update_command.rb +24 -10
  14. data/lib/rubygems/custom_require.rb +1 -2
  15. data/lib/rubygems/dependency_installer.rb +1 -1
  16. data/lib/rubygems/ext/rake_builder.rb +1 -1
  17. data/lib/rubygems/gem_runner.rb +1 -0
  18. data/lib/rubygems/mock_gem_ui.rb +2 -1
  19. data/lib/rubygems/package/tar_input.rb +1 -0
  20. data/lib/rubygems/remote_fetcher.rb +62 -39
  21. data/lib/rubygems/server.rb +1 -1
  22. data/lib/rubygems/source_index.rb +64 -43
  23. data/lib/rubygems/spec_fetcher.rb +5 -6
  24. data/lib/rubygems/specification.rb +375 -402
  25. data/lib/rubygems/test_case.rb +7 -8
  26. data/lib/rubygems/uninstaller.rb +2 -2
  27. data/lib/rubygems/user_interaction.rb +27 -31
  28. data/test/rubygems/test_gem.rb +2 -44
  29. data/test/rubygems/test_gem_commands_contents_command.rb +19 -30
  30. data/test/rubygems/test_gem_commands_unpack_command.rb +24 -0
  31. data/test/rubygems/test_gem_commands_update_command.rb +26 -1
  32. data/test/rubygems/test_gem_dependency_installer.rb +9 -5
  33. data/test/rubygems/test_gem_dependency_list.rb +2 -6
  34. data/test/rubygems/test_gem_gem_runner.rb +1 -4
  35. data/test/rubygems/test_gem_installer.rb +1 -2
  36. data/test/rubygems/test_gem_remote_fetcher.rb +131 -24
  37. data/test/rubygems/test_gem_source_index.rb +7 -192
  38. data/test/rubygems/test_gem_specification.rb +132 -103
  39. metadata +9 -9
  40. metadata.gz.sig +0 -0
@@ -40,11 +40,9 @@ end
40
40
  def setup
41
41
  super
42
42
 
43
- # TODO: there is no reason why the spec tests need to write to disk
44
- @a1 = quick_gem 'a', '1' do |s|
43
+ @a1 = quick_spec 'a', '1' do |s|
45
44
  s.executable = 'exec'
46
45
  s.extensions << 'ext/a/extconf.rb'
47
- s.has_rdoc = 'true'
48
46
  s.test_file = 'test/suite.rb'
49
47
  s.requirements << 'A working computer'
50
48
  s.rubyforge_project = 'example'
@@ -58,15 +56,10 @@ end
58
56
  s.files = %w[lib/code.rb]
59
57
  end
60
58
 
61
- @a2 = quick_gem 'a', '2' do |s|
59
+ @a2 = quick_spec 'a', '2' do |s|
62
60
  s.files = %w[lib/code.rb]
63
61
  end
64
62
 
65
- FileUtils.mkdir_p File.join(@tempdir, 'bin')
66
- File.open File.join(@tempdir, 'bin', 'exec'), 'w' do |fp|
67
- fp.puts "#!#{Gem.ruby}"
68
- end
69
-
70
63
  @current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
71
64
  end
72
65
 
@@ -77,7 +70,6 @@ end
77
70
  bindir
78
71
  cert_chain
79
72
  date
80
- default_executable
81
73
  dependencies
82
74
  description
83
75
  email
@@ -85,7 +77,6 @@ end
85
77
  extensions
86
78
  extra_rdoc_files
87
79
  files
88
- has_rdoc
89
80
  homepage
90
81
  licenses
91
82
  name
@@ -124,17 +115,25 @@ end
124
115
  end
125
116
 
126
117
  def test_self_load
127
- spec = File.join @gemhome, 'specifications', @a2.spec_name
128
- gs = Gem::Specification.load spec
118
+ full_path = File.join @gemhome, 'specifications', @a2.spec_name
119
+ path = File.join "specifications", @a2.spec_name
120
+ write_file path do |io|
121
+ io.write @a2.to_ruby_for_cache
122
+ end
123
+
124
+ spec = Gem::Specification.load full_path
129
125
 
130
- assert_equal @a2, gs
126
+ @a2.files.clear
127
+
128
+ assert_equal @a2, spec
131
129
  end
132
130
 
133
131
  def test_self_load_legacy_ruby
134
- spec = eval LEGACY_RUBY_SPEC
132
+ spec = Deprecate.skip_during do
133
+ eval LEGACY_RUBY_SPEC
134
+ end
135
135
  assert_equal 'keyedlist', spec.name
136
136
  assert_equal '0.4.0', spec.version.to_s
137
- assert_equal true, spec.has_rdoc?
138
137
  assert_equal Gem::Specification::TODAY, spec.date
139
138
  assert spec.required_ruby_version.satisfied_by?(Gem::Version.new('1'))
140
139
  assert_equal false, spec.has_unit_tests?
@@ -189,8 +188,6 @@ end
189
188
  assert_equal [], spec.requirements
190
189
  assert_equal [], spec.dependencies
191
190
  assert_equal 'bin', spec.bindir
192
- assert_equal true, spec.has_rdoc
193
- assert_equal true, spec.has_rdoc?
194
191
  assert_equal '>= 0', spec.required_ruby_version.to_s
195
192
  assert_equal '>= 0', spec.required_rubygems_version.to_s
196
193
  end
@@ -273,9 +270,6 @@ end
273
270
  assert_equal 'bin', spec.bindir
274
271
  assert_same spec.bindir, new_spec.bindir
275
272
 
276
- assert_equal true, spec.has_rdoc
277
- assert_same spec.has_rdoc, new_spec.has_rdoc
278
-
279
273
  assert_equal '>= 0', spec.required_ruby_version.to_s
280
274
  assert_same spec.required_ruby_version, new_spec.required_ruby_version
281
275
 
@@ -284,6 +278,23 @@ end
284
278
  new_spec.required_rubygems_version
285
279
  end
286
280
 
281
+ def test_initialize_copy_broken
282
+ spec = Gem::Specification.new do |s|
283
+ s.name = 'a'
284
+ s.version = '1'
285
+ end
286
+
287
+ spec.instance_variable_set :@licenses, nil
288
+ spec.loaded_from = '/path/to/file'
289
+
290
+ e = assert_raises Gem::FormatException do
291
+ spec.dup
292
+ end
293
+
294
+ assert_equal 'a-1 has an invalid value for @licenses', e.message
295
+ assert_equal '/path/to/file', e.file_path
296
+ end
297
+
287
298
  def test__dump
288
299
  @a2.platform = Gem::Platform.local
289
300
  @a2.instance_variable_set :@original_platform, 'old_platform'
@@ -332,37 +343,33 @@ end
332
343
 
333
344
  def test_date_equals_date
334
345
  @a1.date = Date.new(2003, 9, 17)
335
- assert_equal Time.local(2003, 9, 17, 0,0,0), @a1.date
346
+ assert_equal Time.utc(2003, 9, 17, 0,0,0), @a1.date
336
347
  end
337
348
 
338
349
  def test_date_equals_string
339
350
  @a1.date = '2003-09-17'
340
- assert_equal Time.local(2003, 9, 17, 0,0,0), @a1.date
351
+ assert_equal Time.utc(2003, 9, 17, 0,0,0), @a1.date
352
+ end
353
+
354
+ def test_date_equals_string_bad
355
+ assert_raises Gem::InvalidSpecificationException do
356
+ @a1.date = '9/11/2003'
357
+ end
341
358
  end
342
359
 
343
360
  def test_date_equals_time
344
361
  @a1.date = Time.local(2003, 9, 17, 0,0,0)
345
- assert_equal Time.local(2003, 9, 17, 0,0,0), @a1.date
362
+ assert_equal Time.utc(2003, 9, 17, 0,0,0), @a1.date
346
363
  end
347
364
 
348
365
  def test_date_equals_time_local
349
- # HACK PDT
350
- @a1.date = Time.local(2003, 9, 17, 19,50,0)
351
- assert_equal Time.local(2003, 9, 17, 0,0,0), @a1.date
366
+ @a1.date = Time.local(2003, 9, 17, 19,50,0) # may not pass in utc >= +4
367
+ assert_equal Time.utc(2003, 9, 17, 0,0,0), @a1.date
352
368
  end
353
369
 
354
370
  def test_date_equals_time_utc
355
- # HACK PDT
356
- @a1.date = Time.local(2003, 9, 17, 19,50,0)
357
- assert_equal Time.local(2003, 9, 17, 0,0,0), @a1.date
358
- end
359
-
360
- def test_default_executable
361
- assert_equal 'exec', @a1.default_executable
362
-
363
- @a1.default_executable = nil
364
- @a1.instance_variable_set :@executables, nil
365
- assert_equal nil, @a1.default_executable
371
+ @a1.date = Time.utc(2003, 9, 17, 19,50,0)
372
+ assert_equal Time.utc(2003, 9, 17, 0,0,0), @a1.date
366
373
  end
367
374
 
368
375
  def test_dependencies
@@ -416,7 +423,6 @@ end
416
423
  s.homepage = %q{http://www.spice-of-life.net/download/cgikit/}
417
424
  s.autorequire = %q{cgikit}
418
425
  s.bindir = nil
419
- s.has_rdoc = true
420
426
  s.required_ruby_version = nil
421
427
  s.platform = nil
422
428
  s.files = ["lib/cgikit", "lib/cgikit.rb", "lib/cgikit/components", "..."]
@@ -425,14 +431,6 @@ end
425
431
  assert_equal cgikit, cgikit
426
432
  end
427
433
 
428
- def test_equals2_default_executable
429
- spec = @a1.dup
430
- spec.default_executable = 'xx'
431
-
432
- refute_equal @a1, spec
433
- refute_equal spec, @a1
434
- end
435
-
436
434
  def test_equals2_extensions
437
435
  spec = @a1.dup
438
436
  spec.extensions = 'xx'
@@ -536,9 +534,26 @@ end
536
534
  assert_kind_of Integer, @a1.hash
537
535
  end
538
536
 
537
+ def test_for_cache
538
+ @a2.add_runtime_dependency 'b', '1'
539
+ @a2.dependencies.first.instance_variable_set :@type, nil
540
+ @a2.required_rubygems_version = Gem::Requirement.new '> 0'
541
+ @a2.test_files = %w[test/test_b.rb]
542
+
543
+ refute_empty @a2.files
544
+ refute_empty @a2.test_files
545
+
546
+ spec = @a2.for_cache
547
+
548
+ assert_empty spec.files
549
+ assert_empty spec.test_files
550
+
551
+ refute_empty @a2.files
552
+ refute_empty @a2.test_files
553
+ end
554
+
539
555
  def test_full_gem_path
540
- assert_equal File.join(@gemhome, 'gems', @a1.full_name),
541
- @a1.full_gem_path
556
+ assert_equal File.join(@gemhome, 'gems', @a1.full_name), @a1.full_gem_path
542
557
 
543
558
  @a1.original_platform = 'mswin32'
544
559
 
@@ -583,21 +598,6 @@ end
583
598
  end
584
599
  end
585
600
 
586
- def test_has_rdoc_eh
587
- assert @a1.has_rdoc?
588
- end
589
-
590
- def test_has_rdoc_equals
591
-
592
- use_ui @ui do
593
- @a1.has_rdoc = false
594
- end
595
-
596
- assert_equal '', @ui.output
597
-
598
- assert_equal true, @a1.has_rdoc
599
- end
600
-
601
601
  def test_hash
602
602
  assert_equal @a1.hash, @a1.hash
603
603
  assert_equal @a1.hash, @a1.dup.hash
@@ -864,7 +864,6 @@ Gem::Specification.new do |s|
864
864
  s.required_rubygems_version = Gem::Requirement.new(\">= 0\") if s.respond_to? :required_rubygems_version=
865
865
  s.authors = [\"A User\"]
866
866
  s.date = %q{#{Gem::Specification::TODAY.strftime "%Y-%m-%d"}}
867
- s.default_executable = %q{exec}
868
867
  s.description = %q{This is a test description}
869
868
  s.email = %q{example@example.com}
870
869
  s.executables = [\"exec\"]
@@ -907,7 +906,9 @@ end
907
906
  end
908
907
 
909
908
  def test_to_ruby_legacy
910
- gemspec1 = eval LEGACY_RUBY_SPEC
909
+ gemspec1 = Deprecate.skip_during do
910
+ eval LEGACY_RUBY_SPEC
911
+ end
911
912
  ruby_code = gemspec1.to_ruby
912
913
  gemspec2 = eval ruby_code
913
914
 
@@ -978,6 +979,11 @@ end
978
979
  end
979
980
  end
980
981
 
982
+ def x s; s.gsub(/xxx/, ''); end
983
+ def w; x "WARxxxNING"; end
984
+ def t; x "TOxxxDO"; end
985
+ def f; x "FxxxIXME"; end
986
+
981
987
  def test_validate_authors
982
988
  util_setup_validate
983
989
 
@@ -988,7 +994,7 @@ end
988
994
  @a1.validate
989
995
  end
990
996
 
991
- assert_equal "WARNING: no author specified\n", @ui.error, 'error'
997
+ assert_equal "#{w}: no author specified\n", @ui.error, 'error'
992
998
 
993
999
  @a1.authors = [Object.new]
994
1000
 
@@ -996,23 +1002,23 @@ end
996
1002
  @a1.validate
997
1003
  end
998
1004
 
999
- assert_equal 'authors must be Array of Strings', e.message
1005
+ assert_equal "authors must be an Array of String instances", e.message
1000
1006
 
1001
- @a1.authors = ['FIXME (who is writing this software)']
1007
+ @a1.authors = ["#{f} (who is writing this software)"]
1002
1008
 
1003
1009
  e = assert_raises Gem::InvalidSpecificationException do
1004
1010
  @a1.validate
1005
1011
  end
1006
1012
 
1007
- assert_equal '"FIXME" or "TODO" is not an author', e.message
1013
+ assert_equal %{"#{f}" or "#{t}" is not an author}, e.message
1008
1014
 
1009
- @a1.authors = ['TODO (who is writing this software)']
1015
+ @a1.authors = ["#{t} (who is writing this software)"]
1010
1016
 
1011
1017
  e = assert_raises Gem::InvalidSpecificationException do
1012
1018
  @a1.validate
1013
1019
  end
1014
1020
 
1015
- assert_equal '"FIXME" or "TODO" is not an author', e.message
1021
+ assert_equal %{"#{f}" or "#{t}" is not an author}, e.message
1016
1022
  end
1017
1023
  end
1018
1024
 
@@ -1026,7 +1032,7 @@ end
1026
1032
  @a1.validate
1027
1033
  end
1028
1034
 
1029
- assert_equal "WARNING: deprecated autorequire specified\n",
1035
+ assert_equal "#{w}: deprecated autorequire specified\n",
1030
1036
  @ui.error, 'error'
1031
1037
  end
1032
1038
  end
@@ -1041,34 +1047,34 @@ end
1041
1047
  @a1.validate
1042
1048
  end
1043
1049
 
1044
- assert_equal "WARNING: no description specified\n", @ui.error, 'error'
1050
+ assert_equal "#{w}: no description specified\n", @ui.error, "error"
1045
1051
 
1046
1052
  @ui = Gem::MockGemUi.new
1047
- @a1.summary = 'this is my summary'
1053
+ @a1.summary = "this is my summary"
1048
1054
  @a1.description = @a1.summary
1049
1055
 
1050
1056
  use_ui @ui do
1051
1057
  @a1.validate
1052
1058
  end
1053
1059
 
1054
- assert_equal "WARNING: description and summary are identical\n",
1055
- @ui.error, 'error'
1060
+ assert_equal "#{w}: description and summary are identical\n",
1061
+ @ui.error, "error"
1056
1062
 
1057
- @a1.description = 'FIXME (describe your package)'
1063
+ @a1.description = "#{f} (describe your package)"
1058
1064
 
1059
1065
  e = assert_raises Gem::InvalidSpecificationException do
1060
1066
  @a1.validate
1061
1067
  end
1062
1068
 
1063
- assert_equal '"FIXME" or "TODO" is not a description', e.message
1069
+ assert_equal %{"#{f}" or "#{t}" is not a description}, e.message
1064
1070
 
1065
- @a1.description = 'TODO (describe your package)'
1071
+ @a1.description = "#{t} (describe your package)"
1066
1072
 
1067
1073
  e = assert_raises Gem::InvalidSpecificationException do
1068
1074
  @a1.validate
1069
1075
  end
1070
1076
 
1071
- assert_equal '"FIXME" or "TODO" is not a description', e.message
1077
+ assert_equal %{"#{f}" or "#{t}" is not a description}, e.message
1072
1078
  end
1073
1079
  end
1074
1080
 
@@ -1076,35 +1082,33 @@ end
1076
1082
  util_setup_validate
1077
1083
 
1078
1084
  Dir.chdir @tempdir do
1079
- @a1.email = ''
1085
+ @a1.email = ""
1080
1086
 
1081
1087
  use_ui @ui do
1082
1088
  @a1.validate
1083
1089
  end
1084
1090
 
1085
- assert_equal "WARNING: no email specified\n", @ui.error, 'error'
1091
+ assert_equal "#{w}: no email specified\n", @ui.error, "error"
1086
1092
 
1087
- @a1.email = 'FIXME (your e-mail)'
1093
+ @a1.email = "FIxxxXME (your e-mail)".sub(/xxx/, "")
1088
1094
 
1089
1095
  e = assert_raises Gem::InvalidSpecificationException do
1090
1096
  @a1.validate
1091
1097
  end
1092
1098
 
1093
- assert_equal '"FIXME" or "TODO" is not an email address', e.message
1099
+ assert_equal %{"#{f}" or "#{t}" is not an email}, e.message
1094
1100
 
1095
- @a1.email = 'TODO (your e-mail)'
1101
+ @a1.email = "#{t} (your e-mail)"
1096
1102
 
1097
1103
  e = assert_raises Gem::InvalidSpecificationException do
1098
1104
  @a1.validate
1099
1105
  end
1100
1106
 
1101
- assert_equal '"FIXME" or "TODO" is not an email address', e.message
1107
+ assert_equal %{"#{f}" or "#{t}" is not an email}, e.message
1102
1108
  end
1103
1109
  end
1104
1110
 
1105
1111
  def test_validate_empty
1106
- util_setup_validate
1107
-
1108
1112
  e = assert_raises Gem::InvalidSpecificationException do
1109
1113
  Gem::Specification.new.validate
1110
1114
  end
@@ -1128,7 +1132,7 @@ end
1128
1132
  assert_equal %w[exec], @a1.executables
1129
1133
 
1130
1134
  assert_equal '', @ui.output, 'output'
1131
- assert_equal "WARNING: bin/exec is missing #! line\n", @ui.error, 'error'
1135
+ assert_equal "#{w}: bin/exec is missing #! line\n", @ui.error, 'error'
1132
1136
  end
1133
1137
 
1134
1138
  def test_validate_empty_require_paths
@@ -1177,7 +1181,7 @@ end
1177
1181
  @a1.validate
1178
1182
  end
1179
1183
 
1180
- assert_equal "WARNING: no homepage specified\n", @ui.error, 'error'
1184
+ assert_equal "#{w}: no homepage specified\n", @ui.error, 'error'
1181
1185
 
1182
1186
  @ui = Gem::MockGemUi.new
1183
1187
 
@@ -1187,7 +1191,7 @@ end
1187
1191
  @a1.validate
1188
1192
  end
1189
1193
 
1190
- assert_equal "WARNING: no homepage specified\n", @ui.error, 'error'
1194
+ assert_equal "#{w}: no homepage specified\n", @ui.error, 'error'
1191
1195
 
1192
1196
  @a1.homepage = 'over at my cool site'
1193
1197
 
@@ -1210,6 +1214,26 @@ end
1210
1214
  assert_equal 'invalid value for attribute name: ":json"', e.message
1211
1215
  end
1212
1216
 
1217
+ def test_validate_non_nil
1218
+ util_setup_validate
1219
+
1220
+ Dir.chdir @tempdir do
1221
+ assert @a1.validate
1222
+
1223
+ Gem::Specification.non_nil_attributes.each do |name|
1224
+ next if name == :files # set by #normalize
1225
+ spec = @a1.dup
1226
+ spec.instance_variable_set "@#{name}", nil
1227
+
1228
+ e = assert_raises Gem::InvalidSpecificationException do
1229
+ spec.validate
1230
+ end
1231
+
1232
+ assert_match %r%^#{name}%, e.message
1233
+ end
1234
+ end
1235
+ end
1236
+
1213
1237
  def test_validate_platform_legacy
1214
1238
  util_setup_validate
1215
1239
 
@@ -1264,23 +1288,23 @@ end
1264
1288
  @a1.validate
1265
1289
  end
1266
1290
 
1267
- assert_equal "WARNING: no summary specified\n", @ui.error, 'error'
1291
+ assert_equal "#{w}: no summary specified\n", @ui.error, 'error'
1268
1292
 
1269
- @a1.summary = 'FIXME (describe your package)'
1293
+ @a1.summary = "#{f} (describe your package)"
1270
1294
 
1271
1295
  e = assert_raises Gem::InvalidSpecificationException do
1272
1296
  @a1.validate
1273
1297
  end
1274
1298
 
1275
- assert_equal '"FIXME" or "TODO" is not a summary', e.message
1299
+ assert_equal %{"#{f}" or "#{t}" is not a summary}, e.message
1276
1300
 
1277
- @a1.summary = 'TODO (describe your package)'
1301
+ @a1.summary = "#{t} (describe your package)"
1278
1302
 
1279
1303
  e = assert_raises Gem::InvalidSpecificationException do
1280
1304
  @a1.validate
1281
1305
  end
1282
1306
 
1283
- assert_equal '"FIXME" or "TODO" is not a summary', e.message
1307
+ assert_equal %{"#{f}" or "#{t}" is not a summary}, e.message
1284
1308
  end
1285
1309
  end
1286
1310
 
@@ -1316,13 +1340,18 @@ end
1316
1340
 
1317
1341
  def util_setup_validate
1318
1342
  Dir.chdir @tempdir do
1319
- FileUtils.mkdir_p File.join('ext', 'a')
1320
- FileUtils.mkdir_p 'lib'
1321
- FileUtils.mkdir_p 'test'
1343
+ FileUtils.mkdir_p File.join("ext", "a")
1344
+ FileUtils.mkdir_p "lib"
1345
+ FileUtils.mkdir_p "test"
1346
+ FileUtils.mkdir_p "bin"
1322
1347
 
1323
- FileUtils.touch File.join('ext', 'a', 'extconf.rb')
1324
- FileUtils.touch File.join('lib', 'code.rb')
1325
- FileUtils.touch File.join('test', 'suite.rb')
1348
+ FileUtils.touch File.join("ext", "a", "extconf.rb")
1349
+ FileUtils.touch File.join("lib", "code.rb")
1350
+ FileUtils.touch File.join("test", "suite.rb")
1351
+
1352
+ File.open "bin/exec", "w" do |fp|
1353
+ fp.puts "#!#{Gem.ruby}"
1354
+ end
1326
1355
  end
1327
1356
  end
1328
1357
  end