rubygems-update 2.1.11 → 2.2.0.rc.1

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 (190) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/.autotest +37 -12
  5. data/History.txt +99 -2
  6. data/MIT.txt +1 -0
  7. data/Manifest.txt +59 -19
  8. data/Rakefile +4 -6
  9. data/lib/gauntlet_rubygems.rb +1 -1
  10. data/lib/rubygems.rb +102 -80
  11. data/lib/rubygems/available_set.rb +2 -2
  12. data/lib/rubygems/basic_specification.rb +97 -8
  13. data/lib/rubygems/commands/install_command.rb +58 -15
  14. data/lib/rubygems/commands/list_command.rb +1 -7
  15. data/lib/rubygems/commands/outdated_command.rb +1 -1
  16. data/lib/rubygems/commands/pristine_command.rb +14 -1
  17. data/lib/rubygems/commands/push_command.rb +9 -4
  18. data/lib/rubygems/commands/query_command.rb +33 -17
  19. data/lib/rubygems/commands/search_command.rb +0 -6
  20. data/lib/rubygems/commands/specification_command.rb +1 -1
  21. data/lib/rubygems/commands/unpack_command.rb +1 -1
  22. data/lib/rubygems/commands/update_command.rb +4 -1
  23. data/lib/rubygems/commands/which_command.rb +5 -8
  24. data/lib/rubygems/compatibility.rb +3 -0
  25. data/lib/rubygems/core_ext/kernel_gem.rb +6 -0
  26. data/lib/rubygems/defaults.rb +19 -0
  27. data/lib/rubygems/dependency_installer.rb +28 -9
  28. data/lib/rubygems/doctor.rb +17 -11
  29. data/lib/rubygems/errors.rb +16 -3
  30. data/lib/rubygems/exceptions.rb +52 -5
  31. data/lib/rubygems/ext.rb +1 -2
  32. data/lib/rubygems/ext/build_error.rb +6 -0
  33. data/lib/rubygems/ext/builder.rb +50 -17
  34. data/lib/rubygems/ext/cmake_builder.rb +1 -1
  35. data/lib/rubygems/ext/configure_builder.rb +1 -3
  36. data/lib/rubygems/ext/ext_conf_builder.rb +9 -3
  37. data/lib/rubygems/ext/rake_builder.rb +2 -5
  38. data/lib/rubygems/gemcutter_utilities.rb +8 -1
  39. data/lib/rubygems/installer.rb +14 -4
  40. data/lib/rubygems/installer_test_case.rb +0 -5
  41. data/lib/rubygems/package.rb +11 -2
  42. data/lib/rubygems/psych_additions.rb +1 -1
  43. data/lib/rubygems/rdoc.rb +1 -1
  44. data/lib/rubygems/remote_fetcher.rb +3 -3
  45. data/lib/rubygems/request.rb +16 -8
  46. data/lib/rubygems/request_set.rb +133 -42
  47. data/lib/rubygems/request_set/gem_dependency_api.rb +493 -11
  48. data/lib/rubygems/request_set/lockfile.rb +579 -0
  49. data/lib/rubygems/requirement.rb +58 -30
  50. data/lib/rubygems/resolver.rb +471 -0
  51. data/lib/rubygems/resolver/activation_request.rb +165 -0
  52. data/lib/rubygems/resolver/api_set.rb +110 -0
  53. data/lib/rubygems/resolver/api_specification.rb +79 -0
  54. data/lib/rubygems/resolver/best_set.rb +31 -0
  55. data/lib/rubygems/resolver/composed_set.rb +39 -0
  56. data/lib/rubygems/resolver/conflict.rb +122 -0
  57. data/lib/rubygems/{dependency_resolver → resolver}/current_set.rb +1 -4
  58. data/lib/rubygems/{dependency_resolver → resolver}/dependency_request.rb +37 -7
  59. data/lib/rubygems/resolver/git_set.rb +119 -0
  60. data/lib/rubygems/resolver/git_specification.rb +35 -0
  61. data/lib/rubygems/resolver/index_set.rb +74 -0
  62. data/lib/rubygems/resolver/index_specification.rb +69 -0
  63. data/lib/rubygems/resolver/installed_specification.rb +40 -0
  64. data/lib/rubygems/{dependency_resolver → resolver}/installer_set.rb +18 -17
  65. data/lib/rubygems/resolver/local_specification.rb +16 -0
  66. data/lib/rubygems/resolver/lock_set.rb +78 -0
  67. data/lib/rubygems/resolver/lock_specification.rb +58 -0
  68. data/lib/rubygems/resolver/requirement_list.rb +81 -0
  69. data/lib/rubygems/resolver/set.rb +27 -0
  70. data/lib/rubygems/resolver/spec_specification.rb +58 -0
  71. data/lib/rubygems/resolver/specification.rb +89 -0
  72. data/lib/rubygems/resolver/stats.rb +44 -0
  73. data/lib/rubygems/resolver/vendor_set.rb +83 -0
  74. data/lib/rubygems/resolver/vendor_specification.rb +24 -0
  75. data/lib/rubygems/security/trust_dir.rb +16 -2
  76. data/lib/rubygems/source.rb +71 -18
  77. data/lib/rubygems/source/git.rb +218 -0
  78. data/lib/rubygems/source/installed.rb +8 -1
  79. data/lib/rubygems/source/local.rb +14 -8
  80. data/lib/rubygems/source/lock.rb +48 -0
  81. data/lib/rubygems/source/specific_file.rb +14 -3
  82. data/lib/rubygems/source/vendor.rb +27 -0
  83. data/lib/rubygems/source_list.rb +74 -12
  84. data/lib/rubygems/spec_fetcher.rb +36 -4
  85. data/lib/rubygems/specification.rb +214 -65
  86. data/lib/rubygems/stub_specification.rb +57 -1
  87. data/lib/rubygems/syck_hack.rb +3 -3
  88. data/lib/rubygems/test_case.rb +226 -59
  89. data/lib/rubygems/test_utilities.rb +198 -0
  90. data/lib/rubygems/uninstaller.rb +22 -10
  91. data/lib/rubygems/uri_formatter.rb +20 -0
  92. data/lib/rubygems/user_interaction.rb +193 -71
  93. data/lib/rubygems/util.rb +121 -0
  94. data/lib/rubygems/util/list.rb +4 -0
  95. data/lib/rubygems/util/stringio.rb +34 -0
  96. data/lib/rubygems/validator.rb +6 -2
  97. data/lib/rubygems/version.rb +4 -8
  98. data/test/rubygems/test_bundled_ca.rb +1 -1
  99. data/test/rubygems/test_gem.rb +137 -29
  100. data/test/rubygems/test_gem_available_set.rb +19 -0
  101. data/test/rubygems/test_gem_commands_build_command.rb +1 -1
  102. data/test/rubygems/test_gem_commands_cert_command.rb +2 -2
  103. data/test/rubygems/test_gem_commands_cleanup_command.rb +13 -13
  104. data/test/rubygems/test_gem_commands_dependency_command.rb +24 -34
  105. data/test/rubygems/test_gem_commands_fetch_command.rb +43 -48
  106. data/test/rubygems/test_gem_commands_install_command.rb +244 -279
  107. data/test/rubygems/test_gem_commands_list_command.rb +3 -3
  108. data/test/rubygems/test_gem_commands_outdated_command.rb +7 -12
  109. data/test/rubygems/test_gem_commands_pristine_command.rb +73 -27
  110. data/test/rubygems/test_gem_commands_push_command.rb +76 -8
  111. data/test/rubygems/test_gem_commands_query_command.rb +239 -49
  112. data/test/rubygems/test_gem_commands_sources_command.rb +10 -43
  113. data/test/rubygems/test_gem_commands_specification_command.rb +24 -47
  114. data/test/rubygems/test_gem_commands_stale_command.rb +2 -2
  115. data/test/rubygems/test_gem_commands_uninstall_command.rb +3 -3
  116. data/test/rubygems/test_gem_commands_unpack_command.rb +16 -30
  117. data/test/rubygems/test_gem_commands_update_command.rb +149 -134
  118. data/test/rubygems/test_gem_commands_which_command.rb +4 -2
  119. data/test/rubygems/test_gem_dependency_installer.rb +68 -0
  120. data/test/rubygems/test_gem_dependency_list.rb +17 -17
  121. data/test/rubygems/test_gem_dependency_resolution_error.rb +28 -0
  122. data/test/rubygems/test_gem_doctor.rb +1 -1
  123. data/test/rubygems/test_gem_ext_builder.rb +178 -8
  124. data/test/rubygems/test_gem_ext_cmake_builder.rb +1 -7
  125. data/test/rubygems/test_gem_ext_configure_builder.rb +8 -10
  126. data/test/rubygems/test_gem_ext_ext_conf_builder.rb +18 -21
  127. data/test/rubygems/test_gem_ext_rake_builder.rb +1 -3
  128. data/test/rubygems/test_gem_impossible_dependencies_error.rb +10 -6
  129. data/test/rubygems/test_gem_indexer.rb +6 -6
  130. data/test/rubygems/test_gem_installer.rb +29 -10
  131. data/test/rubygems/test_gem_local_remote_options.rb +1 -1
  132. data/test/rubygems/test_gem_package.rb +18 -0
  133. data/test/rubygems/test_gem_rdoc.rb +1 -1
  134. data/test/rubygems/test_gem_remote_fetcher.rb +1 -1
  135. data/test/rubygems/test_gem_request.rb +37 -10
  136. data/test/rubygems/test_gem_request_set.rb +271 -9
  137. data/test/rubygems/test_gem_request_set_gem_dependency_api.rb +684 -0
  138. data/test/rubygems/test_gem_request_set_lockfile.rb +849 -0
  139. data/test/rubygems/test_gem_requirement.rb +21 -0
  140. data/test/rubygems/{test_gem_dependency_resolver.rb → test_gem_resolver.rb} +231 -70
  141. data/test/rubygems/test_gem_resolver_activation_request.rb +63 -0
  142. data/test/rubygems/test_gem_resolver_api_set.rb +167 -0
  143. data/test/rubygems/test_gem_resolver_api_specification.rb +104 -0
  144. data/test/rubygems/test_gem_resolver_best_set.rb +30 -0
  145. data/test/rubygems/test_gem_resolver_conflict.rb +75 -0
  146. data/test/rubygems/test_gem_resolver_dependency_request.rb +20 -0
  147. data/test/rubygems/test_gem_resolver_git_set.rb +148 -0
  148. data/test/rubygems/test_gem_resolver_git_specification.rb +100 -0
  149. data/test/rubygems/test_gem_resolver_index_set.rb +28 -0
  150. data/test/rubygems/test_gem_resolver_index_specification.rb +89 -0
  151. data/test/rubygems/test_gem_resolver_installed_specification.rb +49 -0
  152. data/test/rubygems/test_gem_resolver_installer_set.rb +22 -0
  153. data/test/rubygems/test_gem_resolver_local_specification.rb +45 -0
  154. data/test/rubygems/test_gem_resolver_lock_set.rb +57 -0
  155. data/test/rubygems/test_gem_resolver_lock_specification.rb +87 -0
  156. data/test/rubygems/test_gem_resolver_requirement_list.rb +20 -0
  157. data/test/rubygems/test_gem_resolver_specification.rb +32 -0
  158. data/test/rubygems/test_gem_resolver_vendor_set.rb +67 -0
  159. data/test/rubygems/test_gem_resolver_vendor_specification.rb +83 -0
  160. data/test/rubygems/test_gem_server.rb +4 -4
  161. data/test/rubygems/test_gem_source.rb +54 -64
  162. data/test/rubygems/test_gem_source_git.rb +231 -0
  163. data/test/rubygems/test_gem_source_list.rb +24 -0
  164. data/test/rubygems/test_gem_source_local.rb +1 -1
  165. data/test/rubygems/test_gem_source_lock.rb +114 -0
  166. data/test/rubygems/test_gem_source_vendor.rb +27 -0
  167. data/test/rubygems/test_gem_spec_fetcher.rb +116 -61
  168. data/test/rubygems/test_gem_specification.rb +526 -94
  169. data/test/rubygems/test_gem_stub_specification.rb +123 -10
  170. data/test/rubygems/test_gem_uninstaller.rb +28 -2
  171. data/test/rubygems/test_gem_util.rb +31 -0
  172. data/test/rubygems/test_gem_validator.rb +9 -0
  173. data/util/update_bundled_ca_certificates.rb +8 -1
  174. metadata +89 -29
  175. metadata.gz.sig +2 -4
  176. data/lib/rubygems/dependency_resolver.rb +0 -254
  177. data/lib/rubygems/dependency_resolver/activation_request.rb +0 -109
  178. data/lib/rubygems/dependency_resolver/api_set.rb +0 -65
  179. data/lib/rubygems/dependency_resolver/api_specification.rb +0 -39
  180. data/lib/rubygems/dependency_resolver/composed_set.rb +0 -18
  181. data/lib/rubygems/dependency_resolver/dependency_conflict.rb +0 -85
  182. data/lib/rubygems/dependency_resolver/index_set.rb +0 -64
  183. data/lib/rubygems/dependency_resolver/index_specification.rb +0 -60
  184. data/lib/rubygems/dependency_resolver/installed_specification.rb +0 -52
  185. data/test/rubygems/test_gem_dependency_resolver_api_specification.rb +0 -33
  186. data/test/rubygems/test_gem_dependency_resolver_dependency_conflict.rb +0 -36
  187. data/test/rubygems/test_gem_dependency_resolver_index_set.rb +0 -53
  188. data/test/rubygems/test_gem_dependency_resolver_index_specification.rb +0 -73
  189. data/test/rubygems/test_gem_dependency_resolver_installed_specification.rb +0 -19
  190. data/test/rubygems/test_gem_dependency_resolver_installer_set.rb +0 -28
