slimgems 1.3.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (185) hide show
  1. data/ChangeLog +5811 -0
  2. data/History.txt +887 -0
  3. data/LICENSE.txt +51 -0
  4. data/README.md +87 -0
  5. data/Rakefile +120 -0
  6. data/bin/gem +25 -0
  7. data/bin/update_slimgems +35 -0
  8. data/bootstrap/Rakefile +4 -0
  9. data/hide_lib_for_update/note.txt +5 -0
  10. data/lib/gauntlet_rubygems.rb +50 -0
  11. data/lib/rbconfig/datadir.rb +20 -0
  12. data/lib/rubygems.rb +1220 -0
  13. data/lib/rubygems/builder.rb +102 -0
  14. data/lib/rubygems/command.rb +534 -0
  15. data/lib/rubygems/command_manager.rb +182 -0
  16. data/lib/rubygems/commands/build_command.rb +53 -0
  17. data/lib/rubygems/commands/cert_command.rb +86 -0
  18. data/lib/rubygems/commands/check_command.rb +80 -0
  19. data/lib/rubygems/commands/cleanup_command.rb +106 -0
  20. data/lib/rubygems/commands/contents_command.rb +98 -0
  21. data/lib/rubygems/commands/dependency_command.rb +195 -0
  22. data/lib/rubygems/commands/environment_command.rb +132 -0
  23. data/lib/rubygems/commands/fetch_command.rb +67 -0
  24. data/lib/rubygems/commands/generate_index_command.rb +133 -0
  25. data/lib/rubygems/commands/help_command.rb +172 -0
  26. data/lib/rubygems/commands/install_command.rb +178 -0
  27. data/lib/rubygems/commands/list_command.rb +35 -0
  28. data/lib/rubygems/commands/lock_command.rb +110 -0
  29. data/lib/rubygems/commands/mirror_command.rb +111 -0
  30. data/lib/rubygems/commands/outdated_command.rb +33 -0
  31. data/lib/rubygems/commands/owner_command.rb +75 -0
  32. data/lib/rubygems/commands/pristine_command.rb +93 -0
  33. data/lib/rubygems/commands/push_command.rb +56 -0
  34. data/lib/rubygems/commands/query_command.rb +280 -0
  35. data/lib/rubygems/commands/rdoc_command.rb +91 -0
  36. data/lib/rubygems/commands/search_command.rb +31 -0
  37. data/lib/rubygems/commands/server_command.rb +86 -0
  38. data/lib/rubygems/commands/setup_command.rb +387 -0
  39. data/lib/rubygems/commands/sources_command.rb +157 -0
  40. data/lib/rubygems/commands/specification_command.rb +125 -0
  41. data/lib/rubygems/commands/stale_command.rb +27 -0
  42. data/lib/rubygems/commands/uninstall_command.rb +83 -0
  43. data/lib/rubygems/commands/unpack_command.rb +121 -0
  44. data/lib/rubygems/commands/update_command.rb +212 -0
  45. data/lib/rubygems/commands/which_command.rb +86 -0
  46. data/lib/rubygems/config_file.rb +345 -0
  47. data/lib/rubygems/custom_require.rb +44 -0
  48. data/lib/rubygems/defaults.rb +101 -0
  49. data/lib/rubygems/dependency.rb +227 -0
  50. data/lib/rubygems/dependency_installer.rb +286 -0
  51. data/lib/rubygems/dependency_list.rb +208 -0
  52. data/lib/rubygems/doc_manager.rb +242 -0
  53. data/lib/rubygems/errors.rb +35 -0
  54. data/lib/rubygems/exceptions.rb +91 -0
  55. data/lib/rubygems/ext.rb +18 -0
  56. data/lib/rubygems/ext/builder.rb +56 -0
  57. data/lib/rubygems/ext/configure_builder.rb +25 -0
  58. data/lib/rubygems/ext/ext_conf_builder.rb +24 -0
  59. data/lib/rubygems/ext/rake_builder.rb +39 -0
  60. data/lib/rubygems/format.rb +81 -0
  61. data/lib/rubygems/gem_openssl.rb +92 -0
  62. data/lib/rubygems/gem_path_searcher.rb +100 -0
  63. data/lib/rubygems/gem_runner.rb +79 -0
  64. data/lib/rubygems/gemcutter_utilities.rb +49 -0
  65. data/lib/rubygems/indexer.rb +720 -0
  66. data/lib/rubygems/install_update_options.rb +125 -0
  67. data/lib/rubygems/installer.rb +604 -0
  68. data/lib/rubygems/local_remote_options.rb +135 -0
  69. data/lib/rubygems/old_format.rb +153 -0
  70. data/lib/rubygems/package.rb +97 -0
  71. data/lib/rubygems/package/f_sync_dir.rb +23 -0
  72. data/lib/rubygems/package/tar_header.rb +266 -0
  73. data/lib/rubygems/package/tar_input.rb +222 -0
  74. data/lib/rubygems/package/tar_output.rb +144 -0
  75. data/lib/rubygems/package/tar_reader.rb +106 -0
  76. data/lib/rubygems/package/tar_reader/entry.rb +141 -0
  77. data/lib/rubygems/package/tar_writer.rb +241 -0
  78. data/lib/rubygems/package_task.rb +126 -0
  79. data/lib/rubygems/platform.rb +183 -0
  80. data/lib/rubygems/remote_fetcher.rb +414 -0
  81. data/lib/rubygems/require_paths_builder.rb +18 -0
  82. data/lib/rubygems/requirement.rb +153 -0
  83. data/lib/rubygems/security.rb +814 -0
  84. data/lib/rubygems/server.rb +872 -0
  85. data/lib/rubygems/source_index.rb +597 -0
  86. data/lib/rubygems/source_info_cache.rb +395 -0
  87. data/lib/rubygems/source_info_cache_entry.rb +56 -0
  88. data/lib/rubygems/spec_fetcher.rb +337 -0
  89. data/lib/rubygems/specification.rb +1486 -0
  90. data/lib/rubygems/test_utilities.rb +147 -0
  91. data/lib/rubygems/text.rb +65 -0
  92. data/lib/rubygems/uninstaller.rb +278 -0
  93. data/lib/rubygems/user_interaction.rb +527 -0
  94. data/lib/rubygems/validator.rb +240 -0
  95. data/lib/rubygems/version.rb +316 -0
  96. data/lib/rubygems/version_option.rb +65 -0
  97. data/lib/ubygems.rb +10 -0
  98. data/setup.rb +42 -0
  99. data/test/bogussources.rb +8 -0
  100. data/test/data/gem-private_key.pem +27 -0
  101. data/test/data/gem-public_cert.pem +20 -0
  102. data/test/fake_certlib/openssl.rb +7 -0
  103. data/test/foo/discover.rb +0 -0
  104. data/test/functional.rb +92 -0
  105. data/test/gem_installer_test_case.rb +97 -0
  106. data/test/gem_package_tar_test_case.rb +132 -0
  107. data/test/gemutilities.rb +605 -0
  108. data/test/insure_session.rb +43 -0
  109. data/test/mockgemui.rb +56 -0
  110. data/test/plugin/exception/rubygems_plugin.rb +2 -0
  111. data/test/plugin/load/rubygems_plugin.rb +1 -0
  112. data/test/plugin/standarderror/rubygems_plugin.rb +2 -0
  113. data/test/private_key.pem +27 -0
  114. data/test/public_cert.pem +20 -0
  115. data/test/rubygems_plugin.rb +21 -0
  116. data/test/simple_gem.rb +66 -0
  117. data/test/test_config.rb +12 -0
  118. data/test/test_gem.rb +766 -0
  119. data/test/test_gem_builder.rb +27 -0
  120. data/test/test_gem_command.rb +178 -0
  121. data/test/test_gem_command_manager.rb +207 -0
  122. data/test/test_gem_commands_build_command.rb +74 -0
  123. data/test/test_gem_commands_cert_command.rb +124 -0
  124. data/test/test_gem_commands_check_command.rb +18 -0
  125. data/test/test_gem_commands_contents_command.rb +156 -0
  126. data/test/test_gem_commands_dependency_command.rb +216 -0
  127. data/test/test_gem_commands_environment_command.rb +144 -0
  128. data/test/test_gem_commands_fetch_command.rb +76 -0
  129. data/test/test_gem_commands_generate_index_command.rb +135 -0
  130. data/test/test_gem_commands_install_command.rb +315 -0
  131. data/test/test_gem_commands_list_command.rb +36 -0
  132. data/test/test_gem_commands_lock_command.rb +68 -0
  133. data/test/test_gem_commands_mirror_command.rb +60 -0
  134. data/test/test_gem_commands_outdated_command.rb +40 -0
  135. data/test/test_gem_commands_owner_command.rb +105 -0
  136. data/test/test_gem_commands_pristine_command.rb +108 -0
  137. data/test/test_gem_commands_push_command.rb +81 -0
  138. data/test/test_gem_commands_query_command.rb +426 -0
  139. data/test/test_gem_commands_server_command.rb +59 -0
  140. data/test/test_gem_commands_sources_command.rb +209 -0
  141. data/test/test_gem_commands_specification_command.rb +139 -0
  142. data/test/test_gem_commands_stale_command.rb +38 -0
  143. data/test/test_gem_commands_uninstall_command.rb +83 -0
  144. data/test/test_gem_commands_unpack_command.rb +199 -0
  145. data/test/test_gem_commands_update_command.rb +353 -0
  146. data/test/test_gem_commands_which_command.rb +66 -0
  147. data/test/test_gem_config_file.rb +287 -0
  148. data/test/test_gem_dependency.rb +149 -0
  149. data/test/test_gem_dependency_installer.rb +661 -0
  150. data/test/test_gem_dependency_list.rb +230 -0
  151. data/test/test_gem_doc_manager.rb +31 -0
  152. data/test/test_gem_ext_configure_builder.rb +84 -0
  153. data/test/test_gem_ext_ext_conf_builder.rb +173 -0
  154. data/test/test_gem_ext_rake_builder.rb +81 -0
  155. data/test/test_gem_format.rb +70 -0
  156. data/test/test_gem_gem_path_searcher.rb +78 -0
  157. data/test/test_gem_gem_runner.rb +45 -0
  158. data/test/test_gem_gemcutter_utilities.rb +103 -0
  159. data/test/test_gem_indexer.rb +673 -0
  160. data/test/test_gem_install_update_options.rb +68 -0
  161. data/test/test_gem_installer.rb +857 -0
  162. data/test/test_gem_local_remote_options.rb +97 -0
  163. data/test/test_gem_package_tar_header.rb +130 -0
  164. data/test/test_gem_package_tar_input.rb +112 -0
  165. data/test/test_gem_package_tar_output.rb +97 -0
  166. data/test/test_gem_package_tar_reader.rb +46 -0
  167. data/test/test_gem_package_tar_reader_entry.rb +109 -0
  168. data/test/test_gem_package_tar_writer.rb +144 -0
  169. data/test/test_gem_package_task.rb +59 -0
  170. data/test/test_gem_platform.rb +264 -0
  171. data/test/test_gem_remote_fetcher.rb +740 -0
  172. data/test/test_gem_requirement.rb +292 -0
  173. data/test/test_gem_server.rb +356 -0
  174. data/test/test_gem_silent_ui.rb +113 -0
  175. data/test/test_gem_source_index.rb +461 -0
  176. data/test/test_gem_spec_fetcher.rb +410 -0
  177. data/test/test_gem_specification.rb +1291 -0
  178. data/test/test_gem_stream_ui.rb +218 -0
  179. data/test/test_gem_text.rb +43 -0
  180. data/test/test_gem_uninstaller.rb +146 -0
  181. data/test/test_gem_validator.rb +63 -0
  182. data/test/test_gem_version.rb +181 -0
  183. data/test/test_gem_version_option.rb +89 -0
  184. data/test/test_kernel.rb +59 -0
  185. metadata +413 -0
