libgems 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +5811 -0
- data/History.txt +887 -0
- data/LICENSE.txt +51 -0
- data/README.md +87 -0
- data/Rakefile +113 -0
- data/lib/gauntlet_libgems.rb +50 -0
- data/lib/libgems.rb +1246 -0
- data/lib/libgems/builder.rb +102 -0
- data/lib/libgems/command.rb +534 -0
- data/lib/libgems/command_manager.rb +182 -0
- data/lib/libgems/commands/build_command.rb +53 -0
- data/lib/libgems/commands/cert_command.rb +86 -0
- data/lib/libgems/commands/check_command.rb +80 -0
- data/lib/libgems/commands/cleanup_command.rb +106 -0
- data/lib/libgems/commands/contents_command.rb +98 -0
- data/lib/libgems/commands/dependency_command.rb +195 -0
- data/lib/libgems/commands/environment_command.rb +133 -0
- data/lib/libgems/commands/fetch_command.rb +67 -0
- data/lib/libgems/commands/generate_index_command.rb +133 -0
- data/lib/libgems/commands/help_command.rb +172 -0
- data/lib/libgems/commands/install_command.rb +178 -0
- data/lib/libgems/commands/list_command.rb +35 -0
- data/lib/libgems/commands/lock_command.rb +110 -0
- data/lib/libgems/commands/mirror_command.rb +111 -0
- data/lib/libgems/commands/outdated_command.rb +33 -0
- data/lib/libgems/commands/owner_command.rb +75 -0
- data/lib/libgems/commands/pristine_command.rb +93 -0
- data/lib/libgems/commands/push_command.rb +56 -0
- data/lib/libgems/commands/query_command.rb +280 -0
- data/lib/libgems/commands/rdoc_command.rb +91 -0
- data/lib/libgems/commands/search_command.rb +31 -0
- data/lib/libgems/commands/server_command.rb +86 -0
- data/lib/libgems/commands/sources_command.rb +157 -0
- data/lib/libgems/commands/specification_command.rb +125 -0
- data/lib/libgems/commands/stale_command.rb +27 -0
- data/lib/libgems/commands/uninstall_command.rb +83 -0
- data/lib/libgems/commands/unpack_command.rb +121 -0
- data/lib/libgems/commands/update_command.rb +160 -0
- data/lib/libgems/commands/which_command.rb +86 -0
- data/lib/libgems/config_file.rb +345 -0
- data/lib/libgems/custom_require.rb +44 -0
- data/lib/libgems/defaults.rb +101 -0
- data/lib/libgems/dependency.rb +227 -0
- data/lib/libgems/dependency_installer.rb +286 -0
- data/lib/libgems/dependency_list.rb +208 -0
- data/lib/libgems/doc_manager.rb +242 -0
- data/lib/libgems/errors.rb +35 -0
- data/lib/libgems/exceptions.rb +91 -0
- data/lib/libgems/ext.rb +18 -0
- data/lib/libgems/ext/builder.rb +56 -0
- data/lib/libgems/ext/configure_builder.rb +25 -0
- data/lib/libgems/ext/ext_conf_builder.rb +24 -0
- data/lib/libgems/ext/rake_builder.rb +39 -0
- data/lib/libgems/format.rb +81 -0
- data/lib/libgems/gem_openssl.rb +92 -0
- data/lib/libgems/gem_path_searcher.rb +100 -0
- data/lib/libgems/gem_runner.rb +79 -0
- data/lib/libgems/gemcutter_utilities.rb +49 -0
- data/lib/libgems/indexer.rb +720 -0
- data/lib/libgems/install_update_options.rb +125 -0
- data/lib/libgems/installer.rb +604 -0
- data/lib/libgems/local_remote_options.rb +135 -0
- data/lib/libgems/old_format.rb +153 -0
- data/lib/libgems/package.rb +97 -0
- data/lib/libgems/package/f_sync_dir.rb +23 -0
- data/lib/libgems/package/tar_header.rb +266 -0
- data/lib/libgems/package/tar_input.rb +222 -0
- data/lib/libgems/package/tar_output.rb +144 -0
- data/lib/libgems/package/tar_reader.rb +106 -0
- data/lib/libgems/package/tar_reader/entry.rb +141 -0
- data/lib/libgems/package/tar_writer.rb +241 -0
- data/lib/libgems/package_task.rb +126 -0
- data/lib/libgems/platform.rb +183 -0
- data/lib/libgems/remote_fetcher.rb +414 -0
- data/lib/libgems/require_paths_builder.rb +18 -0
- data/lib/libgems/requirement.rb +153 -0
- data/lib/libgems/security.rb +814 -0
- data/lib/libgems/server.rb +872 -0
- data/lib/libgems/source_index.rb +597 -0
- data/lib/libgems/source_info_cache.rb +395 -0
- data/lib/libgems/source_info_cache_entry.rb +56 -0
- data/lib/libgems/spec_fetcher.rb +337 -0
- data/lib/libgems/specification.rb +1487 -0
- data/lib/libgems/test_utilities.rb +147 -0
- data/lib/libgems/text.rb +65 -0
- data/lib/libgems/uninstaller.rb +278 -0
- data/lib/libgems/user_interaction.rb +527 -0
- data/lib/libgems/validator.rb +240 -0
- data/lib/libgems/version.rb +316 -0
- data/lib/libgems/version_option.rb +65 -0
- data/lib/rbconfig/datadir.rb +20 -0
- data/test/bogussources.rb +8 -0
- data/test/data/gem-private_key.pem +27 -0
- data/test/data/gem-public_cert.pem +20 -0
- data/test/fake_certlib/openssl.rb +7 -0
- data/test/foo/discover.rb +0 -0
- data/test/gem_installer_test_case.rb +97 -0
- data/test/gem_package_tar_test_case.rb +132 -0
- data/test/gemutilities.rb +605 -0
- data/test/insure_session.rb +43 -0
- data/test/mockgemui.rb +56 -0
- data/test/plugin/exception/libgems_plugin.rb +2 -0
- data/test/plugin/load/libgems_plugin.rb +1 -0
- data/test/plugin/standarderror/libgems_plugin.rb +2 -0
- data/test/private_key.pem +27 -0
- data/test/public_cert.pem +20 -0
- data/test/rubygems_plugin.rb +21 -0
- data/test/simple_gem.rb +66 -0
- data/test/test_config.rb +12 -0
- data/test/test_gem.rb +780 -0
- data/test/test_gem_builder.rb +27 -0
- data/test/test_gem_command.rb +178 -0
- data/test/test_gem_command_manager.rb +207 -0
- data/test/test_gem_commands_build_command.rb +74 -0
- data/test/test_gem_commands_cert_command.rb +124 -0
- data/test/test_gem_commands_check_command.rb +18 -0
- data/test/test_gem_commands_contents_command.rb +156 -0
- data/test/test_gem_commands_dependency_command.rb +216 -0
- data/test/test_gem_commands_environment_command.rb +144 -0
- data/test/test_gem_commands_fetch_command.rb +76 -0
- data/test/test_gem_commands_generate_index_command.rb +135 -0
- data/test/test_gem_commands_install_command.rb +315 -0
- data/test/test_gem_commands_list_command.rb +36 -0
- data/test/test_gem_commands_lock_command.rb +68 -0
- data/test/test_gem_commands_mirror_command.rb +60 -0
- data/test/test_gem_commands_outdated_command.rb +40 -0
- data/test/test_gem_commands_owner_command.rb +105 -0
- data/test/test_gem_commands_pristine_command.rb +108 -0
- data/test/test_gem_commands_push_command.rb +81 -0
- data/test/test_gem_commands_query_command.rb +426 -0
- data/test/test_gem_commands_server_command.rb +59 -0
- data/test/test_gem_commands_sources_command.rb +209 -0
- data/test/test_gem_commands_specification_command.rb +139 -0
- data/test/test_gem_commands_stale_command.rb +38 -0
- data/test/test_gem_commands_uninstall_command.rb +83 -0
- data/test/test_gem_commands_unpack_command.rb +199 -0
- data/test/test_gem_commands_update_command.rb +207 -0
- data/test/test_gem_commands_which_command.rb +66 -0
- data/test/test_gem_config_file.rb +287 -0
- data/test/test_gem_dependency.rb +149 -0
- data/test/test_gem_dependency_installer.rb +661 -0
- data/test/test_gem_dependency_list.rb +230 -0
- data/test/test_gem_doc_manager.rb +31 -0
- data/test/test_gem_ext_configure_builder.rb +84 -0
- data/test/test_gem_ext_ext_conf_builder.rb +173 -0
- data/test/test_gem_ext_rake_builder.rb +81 -0
- data/test/test_gem_format.rb +70 -0
- data/test/test_gem_gem_path_searcher.rb +78 -0
- data/test/test_gem_gem_runner.rb +45 -0
- data/test/test_gem_gemcutter_utilities.rb +103 -0
- data/test/test_gem_indexer.rb +673 -0
- data/test/test_gem_install_update_options.rb +68 -0
- data/test/test_gem_installer.rb +857 -0
- data/test/test_gem_local_remote_options.rb +97 -0
- data/test/test_gem_package_tar_header.rb +130 -0
- data/test/test_gem_package_tar_input.rb +112 -0
- data/test/test_gem_package_tar_output.rb +97 -0
- data/test/test_gem_package_tar_reader.rb +46 -0
- data/test/test_gem_package_tar_reader_entry.rb +109 -0
- data/test/test_gem_package_tar_writer.rb +144 -0
- data/test/test_gem_package_task.rb +59 -0
- data/test/test_gem_platform.rb +264 -0
- data/test/test_gem_remote_fetcher.rb +740 -0
- data/test/test_gem_requirement.rb +292 -0
- data/test/test_gem_server.rb +356 -0
- data/test/test_gem_silent_ui.rb +113 -0
- data/test/test_gem_source_index.rb +461 -0
- data/test/test_gem_spec_fetcher.rb +410 -0
- data/test/test_gem_specification.rb +1334 -0
- data/test/test_gem_stream_ui.rb +218 -0
- data/test/test_gem_text.rb +43 -0
- data/test/test_gem_uninstaller.rb +146 -0
- data/test/test_gem_validator.rb +63 -0
- data/test/test_gem_version.rb +181 -0
- data/test/test_gem_version_option.rb +89 -0
- data/test/test_kernel.rb +59 -0
- metadata +402 -0
@@ -0,0 +1,230 @@
|
|
1
|
+
require File.expand_path('../gemutilities', __FILE__)
|
2
|
+
require 'libgems/dependency_list'
|
3
|
+
|
4
|
+
class TestGemDependencyList < RubyGemTestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
super
|
8
|
+
|
9
|
+
@deplist = LibGems::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 = LibGems::SourceIndex.new hash
|
31
|
+
deps = LibGems::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 = LibGems::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 = LibGems::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 'libgems/doc_manager'
|
3
|
+
|
4
|
+
class TestGemDocManager < RubyGemTestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
super
|
8
|
+
|
9
|
+
@spec = quick_gem 'a'
|
10
|
+
@manager = LibGems::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 LibGems::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 'libgems/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
|
+
LibGems::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 LibGems::InstallError do
|
44
|
+
Dir.chdir @ext do
|
45
|
+
LibGems::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
|
+
LibGems::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 'libgems/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
|
+
LibGems::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(/^#{LibGems.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 LibGems::InstallError do
|
63
|
+
Dir.chdir @ext do
|
64
|
+
LibGems::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 LibGems::InstallError do
|
86
|
+
Dir.chdir @ext do
|
87
|
+
LibGems::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 LibGems::InstallError do
|
112
|
+
Dir.chdir @ext do
|
113
|
+
LibGems::Ext::ExtConfBuilder.build 'extconf.rb', nil, @dest_path, output
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
assert_match(/\Aextconf failed:
|
118
|
+
|
119
|
+
#{LibGems.ruby} extconf.rb.*
|
120
|
+
checking for main\(\) in .*?nonexistent/m, error.message)
|
121
|
+
|
122
|
+
assert_match(/^#{LibGems.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
|
+
LibGems::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 LibGems::InstallError do
|
158
|
+
Dir.chdir @ext do
|
159
|
+
LibGems::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
|
+
|