@@ -44,7 +44,9 @@ class TestGemCommandsWhichCommand < Gem::TestCase
44
44
  @cmd.handle_options %w[foo_bar missinglib]
45
45
 
46
46
  use_ui @ui do
47
- @cmd.execute
47
+ assert_raises Gem::MockGemUi::TermError do
48
+ @cmd.execute
49
+ end
48
50
  end
49
51
 
50
52
  assert_equal "#{@foo_bar.full_gem_path}/lib/foo_bar.rb\n", @ui.output
@@ -68,7 +70,7 @@ class TestGemCommandsWhichCommand < Gem::TestCase
68
70
 
69
71
  def util_foo_bar
70
72
  files = %w[lib/foo_bar.rb lib/directory/baz.rb Rakefile]
71
- @foo_bar = quick_spec 'foo_bar' do |gem|
73
+ @foo_bar = util_spec 'foo_bar' do |gem|
72
74
  gem.files = files
73
75
  end
74
76
 
@@ -388,6 +388,41 @@ class TestGemDependencyInstaller < Gem::TestCase
388
388
  assert_equal %w[b-1], inst.installed_gems.map { |s| s.full_name }
389
389
  end
390
390
 
391
+ def test_install_dependency_existing_extension
392
+ extconf_rb = File.join @gemhome, 'gems', 'e-1', 'extconf.rb'
393
+ FileUtils.mkdir_p File.dirname extconf_rb
394
+
395
+ open extconf_rb, 'w' do |io|
396
+ io.write <<-EXTCONF_RB
397
+ require 'mkmf'
398
+ create_makefile 'e'
399
+ EXTCONF_RB
400
+ end
401
+
402
+ e1 = new_spec 'e', '1', nil, 'extconf.rb' do |s|
403
+ s.extensions << 'extconf.rb'
404
+ end
405
+ e1_gem = File.join @tempdir, 'gems', "#{e1.full_name}.gem"
406
+
407
+ _, f1_gem = util_gem 'f', '1', 'e' => nil
408
+
409
+ Gem::Installer.new(e1_gem).install
410
+ FileUtils.rm_r e1.extension_dir
411
+
412
+ FileUtils.mv e1_gem, @tempdir
413
+ FileUtils.mv f1_gem, @tempdir
414
+ inst = nil
415
+
416
+ Dir.chdir @tempdir do
417
+ inst = Gem::DependencyInstaller.new
418
+ inst.install 'f'
419
+ end
420
+
421
+ assert_equal %w[f-1], inst.installed_gems.map { |s| s.full_name }
422
+
423
+ assert_path_exists e1.extension_dir
424
+ end
425
+
391
426
  def test_install_dependency_old