@@ -0,0 +1,230 @@
1
+ require File.expand_path('../gemutilities', __FILE__)
2
+ require 'rubygems/dependency_list'
3
+
4
+ class TestGemDependencyList < RubyGemTestCase
5
+
6
+ def setup
7
+ super
8
+
9
+ @deplist = Gem::DependencyList.new
10
+
11
+ @a1 = quick_gem 'a', '1'
12
+ @a2 = quick_gem 'a', '2'
13
+ @a3 = quick_gem 'a', '3'
14
+
15
+ @b1 = quick_gem 'b', '1' do |s| s.add_dependency 'a', '>= 1' end
16
+ @b2 = quick_gem 'b', '2' do |s| s.add_dependency 'a', '>= 1' end
17
+
18
+ @c1 = quick_gem 'c', '1' do |s| s.add_dependency 'b', '>= 1' end
19
+ @c2 = quick_gem 'c', '2'
20
+
21
+ @d1 = quick_gem 'd', '1' do |s| s.add_dependency 'c', '>= 1' end
22
+ end
23
+
24
+ def test_self_from_source_index
25
+ hash = {
26
+ 'a-1' => @a1,
27
+ 'b-2' => @b2,
28
+ }
29
+
30
+ si = Gem::SourceIndex.new hash
31
+ deps = Gem::DependencyList.from_source_index si
32
+
33
+ assert_equal %w[b-2 a-1], deps.dependency_order.map { |s| s.full_name }
34
+ end
35
+
36
+ def test_active_count
37
+ assert_equal 0, @deplist.send(:active_count, [], {})
38
+ assert_equal 1, @deplist.send(:active_count, [@a1], {})
39
+ assert_equal 0, @deplist.send(:active_count, [@a1],
40
+ { @a1.full_name => true })
41
+ end
42
+
43
+ def test_add
44
+ assert_equal [], @deplist.dependency_order
45
+
46
+ @deplist.add @a1, @b2
47
+
48
+ assert_equal [@b2, @a1], @deplist.dependency_order
49
+ end
50
+
51
+ def test_dependency_order
52
+ @deplist.add @a1, @b1, @c1, @d1
53
+
54
+ order = @deplist.dependency_order
55
+
56
+ assert_equal %w[d-1 c-1 b-1 a-1], order.map { |s| s.full_name }
57
+ end
58
+
59
+ def test_dependency_order_circle
60
+ @a1.add_dependency 'c', '>= 1'
61
+ @deplist.add @a1, @b1, @c1
62
+
63
+ order = @deplist.dependency_order
64
+
65
+ assert_equal %w[b-1 c-1 a-1], order.map { |s| s.full_name }
66
+ end
67
+
68
+ def test_dependency_order_development
69
+ e1 = quick_gem 'e', '1'
70
+ f1 = quick_gem 'f', '1'
71
+ g1 = quick_gem 'g', '1'
72
+
73
+ @a1.add_dependency 'e'
74
+ @a1.add_dependency 'f'
75
+ @a1.add_dependency 'g'
76
+ g1.add_development_dependency 'a'
77
+
78
+ deplist = Gem::DependencyList.new true
79
+ deplist.add @a1, e1, f1, g1
80
+
81
+ order = deplist.dependency_order
82
+
83
+ assert_equal %w[g-1 a-1 f-1 e-1], order.map { |s| s.full_name },
84
+ 'development on'
85
+
86
+ deplist2 = Gem::DependencyList.new
87
+ deplist2.add @a1, e1, f1, g1
88
+
89
+ order = deplist2.dependency_order
90
+
91
+ assert_equal %w[a-1 g-1 f-1 e-1], order.map { |s| s.full_name },
92
+ 'development off'
93
+ end
94
+
95
+ def test_dependency_order_diamond
96
+ util_diamond
97
+ e1 = quick_gem 'e', '1'
98
+ @deplist.add e1
99
+ @a1.add_dependency 'e', '>= 1'
100
+
101
+ order = @deplist.dependency_order
102
+
103
+ assert_equal %w[d-1 c-2 b-1 a-2 e-1], order.map { |s| s.full_name },
104
+ 'deps of trimmed specs not included'
105
+ end
106
+
107
+ def test_dependency_order_no_dependendencies
108
+ @deplist.add @a1, @c2
109
+
110
+ order = @deplist.dependency_order
111
+
112
+ assert_equal %w[c-2 a-1], order.map { |s| s.full_name }
113
+ end
114
+
115
+ def test_find_name
116
+ @deplist.add @a1, @b2
117
+
118
+ assert_equal "a-1", @deplist.find_name("a-1").full_name
119
+ assert_equal "b-2", @deplist.find_name("b-2").full_name
120
+
121
+ assert_nil @deplist.find_name("c-2")
122
+ end
123
+
124
+ def test_ok_eh
125
+ assert @deplist.ok?, 'no dependencies'
126
+
127
+ @deplist.add @b2
128
+
129
+ refute @deplist.ok?, 'unsatisfied dependency'
130
+
131
+ @deplist.add @a1
132
+
133
+ assert @deplist.ok?, 'satisfied dependency'
134
+ end
135
+
136
+ def test_ok_eh_mismatch
137
+ a1 = quick_gem 'a', '1'
138
+ a2 = quick_gem 'a', '2'
139
+
140
+ b = quick_gem 'b', '1' do |s| s.add_dependency 'a', '= 1' end
141
+ c = quick_gem 'c', '1' do |s| s.add_dependency 'a', '= 2' end
142
+
143
+ d = quick_gem 'd', '1' do |s|
144
+ s.add_dependency 'b'
145
+ s.add_dependency 'c'
146
+ end
147
+
148
+ @deplist.add a1, a2, b, c, d
149
+
150
+ assert @deplist.ok?, 'this will break on require'
151
+ end
152
+
153
+ def test_ok_eh_redundant
154
+ @deplist.add @a1, @a3, @b2
155
+
156
+ @deplist.remove_by_name("a-1")
157
+
158
+ assert @deplist.ok?
159
+ end
160
+
161
+ def test_ok_to_remove_eh
162
+ @deplist.add @a1
163
+
164
+ assert @deplist.ok_to_remove?("a-1")
165
+
166
+ @deplist.add @b2
167
+
168
+ refute @deplist.ok_to_remove?("a-1")
169
+
170
+ @deplist.add @a2
171
+
172
+ assert @deplist.ok_to_remove?("a-1")
173
+ assert @deplist.ok_to_remove?("a-2")
174
+ assert @deplist.ok_to_remove?("b-2")
175
+ end
176
+
177
+ def test_ok_to_remove_eh_after_sibling_removed
178
+ @deplist.add @a1, @a2, @b2
179
+
180
+ assert @deplist.ok_to_remove?("a-1")
181
+ assert @deplist.ok_to_remove?("a-2")
182
+
183
+ @deplist.remove_by_name("a-1")
184
+
185
+ refute @deplist.ok_to_remove?("a-2")
186
+ end
187
+
188
+ def test_remove_by_name
189
+ @deplist.add @a1, @b2
190
+
191
+ @deplist.remove_by_name "a-1"
192
+
193
+ refute @deplist.ok?
194
+ end
195
+
196
+ def test_tsort_each_node
197
+ util_diamond
198
+
199
+ order = %w[a-1 a-2 b-1 c-2 d-1]
200
+
201
+ @deplist.tsort_each_node do |node|
202
+ assert_equal order.shift, node.full_name
203
+ end
204
+
205
+ assert_empty order
206
+ end
207
+
208
+ def test_tsort_each_child
209
+ util_diamond
210
+
211
+ order = %w[a-2]
212
+
213
+ @deplist.tsort_each_child(@b1) do |node|
214
+ assert_equal order.shift, node.full_name
215
+ end
216
+
217
+ assert_empty order
218
+ end
219
+
220
+ # d1 -> b1 -> a1
221
+ # d1 -> c2 -> a2
222
+ def util_diamond
223
+ @c2.add_dependency 'a', '>= 2'
224
+ @d1.add_dependency 'b'
225
+
226
+ @deplist.add @a1, @a2, @b1, @c2, @d1
227
+ end
228
+
229
+ end
230
+
@@ -0,0 +1,31 @@
1
+ require File.expand_path('../gemutilities', __FILE__)
2
+ require 'rubygems/doc_manager'
3
+
4
+ class TestGemDocManager < RubyGemTestCase
5
+
6
+ def setup
7
+ super
8
+
9
+ @spec = quick_gem 'a'
10
+ @manager = Gem::DocManager.new(@spec)
11
+ end
12
+
13
+ def test_uninstall_doc_unwritable
14
+ orig_mode = File.stat(@spec.installation_path).mode
15
+
16
+ # File.chmod has no effect on MS Windows directories (it needs ACL).
17
+ if win_platform?
18
+ skip("test_uninstall_doc_unwritable skipped on MS Windows")
19
+ else
20
+ File.chmod(0, @spec.installation_path)
21
+ end
22
+
23
+ assert_raises Gem::FilePermissionError do
24
+ @manager.uninstall_doc
25
+ end
26
+ ensure
27
+ File.chmod orig_mode, @spec.installation_path
28
+ end
29
+
30
+ end
31
+
@@ -0,0 +1,84 @@
1
+ require File.expand_path('../gemutilities', __FILE__)
2
+ require 'rubygems/ext'
3
+
4
+ class TestGemExtConfigureBuilder < RubyGemTestCase
5
+
6
+ def setup
7
+ super
8
+
9
+ @makefile_body = "all:\n\t@echo ok\ninstall:\n\t@echo ok"
10
+
11
+ @ext = File.join @tempdir, 'ext'
12
+ @dest_path = File.join @tempdir, 'prefix'
13
+
14
+ FileUtils.mkdir_p @ext
15
+ FileUtils.mkdir_p @dest_path
16
+ end
17
+
18
+ def test_self_build
19
+ skip("test_self_build skipped on MS Windows (VC++)") if vc_windows?
20
+
21
+ File.open File.join(@ext, './configure'), 'w' do |configure|
22
+ configure.puts "#!/bin/sh\necho \"#{@makefile_body}\" > Makefile"
23
+ end
24
+
25
+ output = []
26
+
27
+ Dir.chdir @ext do
28
+ Gem::Ext::ConfigureBuilder.build nil, nil, @dest_path, output
29
+ end
30
+
31
+ assert_equal "sh ./configure --prefix=#{@dest_path}", output.shift
32
+ assert_equal "", output.shift
33
+ assert_equal "make", output.shift
34
+ assert_match(/^ok$/m, output.shift)
35
+ assert_equal "make install", output.shift
36
+ assert_match(/^ok$/m, output.shift)
37
+ end
38
+
39
+ def test_self_build_fail
40
+ skip("test_self_build_fail skipped on MS Windows (VC++)") if vc_windows?
41
+ output = []
42
+
43
+ error = assert_raises Gem::InstallError do
44
+ Dir.chdir @ext do
45
+ Gem::Ext::ConfigureBuilder.build nil, nil, @dest_path, output
46
+ end
47
+ end
48
+
49
+ shell_error_msg = %r{(\./configure: .*)|(Can't open \./configure(?:: No such file or directory)?)}
50
+ sh_prefix_configure = "sh ./configure --prefix="
51
+
52
+ expected = %r(configure failed:
53
+
54
+ #{Regexp.escape sh_prefix_configure}#{Regexp.escape @dest_path}
55
+ .*?: #{shell_error_msg}
56
+ )
57
+
58
+ assert_match expected, error.message
59
+
60
+ assert_equal "#{sh_prefix_configure}#{@dest_path}", output.shift
61
+ assert_match %r(#{shell_error_msg}), output.shift
62
+ assert_equal true, output.empty?
63
+ end
64
+
65
+ def test_self_build_has_makefile
66
+ if vc_windows? && !nmake_found?
67
+ skip("test_self_build_has_makefile skipped - nmake not found")
68
+ end
69
+
70
+ File.open File.join(@ext, 'Makefile'), 'w' do |makefile|
71
+ makefile.puts @makefile_body
72
+ end
73
+
74
+ output = []
75
+ Dir.chdir @ext do
76
+ Gem::Ext::ConfigureBuilder.build nil, nil, @dest_path, output
77
+ end
78
+
79
+ assert_equal make_command, output[0]
80
+ assert_equal "#{make_command} install", output[2]
81
+ end
82
+
83
+ end
84
+
@@ -0,0 +1,173 @@
1
+ require File.expand_path('../gemutilities', __FILE__)
2
+ require 'rubygems/ext'
3
+
4
+ class TestGemExtExtConfBuilder < RubyGemTestCase
5
+
6
+ def setup
7
+ super
8
+
9
+ @ext = File.join @tempdir, 'ext'
10
+ @dest_path = File.join @tempdir, 'prefix'
11
+
12
+ FileUtils.mkdir_p @ext
13
+ FileUtils.mkdir_p @dest_path
14
+ end
15
+
16
+ def test_class_build
17
+ if vc_windows? && !nmake_found?
18
+ skip("test_class_build skipped - nmake not found")
19
+ end
20
+
21
+ File.open File.join(@ext, 'extconf.rb'), 'w' do |extconf|
22
+ extconf.puts "require 'mkmf'\ncreate_makefile 'foo'"
23
+ end
24
+
25
+ output = []
26
+
27
+ Dir.chdir @ext do
28
+ Gem::Ext::ExtConfBuilder.build 'extconf.rb', nil, @dest_path, output
29
+ end
30
+
31
+ expected = [
32
+ "ruby extconf.rb",
33
+ "creating Makefile\n",
34
+ "make",
35
+ "make: Nothing to be done for `all'.\n",
36
+ "make install",
37
+ "make: Nothing to be done for `install'.\n"
38
+ ]
39
+
40
+ assert_match(/^#{Gem.ruby} extconf.rb/, output[0])
41
+ assert_equal "creating Makefile\n", output[1]
42
+ case RUBY_PLATFORM
43
+ when /mswin/ then
44
+ assert_equal "nmake", output[2]
45
+ assert_equal "nmake install", output[4]
46
+ else
47
+ assert_equal "make", output[2]
48
+ assert_equal "make install", output[4]
49
+ end
50
+ end
51
+
52
+ def test_class_build_rbconfig_make_prog
53
+ configure_args = RbConfig::CONFIG['configure_args']
54
+ RbConfig::CONFIG['configure_args'] = '--with-make-prog=mymake'
55
+
56
+ File.open File.join(@ext, 'extconf.rb'), 'w' do |extconf|
57
+ extconf.puts "require 'mkmf'\ncreate_makefile 'foo'"
58
+ end
59
+
60
+ output = []
61
+
62
+ assert_raises Gem::InstallError do
63
+ Dir.chdir @ext do
64
+ Gem::Ext::ExtConfBuilder.build 'extconf.rb', nil, @dest_path, output
65
+ end
66
+ end
67
+
68
+ assert_equal "creating Makefile\n", output[1]
69
+ assert_equal "mymake", output[2]
70
+ ensure
71
+ RbConfig::CONFIG['configure_args'] = configure_args
72
+ end
73
+
74
+ def test_class_build_env_make
75
+ configure_args, env_make = RbConfig::CONFIG['configure_args'], ENV.delete('make')
76
+ RbConfig::CONFIG['configure_args'] = ''
77
+ ENV['make'] = 'anothermake'
78
+
79
+ File.open File.join(@ext, 'extconf.rb'), 'w' do |extconf|
80
+ extconf.puts "require 'mkmf'\ncreate_makefile 'foo'"
81
+ end
82
+
83
+ output = []
84
+
85
+ assert_raises Gem::InstallError do
86
+ Dir.chdir @ext do
87
+ Gem::Ext::ExtConfBuilder.build 'extconf.rb', nil, @dest_path, output
88
+ end
89
+ end
90
+
91
+ assert_equal "creating Makefile\n", output[1]
92
+ assert_equal "anothermake", output[2]
93
+ ensure
94
+ RbConfig::CONFIG['configure_args'] = configure_args
95
+ ENV['make'] = env_make
96
+ end
97
+
98
+ def test_class_build_extconf_fail
99
+ if vc_windows? && !nmake_found?
100
+ skip("test_class_build_extconf_fail skipped - nmake not found")
101
+ end
102
+
103
+ File.open File.join(@ext, 'extconf.rb'), 'w' do |extconf|
104
+ extconf.puts "require 'mkmf'"
105
+ extconf.puts "have_library 'nonexistent' or abort 'need libnonexistent'"
106
+ extconf.puts "create_makefile 'foo'"
107
+ end
108
+
109
+ output = []
110
+
111
+ error = assert_raises Gem::InstallError do
112
+ Dir.chdir @ext do
113
+ Gem::Ext::ExtConfBuilder.build 'extconf.rb', nil, @dest_path, output
114
+ end
115
+ end
116
+
117
+ assert_match(/\Aextconf failed:
118
+
119
+ #{Gem.ruby} extconf.rb.*
120
+ checking for main\(\) in .*?nonexistent/m, error.message)
121
+
122
+ assert_match(/^#{Gem.ruby} extconf.rb/, output[0])
123
+ end
124
+
125
+ def test_class_make
126
+ if vc_windows? && !nmake_found?
127
+ skip("test_class_make skipped - nmake not found")
128
+ end
129
+
130
+ output = []
131
+ makefile_path = File.join(@ext, 'Makefile')
132
+ File.open makefile_path, 'w' do |makefile|
133
+ makefile.puts "RUBYARCHDIR = $(foo)$(target_prefix)"
134
+ makefile.puts "RUBYLIBDIR = $(bar)$(target_prefix)"
135
+ makefile.puts "all:"
136
+ makefile.puts "install:"
137
+ end
138
+
139
+ Dir.chdir @ext do
140
+ Gem::Ext::ExtConfBuilder.make @ext, output
141
+ end
142
+
143
+ assert_equal make_command, output[0]
144
+ assert_equal "#{make_command} install", output[2]
145
+
146
+ edited_makefile = <<-EOF
147
+ RUBYARCHDIR = #{@ext}$(target_prefix)
148
+ RUBYLIBDIR = #{@ext}$(target_prefix)
149
+ all:
150
+ install:
151
+ EOF
152
+
153
+ assert_equal edited_makefile, File.read(makefile_path)
154
+ end
155
+
156
+ def test_class_make_no_Makefile
157
+ error = assert_raises Gem::InstallError do
158
+ Dir.chdir @ext do
159
+ Gem::Ext::ExtConfBuilder.make @ext, ['output']
160
+ end
161
+ end
162
+
163
+ expected = <<-EOF.strip
164
+ Makefile not found:
165
+
166
+ output
167
+ EOF
168
+
169
+ assert_equal expected, error.message
170
+ end
171
+
172
+ end
173
+