392
427
  _, e1_gem = util_gem 'e', '1'
393
428
  _, f1_gem = util_gem 'f', '1', 'e' => nil
@@ -684,6 +719,9 @@ class TestGemDependencyInstaller < Gem::TestCase
684
719
  inst.install 'a'
685
720
  end
686
721
 
722
+ assert_equal %w[a-1], inst.installed_gems.map { |s| s.full_name },
723
+ 'sanity check'
724
+
687
725
  ENV['GEM_HOME'] = @gemhome
688
726
  ENV['GEM_PATH'] = [@gemhome, gemhome2].join File::PATH_SEPARATOR
689
727
  Gem.clear_paths
@@ -1164,6 +1202,36 @@ class TestGemDependencyInstaller < Gem::TestCase
1164
1202
  assert_resolve %w[d-1 e-1], e1, @d1, @d2
1165
1203
  end
1166
1204
 
1205
+ def test_resolve_dependencies
1206
+ util_setup_gems
1207
+
1208
+ FileUtils.mv @a1_gem, @tempdir
1209
+ FileUtils.mv @b1_gem, @tempdir
1210
+
1211
+ inst = Gem::DependencyInstaller.new
1212
+ request_set = inst.resolve_dependencies 'b', req('>= 0')
1213
+
1214
+ requests = request_set.sorted_requests.map { |req| req.full_name }
1215
+
1216
+ assert_equal %w[a-1 b-1], requests
1217
+ end
1218
+
1219
+ def test_resolve_dependencies_ignore_dependencies
1220
+ util_setup_gems
1221
+
1222
+ FileUtils.mv @a1_gem, @tempdir
1223
+ FileUtils.mv @b1_gem, @tempdir
1224
+
1225
+ inst = Gem::DependencyInstaller.new :ignore_dependencies => true
1226
+ request_set = inst.resolve_dependencies 'b', req('>= 0')
1227
+
1228
+ requests = request_set.sorted_requests.map { |req| req.full_name }
1229
+
1230
+ assert request_set.ignore_dependencies
1231
+
1232
+ assert_equal %w[b-1], requests
1233
+ end
1234
+
1167
1235
  def util_write_a1_bin
1168
1236
  write_file File.join('gems', 'a-1', 'bin', 'a_bin') do |fp|
1169
1237
  fp.puts "#!/usr/bin/ruby"
@@ -11,17 +11,17 @@ class TestGemDependencyList < Gem::TestCase
11
11
  @deplist = Gem::DependencyList.new
12
12
 
13
13
  # TODO: switch to new_spec
14
- @a1 = quick_spec 'a', '1'
15
- @a2 = quick_spec 'a', '2'
16
- @a3 = quick_spec 'a', '3'
14
+ @a1 = util_spec 'a', '1'
15
+ @a2 = util_spec 'a', '2'
16
+ @a3 = util_spec 'a', '3'
17
17
 
18
- @b1 = quick_spec 'b', '1' do |s| s.add_dependency 'a', '>= 1' end
19
- @b2 = quick_spec 'b', '2' do |s| s.add_dependency 'a', '>= 1' end
18
+ @b1 = util_spec 'b', '1' do |s| s.add_dependency 'a', '>= 1' end
19
+ @b2 = util_spec 'b', '2' do |s| s.add_dependency 'a', '>= 1' end
20
20
 
21
- @c1 = quick_spec 'c', '1' do |s| s.add_dependency 'b', '>= 1' end
22
- @c2 = quick_spec 'c', '2'
21
+ @c1 = util_spec 'c', '1' do |s| s.add_dependency 'b', '>= 1' end
22
+ @c2 = util_spec 'c', '2'
23
23
 
24
- @d1 = quick_spec 'd', '1' do |s| s.add_dependency 'c', '>= 1' end
24
+ @d1 = util_spec 'd', '1' do |s| s.add_dependency 'c', '>= 1' end
25
25
  end
26
26
 
27
27
  def test_active_count
@@ -57,9 +57,9 @@ class TestGemDependencyList < Gem::TestCase
57
57
  end
58
58
 
59
59
  def test_dependency_order_development
60
- e1 = quick_spec 'e', '1'
61
- f1 = quick_spec 'f', '1'
62
- g1 = quick_spec 'g', '1'
60
+ e1 = util_spec 'e', '1'
61
+ f1 = util_spec 'f', '1'
62
+ g1 = util_spec 'g', '1'
63
63
 
64
64
  @a1.add_dependency 'e'
65
65
  @a1.add_dependency 'f'
@@ -85,7 +85,7 @@ class TestGemDependencyList < Gem::TestCase
85
85
 
86
86
  def test_dependency_order_diamond
87
87
  util_diamond
88
- e1 = quick_spec 'e', '1'
88
+ e1 = util_spec 'e', '1'
89
89
  @deplist.add e1
90
90
  @a1.add_dependency 'e', '>= 1'
91
91
 
@@ -161,13 +161,13 @@ class TestGemDependencyList < Gem::TestCase
161
161
  end
162
162
 
163
163
  def test_ok_eh_mismatch
164
- a1 = quick_spec 'a', '1'
165
- a2 = quick_spec 'a', '2'
164
+ a1 = util_spec 'a', '1'
165
+ a2 = util_spec 'a', '2'
166
166
 
167
- b = quick_spec 'b', '1' do |s| s.add_dependency 'a', '= 1' end
168
- c = quick_spec 'c', '1' do |s| s.add_dependency 'a', '= 2' end
167
+ b = util_spec 'b', '1' do |s| s.add_dependency 'a', '= 1' end
168
+ c = util_spec 'c', '1' do |s| s.add_dependency 'a', '= 2' end
169
169
 
170
- d = quick_spec 'd', '1' do |s|
170
+ d = util_spec 'd', '1' do |s|
171
171
  s.add_dependency 'b'
172
172
  s.add_dependency 'c'
173
173
  end
@@ -0,0 +1,28 @@
1
+ require 'rubygems/test_case'
2
+
3
+ class TestGemDependencyResolutionError < Gem::TestCase
4
+
5
+ def setup
6
+ super
7
+
8
+ @DR = Gem::Resolver
9
+
10
+ @spec = util_spec 'a', 2
11
+
12
+ @a1_req = @DR::DependencyRequest.new dep('a', '= 1'), nil
13
+ @a2_req = @DR::DependencyRequest.new dep('a', '= 2'), nil
14
+
15
+ @activated = @DR::ActivationRequest.new @spec, @a2_req
16
+
17
+ @conflict = @DR::Conflict.new @a1_req, @activated
18
+
19
+ @error = Gem::DependencyResolutionError.new @conflict
20
+ end
21
+
22
+ def test_message
23
+ assert_match %r%^conflicting dependencies a \(= 1\) and a \(= 2\)$%,
24
+ @error.message
25
+ end
26
+
27
+ end
28
+
@@ -157,7 +157,7 @@ This directory does not appear to be a RubyGems repository, skipping
157
157
 
158
158
  refute doctor.gem_repository?, 'no gems installed'
159
159
 
160
- quick_spec 'a'
160
+ util_spec 'a'
161
161
 
162
162
  doctor = Gem::Doctor.new @gemhome
163
163
 
@@ -15,7 +15,7 @@ class TestGemExtBuilder < Gem::TestCase
15
15
 
16
16
  @orig_DESTDIR = ENV['DESTDIR']
17
17
 
18
- @spec = quick_spec 'a'
18
+ @spec = util_spec 'a'
19
19
 
20
20
  @builder = Gem::Ext::Builder.new @spec, ''
21
21
  end
@@ -36,6 +36,9 @@ class TestGemExtBuilder < Gem::TestCase
36
36
  all:
37
37
  \t@#{Gem.ruby} -e "puts %Q{all: \#{ENV['DESTDIR']}}"
38
38
 
39
+ clean:
40
+ \t@#{Gem.ruby} -e "puts %Q{clean: \#{ENV['DESTDIR']}}"
41
+
39
42
  install:
40
43
  \t@#{Gem.ruby} -e "puts %Q{install: \#{ENV['DESTDIR']}}"
41
44
  MAKEFILE
@@ -46,21 +49,138 @@ install:
46
49
 
47
50
  results = results.join "\n"
48
51
 
49
-
50
52
  if RUBY_VERSION > '2.0' then
53
+ assert_match %r%"DESTDIR=#{ENV['DESTDIR']}" clean$%, results
51
54
  assert_match %r%"DESTDIR=#{ENV['DESTDIR']}"$%, results
52
55
  assert_match %r%"DESTDIR=#{ENV['DESTDIR']}" install$%, results
53
56
  else
57
+ refute_match %r%"DESTDIR=#{ENV['DESTDIR']}" clean$%, results
54
58
  refute_match %r%"DESTDIR=#{ENV['DESTDIR']}"$%, results
55
59
  refute_match %r%"DESTDIR=#{ENV['DESTDIR']}" install$%, results
56
60
  end
57
61
 
58
62
  if /nmake/ !~ results
63
+ assert_match %r%^clean: destination$%, results
59
64
  assert_match %r%^all: destination$%, results
60
65
  assert_match %r%^install: destination$%, results
61
66
  end
62
67
  end
63
68
 
69
+ def test_class_make_no_clean
70
+ ENV['DESTDIR'] = 'destination'
71
+ results = []
72
+
73
+ Dir.chdir @ext do
74
+ open 'Makefile', 'w' do |io|
75
+ io.puts <<-MAKEFILE
76
+ all:
77
+ \t@#{Gem.ruby} -e "puts %Q{all: \#{ENV['DESTDIR']}}"
78
+
79
+ install:
80
+ \t@#{Gem.ruby} -e "puts %Q{install: \#{ENV['DESTDIR']}}"
81
+ MAKEFILE
82
+ end
83
+
84
+ Gem::Ext::Builder.make @dest_path, results
85
+ end
86
+
87
+ results = results.join "\n"
88
+
89
+ if RUBY_VERSION > '2.0' then
90
+ assert_match %r%"DESTDIR=#{ENV['DESTDIR']}" clean$%, results
91
+ assert_match %r%"DESTDIR=#{ENV['DESTDIR']}"$%, results
92
+ assert_match %r%"DESTDIR=#{ENV['DESTDIR']}" install$%, results
93
+ else
94
+ refute_match %r%"DESTDIR=#{ENV['DESTDIR']}" clean$%, results
95
+ refute_match %r%"DESTDIR=#{ENV['DESTDIR']}"$%, results
96
+ refute_match %r%"DESTDIR=#{ENV['DESTDIR']}" install$%, results
97
+ end
98
+ end
99
+
100
+ def test_build_extensions
101
+ @spec.extensions << 'ext/extconf.rb'
102
+
103
+ ext_dir = File.join @spec.gem_dir, 'ext'
104
+
105
+ FileUtils.mkdir_p ext_dir
106
+
107
+ extconf_rb = File.join ext_dir, 'extconf.rb'
108
+
109
+ open extconf_rb, 'w' do |f|
110
+ f.write <<-'RUBY'
111
+ require 'mkmf'
112
+
113
+ create_makefile 'a'
114
+ RUBY
115
+ end
116
+
117
+ ext_lib_dir = File.join ext_dir, 'lib'
118
+ FileUtils.mkdir ext_lib_dir
119
+ FileUtils.touch File.join ext_lib_dir, 'a.rb'
120
+ FileUtils.mkdir File.join ext_lib_dir, 'a'
121
+ FileUtils.touch File.join ext_lib_dir, 'a', 'b.rb'
122
+
123
+ use_ui @ui do
124
+ @builder.build_extensions
125
+ end
126
+
127
+ assert_path_exists @spec.extension_dir
128
+ assert_path_exists @spec.gem_build_complete_path
129
+ assert_path_exists File.join @spec.extension_dir, 'gem_make.out'
130
+ assert_path_exists File.join @spec.extension_dir, 'a.rb'
131
+ assert_path_exists File.join @spec.gem_dir, 'lib', 'a.rb'
132
+ assert_path_exists File.join @spec.gem_dir, 'lib', 'a', 'b.rb'
133
+ end
134
+
135
+ def test_build_extensions_install_ext_only
136
+ class << Gem
137
+ alias orig_install_extension_in_lib install_extension_in_lib
138
+
139
+ def Gem.install_extension_in_lib
140
+ false
141
+ end
142
+ end
143
+
144
+ @spec.extensions << 'ext/extconf.rb'
145
+
146
+ ext_dir = File.join @spec.gem_dir, 'ext'
147
+
148
+ FileUtils.mkdir_p ext_dir
149
+
150
+ extconf_rb = File.join ext_dir, 'extconf.rb'
151
+
152
+ open extconf_rb, 'w' do |f|
153
+ f.write <<-'RUBY'
154
+ require 'mkmf'
155
+
156
+ create_makefile 'a'
157
+ RUBY
158
+ end
159
+
160
+ ext_lib_dir = File.join ext_dir, 'lib'
161
+ FileUtils.mkdir ext_lib_dir
162
+ FileUtils.touch File.join ext_lib_dir, 'a.rb'
163
+ FileUtils.mkdir File.join ext_lib_dir, 'a'
164
+ FileUtils.touch File.join ext_lib_dir, 'a', 'b.rb'
165
+
166
+ use_ui @ui do
167
+ @builder.build_extensions
168
+ end
169
+
170
+ assert_path_exists @spec.extension_dir
171
+ assert_path_exists @spec.gem_build_complete_path
172
+ assert_path_exists File.join @spec.extension_dir, 'gem_make.out'
173
+ assert_path_exists File.join @spec.extension_dir, 'a.rb'
174
+ refute_path_exists File.join @spec.gem_dir, 'lib', 'a.rb'
175
+ refute_path_exists File.join @spec.gem_dir, 'lib', 'a', 'b.rb'
176
+ ensure
177
+ class << Gem
178
+ remove_method :install_extension_in_lib
179
+
180
+ alias install_extension_in_lib orig_install_extension_in_lib
181
+ end
182
+ end
183
+
64
184
  def test_build_extensions_none
65
185
  use_ui @ui do
66
186
  @builder.build_extensions
@@ -69,13 +189,30 @@ install:
69
189
  assert_equal '', @ui.output
70
190
  assert_equal '', @ui.error
71
191
 
72
- refute File.exist?('gem_make.out')
192
+ refute_path_exists File.join @spec.extension_dir, 'gem_make.out'
193
+ end
194
+
195
+ def test_build_extensions_rebuild_failure
196
+ FileUtils.mkdir_p @spec.extension_dir
197
+ FileUtils.touch @spec.gem_build_complete_path
198
+
199
+ @spec.extensions << nil
200
+
201
+ assert_raises Gem::Ext::BuildError do
202
+ use_ui @ui do
203
+ @builder.build_extensions
204
+ end
205
+ end
206
+
207
+ refute_path_exists @spec.gem_build_complete_path
73
208
  end
74
209
 
75
210
  def test_build_extensions_extconf_bad
76
211
  @spec.extensions << 'extconf.rb'
77
212
 
78
- e = assert_raises Gem::Installer::ExtensionBuildError do
213
+ FileUtils.mkdir_p @spec.gem_dir
214
+
215
+ e = assert_raises Gem::Ext::BuildError do
79
216
  use_ui @ui do
80
217
  @builder.build_extensions
81
218
  end
@@ -87,20 +224,28 @@ install:
87
224
  @ui.output
88
225
  assert_equal '', @ui.error
89
226
 
90
- gem_make_out = File.join @gemhome, 'gems', @spec.full_name, 'gem_make.out'
227
+ gem_make_out = File.join @spec.extension_dir, 'gem_make.out'
91
228
 
92
229
  assert_match %r%#{Regexp.escape Gem.ruby} extconf\.rb%,
93
230
  File.read(gem_make_out)
231
+ assert_match /: No such file/,
232
+ File.read(gem_make_out)
233
+
234
+ refute_path_exists @spec.gem_build_complete_path
235
+
236
+ skip "Gem.ruby is not the name of the binary being run in the end" \
237
+ unless File.read(gem_make_out).include? "#{Regexp.escape Gem.ruby}:"
238
+
94
239
  assert_match %r%#{Regexp.escape Gem.ruby}: No such file%,
95
240
  File.read(gem_make_out)
96
241
  end
97
242
 
98
243
  def test_build_extensions_unsupported
99
244
  FileUtils.mkdir_p @spec.gem_dir
100
- gem_make_out = File.join @spec.gem_dir, 'gem_make.out'
245
+ gem_make_out = File.join @spec.extension_dir, 'gem_make.out'
101
246
  @spec.extensions << nil
102
247
 
103
- e = assert_raises Gem::Installer::ExtensionBuildError do
248
+ e = assert_raises Gem::Ext::BuildError do
104
249
  use_ui @ui do
105
250
  @builder.build_extensions
106
251
  end
@@ -113,6 +258,8 @@ install:
113
258
  assert_equal '', @ui.error
114
259
 
115
260
  assert_equal "No builder for extension ''\n", File.read(gem_make_out)
261
+
262
+ refute_path_exists @spec.gem_build_complete_path
116
263
  ensure
117
264
  FileUtils.rm_f gem_make_out
118
265
  end
@@ -133,6 +280,7 @@ install:
133
280
  end
134
281
 
135
282
  File.open 'Makefile', 'w' do |f|
283
+ f.puts "clean:\n\techo cleaned"
136
284
  f.puts "default:\n\techo built"
137
285
  f.puts "install:\n\techo installed"
138
286
  end
@@ -146,7 +294,29 @@ install:
146
294
  path = File.join @spec.gem_dir, "extconf_args"
147
295
 
148
296
  assert_equal args.inspect, File.read(path).strip
149
- assert File.directory? File.join(@spec.gem_dir, 'lib')
297
+ assert_path_exists @spec.extension_dir
298
+ end
299
+
300
+ def test_initialize
301
+ build_info_dir = File.join @gemhome, 'build_info'
302
+
303
+ FileUtils.mkdir_p build_info_dir
304
+
305
+ build_info_file = File.join build_info_dir, "#{@spec.full_name}.info"
306
+
307
+ open build_info_file, 'w' do |io|
308
+ io.puts '--with-foo-dir=/nonexistent'
309
+ end
310
+
311
+ builder = Gem::Ext::Builder.new @spec
312
+
313
+ assert_equal %w[--with-foo-dir=/nonexistent], builder.build_args
314
+ end
315
+
316
+ def test_initialize_build_args
317
+ builder = Gem::Ext::Builder.new @spec, %w[--with-foo-dir=/nonexistent]
318
+
319
+ assert_equal %w[--with-foo-dir=/nonexistent], builder.build_args
150
320
  end
151
321
 
152
322
  end