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,292 @@
|
|
1
|
+
require File.expand_path('../gemutilities', __FILE__)
|
2
|
+
require "libgems/requirement"
|
3
|
+
|
4
|
+
class TestGemRequirement < RubyGemTestCase
|
5
|
+
|
6
|
+
def test_equals2
|
7
|
+
r = req "= 1.2"
|
8
|
+
assert_equal r, r.dup
|
9
|
+
assert_equal r.dup, r
|
10
|
+
|
11
|
+
refute_requirement_equal "= 1.2", "= 1.3"
|
12
|
+
refute_requirement_equal "= 1.3", "= 1.2"
|
13
|
+
|
14
|
+
refute_equal Object.new, req("= 1.2")
|
15
|
+
refute_equal req("= 1.2"), Object.new
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_initialize
|
19
|
+
assert_requirement_equal "= 2", "2"
|
20
|
+
assert_requirement_equal "= 2", ["2"]
|
21
|
+
assert_requirement_equal "= 2", v(2)
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_class_available_as_gem_version_requirement
|
25
|
+
assert_same LibGems::Requirement, LibGems::Version::Requirement,
|
26
|
+
"Gem::Version::Requirement is aliased for old YAML compatibility."
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_parse
|
30
|
+
assert_equal ['=', LibGems::Version.new(1)], LibGems::Requirement.parse(' 1')
|
31
|
+
assert_equal ['=', LibGems::Version.new(1)], LibGems::Requirement.parse('= 1')
|
32
|
+
assert_equal ['>', LibGems::Version.new(1)], LibGems::Requirement.parse('> 1')
|
33
|
+
assert_equal ['=', LibGems::Version.new(1)], LibGems::Requirement.parse("=\n1")
|
34
|
+
|
35
|
+
assert_equal ['=', LibGems::Version.new(2)],
|
36
|
+
LibGems::Requirement.parse(LibGems::Version.new('2'))
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_parse_bad
|
40
|
+
e = assert_raises ArgumentError do
|
41
|
+
LibGems::Requirement.parse nil
|
42
|
+
end
|
43
|
+
|
44
|
+
assert_equal 'Illformed requirement [nil]', e.message
|
45
|
+
|
46
|
+
e = assert_raises ArgumentError do
|
47
|
+
LibGems::Requirement.parse ""
|
48
|
+
end
|
49
|
+
|
50
|
+
assert_equal 'Illformed requirement [""]', e.message
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_prerelease_eh
|
54
|
+
r = req '= 1'
|
55
|
+
|
56
|
+
refute r.prerelease?
|
57
|
+
|
58
|
+
r = req '= 1.a'
|
59
|
+
|
60
|
+
assert r.prerelease?
|
61
|
+
|
62
|
+
r = req '> 1.a', '< 2'
|
63
|
+
|
64
|
+
assert r.prerelease?
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_satisfied_by_eh_bang_equal
|
68
|
+
r = req '!= 1.2'
|
69
|
+
|
70
|
+
assert_satisfied_by nil, r
|
71
|
+
assert_satisfied_by "1.1", r
|
72
|
+
refute_satisfied_by "1.2", r
|
73
|
+
assert_satisfied_by "1.3", r
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_satisfied_by_eh_blank
|
77
|
+
r = req "1.2"
|
78
|
+
|
79
|
+
refute_satisfied_by nil, r
|
80
|
+
refute_satisfied_by "1.1", r
|
81
|
+
assert_satisfied_by "1.2", r
|
82
|
+
refute_satisfied_by "1.3", r
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_satisfied_by_eh_equal
|
86
|
+
r = req "= 1.2"
|
87
|
+
|
88
|
+
refute_satisfied_by nil, r
|
89
|
+
refute_satisfied_by "1.1", r
|
90
|
+
assert_satisfied_by "1.2", r
|
91
|
+
refute_satisfied_by "1.3", r
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_satisfied_by_eh_gt
|
95
|
+
r = req "> 1.2"
|
96
|
+
|
97
|
+
refute_satisfied_by "1.1", r
|
98
|
+
refute_satisfied_by "1.2", r
|
99
|
+
assert_satisfied_by "1.3", r
|
100
|
+
|
101
|
+
assert_raises NoMethodError do
|
102
|
+
r.satisfied_by? nil
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def test_satisfied_by_eh_gte
|
107
|
+
r = req ">= 1.2"
|
108
|
+
|
109
|
+
refute_satisfied_by "1.1", r
|
110
|
+
assert_satisfied_by "1.2", r
|
111
|
+
assert_satisfied_by "1.3", r
|
112
|
+
|
113
|
+
assert_raises NoMethodError do
|
114
|
+
r.satisfied_by? nil
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
def test_satisfied_by_eh_list
|
119
|
+
r = req "> 1.1", "< 1.3"
|
120
|
+
|
121
|
+
refute_satisfied_by "1.1", r
|
122
|
+
assert_satisfied_by "1.2", r
|
123
|
+
refute_satisfied_by "1.3", r
|
124
|
+
|
125
|
+
assert_raises NoMethodError do
|
126
|
+
r.satisfied_by? nil
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
def test_satisfied_by_eh_lt
|
131
|
+
r = req "< 1.2"
|
132
|
+
|
133
|
+
assert_satisfied_by "1.1", r
|
134
|
+
refute_satisfied_by "1.2", r
|
135
|
+
refute_satisfied_by "1.3", r
|
136
|
+
|
137
|
+
assert_raises NoMethodError do
|
138
|
+
r.satisfied_by? nil
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
def test_satisfied_by_eh_lte
|
143
|
+
r = req "<= 1.2"
|
144
|
+
|
145
|
+
assert_satisfied_by "1.1", r
|
146
|
+
assert_satisfied_by "1.2", r
|
147
|
+
refute_satisfied_by "1.3", r
|
148
|
+
|
149
|
+
assert_raises NoMethodError do
|
150
|
+
r.satisfied_by? nil
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
def test_satisfied_by_eh_tilde_gt
|
155
|
+
r = req "~> 1.2"
|
156
|
+
|
157
|
+
refute_satisfied_by "1.1", r
|
158
|
+
assert_satisfied_by "1.2", r
|
159
|
+
assert_satisfied_by "1.3", r
|
160
|
+
|
161
|
+
assert_raises NoMethodError do
|
162
|
+
r.satisfied_by? nil
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
def test_satisfied_by_eh_good
|
167
|
+
assert_satisfied_by "0.2.33", "= 0.2.33"
|
168
|
+
assert_satisfied_by "0.2.34", "> 0.2.33"
|
169
|
+
assert_satisfied_by "1.0", "= 1.0"
|
170
|
+
assert_satisfied_by "1.0", "1.0"
|
171
|
+
assert_satisfied_by "1.8.2", "> 1.8.0"
|
172
|
+
assert_satisfied_by "1.112", "> 1.111"
|
173
|
+
assert_satisfied_by "0.2", "> 0.0.0"
|
174
|
+
assert_satisfied_by "0.0.0.0.0.2", "> 0.0.0"
|
175
|
+
assert_satisfied_by "0.0.1.0", "> 0.0.0.1"
|
176
|
+
assert_satisfied_by "10.3.2", "> 9.3.2"
|
177
|
+
assert_satisfied_by "1.0.0.0", "= 1.0"
|
178
|
+
assert_satisfied_by "10.3.2", "!= 9.3.4"
|
179
|
+
assert_satisfied_by "10.3.2", "> 9.3.2"
|
180
|
+
assert_satisfied_by "10.3.2", "> 9.3.2"
|
181
|
+
assert_satisfied_by " 9.3.2", ">= 9.3.2"
|
182
|
+
assert_satisfied_by "9.3.2 ", ">= 9.3.2"
|
183
|
+
assert_satisfied_by "", "= 0"
|
184
|
+
assert_satisfied_by "", "< 0.1"
|
185
|
+
assert_satisfied_by " ", "< 0.1 "
|
186
|
+
assert_satisfied_by "", " < 0.1"
|
187
|
+
assert_satisfied_by " ", "> 0.a "
|
188
|
+
assert_satisfied_by "", " > 0.a"
|
189
|
+
assert_satisfied_by "3.1", "< 3.2.rc1"
|
190
|
+
assert_satisfied_by "3.2.0", "> 3.2.0.rc1"
|
191
|
+
assert_satisfied_by "3.2.0.rc2", "> 3.2.0.rc1"
|
192
|
+
assert_satisfied_by "3.0.rc2", "< 3.0"
|
193
|
+
assert_satisfied_by "3.0.rc2", "< 3.0.0"
|
194
|
+
assert_satisfied_by "3.0.rc2", "< 3.0.1"
|
195
|
+
end
|
196
|
+
|
197
|
+
def test_illformed_requirements
|
198
|
+
[ ">>> 1.3.5", "> blah" ].each do |rq|
|
199
|
+
assert_raises ArgumentError, "req [#{rq}] should fail" do
|
200
|
+
LibGems::Requirement.new rq
|
201
|
+
end
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
def test_satisfied_by_eh_boxed
|
206
|
+
refute_satisfied_by "1.3", "~> 1.4"
|
207
|
+
assert_satisfied_by "1.4", "~> 1.4"
|
208
|
+
assert_satisfied_by "1.5", "~> 1.4"
|
209
|
+
refute_satisfied_by "2.0", "~> 1.4"
|
210
|
+
|
211
|
+
refute_satisfied_by "1.3", "~> 1.4.4"
|
212
|
+
refute_satisfied_by "1.4", "~> 1.4.4"
|
213
|
+
assert_satisfied_by "1.4.4", "~> 1.4.4"
|
214
|
+
assert_satisfied_by "1.4.5", "~> 1.4.4"
|
215
|
+
refute_satisfied_by "1.5", "~> 1.4.4"
|
216
|
+
refute_satisfied_by "2.0", "~> 1.4.4"
|
217
|
+
|
218
|
+
refute_satisfied_by "1.1.pre", "~> 1.0.0"
|
219
|
+
refute_satisfied_by "1.1.pre", "~> 1.1"
|
220
|
+
refute_satisfied_by "2.0.a", "~> 1.0"
|
221
|
+
refute_satisfied_by "2.0.a", "~> 2.0"
|
222
|
+
end
|
223
|
+
|
224
|
+
def test_satisfied_by_eh_multiple
|
225
|
+
req = [">= 1.4", "<= 1.6", "!= 1.5"]
|
226
|
+
|
227
|
+
refute_satisfied_by "1.3", req
|
228
|
+
assert_satisfied_by "1.4", req
|
229
|
+
refute_satisfied_by "1.5", req
|
230
|
+
assert_satisfied_by "1.6", req
|
231
|
+
refute_satisfied_by "1.7", req
|
232
|
+
refute_satisfied_by "2.0", req
|
233
|
+
end
|
234
|
+
|
235
|
+
def test_satisfied_by_boxed
|
236
|
+
refute_satisfied_by "1.3", "~> 1.4"
|
237
|
+
assert_satisfied_by "1.4", "~> 1.4"
|
238
|
+
assert_satisfied_by "1.5", "~> 1.4"
|
239
|
+
refute_satisfied_by "2.0", "~> 1.4"
|
240
|
+
|
241
|
+
refute_satisfied_by "1.3", "~> 1.4.4"
|
242
|
+
refute_satisfied_by "1.4", "~> 1.4.4"
|
243
|
+
assert_satisfied_by "1.4.4", "~> 1.4.4"
|
244
|
+
assert_satisfied_by "1.4.5", "~> 1.4.4"
|
245
|
+
refute_satisfied_by "1.5", "~> 1.4.4"
|
246
|
+
refute_satisfied_by "2.0", "~> 1.4.4"
|
247
|
+
end
|
248
|
+
|
249
|
+
def test_bad
|
250
|
+
refute_satisfied_by "", "> 0.1"
|
251
|
+
refute_satisfied_by "1.2.3", "!= 1.2.3"
|
252
|
+
refute_satisfied_by "1.2.003.0.0", "!= 1.02.3"
|
253
|
+
refute_satisfied_by "4.5.6", "< 1.2.3"
|
254
|
+
refute_satisfied_by "1.0", "> 1.1"
|
255
|
+
refute_satisfied_by "", "= 0.1"
|
256
|
+
refute_satisfied_by "1.1.1", "> 1.1.1"
|
257
|
+
refute_satisfied_by "1.2", "= 1.1"
|
258
|
+
refute_satisfied_by "1.40", "= 1.1"
|
259
|
+
refute_satisfied_by "1.3", "= 1.40"
|
260
|
+
refute_satisfied_by "9.3.3", "<= 9.3.2"
|
261
|
+
refute_satisfied_by "9.3.1", ">= 9.3.2"
|
262
|
+
refute_satisfied_by "9.3.03", "<= 9.3.2"
|
263
|
+
refute_satisfied_by "1.0.0.1", "= 1.0"
|
264
|
+
end
|
265
|
+
|
266
|
+
# Assert that two requirements are equal. Handles LibGems::Requirements,
|
267
|
+
# strings, arrays, numbers, and versions.
|
268
|
+
|
269
|
+
def assert_requirement_equal expected, actual
|
270
|
+
assert_equal req(expected), req(actual)
|
271
|
+
end
|
272
|
+
|
273
|
+
# Assert that +version+ satisfies +requirement+.
|
274
|
+
|
275
|
+
def assert_satisfied_by version, requirement
|
276
|
+
assert req(requirement).satisfied_by?(v(version)),
|
277
|
+
"#{requirement} is satisfied by #{version}"
|
278
|
+
end
|
279
|
+
|
280
|
+
# Refute the assumption that two requirements are equal.
|
281
|
+
|
282
|
+
def refute_requirement_equal unexpected, actual
|
283
|
+
refute_equal req(unexpected), req(actual)
|
284
|
+
end
|
285
|
+
|
286
|
+
# Refute the assumption that +version+ satisfies +requirement+.
|
287
|
+
|
288
|
+
def refute_satisfied_by version, requirement
|
289
|
+
refute req(requirement).satisfied_by?(v(version)),
|
290
|
+
"#{requirement} is not satisfied by #{version}"
|
291
|
+
end
|
292
|
+
end
|
@@ -0,0 +1,356 @@
|
|
1
|
+
require File.expand_path('../gemutilities', __FILE__)
|
2
|
+
require 'libgems/server'
|
3
|
+
require 'stringio'
|
4
|
+
|
5
|
+
class LibGems::Server
|
6
|
+
attr_accessor :source_index
|
7
|
+
attr_reader :server
|
8
|
+
end
|
9
|
+
|
10
|
+
class TestGemServer < RubyGemTestCase
|
11
|
+
|
12
|
+
def setup
|
13
|
+
super
|
14
|
+
|
15
|
+
@a1 = quick_gem 'a', '1'
|
16
|
+
@a2 = quick_gem 'a', '2'
|
17
|
+
|
18
|
+
@server = LibGems::Server.new LibGems.dir, process_based_port, false
|
19
|
+
@req = WEBrick::HTTPRequest.new :Logger => nil
|
20
|
+
@res = WEBrick::HTTPResponse.new :HTTPVersion => '1.0'
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_spec_dirs
|
24
|
+
s = LibGems::Server.new LibGems.dir, process_based_port, false
|
25
|
+
|
26
|
+
assert_equal [File.join(LibGems.dir, 'specifications')], s.spec_dirs
|
27
|
+
|
28
|
+
s = LibGems::Server.new [LibGems.dir, LibGems.dir], process_based_port, false
|
29
|
+
|
30
|
+
assert_equal [File.join(LibGems.dir, 'specifications'),
|
31
|
+
File.join(LibGems.dir, 'specifications')], s.spec_dirs
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_Marshal
|
35
|
+
data = StringIO.new "GET /Marshal.#{LibGems.marshal_version} HTTP/1.0\r\n\r\n"
|
36
|
+
@req.parse data
|
37
|
+
|
38
|
+
@server.Marshal @req, @res
|
39
|
+
|
40
|
+
assert_equal 200, @res.status, @res.body
|
41
|
+
assert_match %r| \d\d:\d\d:\d\d |, @res['date']
|
42
|
+
assert_equal 'application/octet-stream', @res['content-type']
|
43
|
+
|
44
|
+
si = LibGems::SourceIndex.new
|
45
|
+
si.add_specs @a1, @a2
|
46
|
+
|
47
|
+
assert_equal si, Marshal.load(@res.body)
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_Marshal_Z
|
51
|
+
data = StringIO.new "GET /Marshal.#{LibGems.marshal_version}.Z HTTP/1.0\r\n\r\n"
|
52
|
+
@req.parse data
|
53
|
+
|
54
|
+
@server.Marshal @req, @res
|
55
|
+
|
56
|
+
assert_equal 200, @res.status, @res.body
|
57
|
+
assert_match %r| \d\d:\d\d:\d\d |, @res['date']
|
58
|
+
assert_equal 'application/x-deflate', @res['content-type']
|
59
|
+
|
60
|
+
si = LibGems::SourceIndex.new
|
61
|
+
si.add_specs @a1, @a2
|
62
|
+
|
63
|
+
assert_equal si, Marshal.load(LibGems.inflate(@res.body))
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_latest_specs
|
67
|
+
data = StringIO.new "GET /latest_specs.#{LibGems.marshal_version} HTTP/1.0\r\n\r\n"
|
68
|
+
@req.parse data
|
69
|
+
|
70
|
+
@server.latest_specs @req, @res
|
71
|
+
|
72
|
+
assert_equal 200, @res.status, @res.body
|
73
|
+
assert_match %r| \d\d:\d\d:\d\d |, @res['date']
|
74
|
+
assert_equal 'application/octet-stream', @res['content-type']
|
75
|
+
assert_equal [['a', LibGems::Version.new(2), LibGems::Platform::RUBY]],
|
76
|
+
Marshal.load(@res.body)
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_latest_specs_gz
|
80
|
+
data = StringIO.new "GET /latest_specs.#{LibGems.marshal_version}.gz HTTP/1.0\r\n\r\n"
|
81
|
+
@req.parse data
|
82
|
+
|
83
|
+
@server.latest_specs @req, @res
|
84
|
+
|
85
|
+
assert_equal 200, @res.status, @res.body
|
86
|
+
assert_match %r| \d\d:\d\d:\d\d |, @res['date']
|
87
|
+
assert_equal 'application/x-gzip', @res['content-type']
|
88
|
+
assert_equal [['a', LibGems::Version.new(2), LibGems::Platform::RUBY]],
|
89
|
+
Marshal.load(LibGems.gunzip(@res.body))
|
90
|
+
end
|
91
|
+
|
92
|
+
def test_listen
|
93
|
+
util_listen
|
94
|
+
|
95
|
+
out, err = capture_io do
|
96
|
+
@server.listen
|
97
|
+
end
|
98
|
+
|
99
|
+
assert_equal 1, @server.server.listeners.length
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_listen_addresses
|
103
|
+
util_listen
|
104
|
+
|
105
|
+
out, err = capture_io do
|
106
|
+
@server.listen %w[a b]
|
107
|
+
end
|
108
|
+
|
109
|
+
assert_equal 2, @server.server.listeners.length
|
110
|
+
end
|
111
|
+
|
112
|
+
def test_quick_a_1_gemspec_rz
|
113
|
+
data = StringIO.new "GET /quick/a-1.gemspec.rz HTTP/1.0\r\n\r\n"
|
114
|
+
@req.parse data
|
115
|
+
|
116
|
+
@server.quick @req, @res
|
117
|
+
|
118
|
+
assert_equal 200, @res.status, @res.body
|
119
|
+
assert @res['date']
|
120
|
+
assert_equal 'application/x-deflate', @res['content-type']
|
121
|
+
|
122
|
+
spec = YAML.load LibGems.inflate(@res.body)
|
123
|
+
assert_equal 'a', spec.name
|
124
|
+
assert_equal LibGems::Version.new(1), spec.version
|
125
|
+
end
|
126
|
+
|
127
|
+
def test_quick_a_1_mswin32_gemspec_rz
|
128
|
+
a1_p = quick_gem 'a', '1' do |s| s.platform = LibGems::Platform.local end
|
129
|
+
|
130
|
+
data = StringIO.new "GET /quick/a-1-#{LibGems::Platform.local}.gemspec.rz HTTP/1.0\r\n\r\n"
|
131
|
+
@req.parse data
|
132
|
+
|
133
|
+
@server.quick @req, @res
|
134
|
+
|
135
|
+
assert_equal 200, @res.status, @res.body
|
136
|
+
assert @res['date']
|
137
|
+
assert_equal 'application/x-deflate', @res['content-type']
|
138
|
+
|
139
|
+
spec = YAML.load LibGems.inflate(@res.body)
|
140
|
+
assert_equal 'a', spec.name
|
141
|
+
assert_equal LibGems::Version.new(1), spec.version
|
142
|
+
assert_equal LibGems::Platform.local, spec.platform
|
143
|
+
end
|
144
|
+
|
145
|
+
def test_quick_common_substrings
|
146
|
+
ab1 = quick_gem 'ab', '1'
|
147
|
+
|
148
|
+
data = StringIO.new "GET /quick/a-1.gemspec.rz HTTP/1.0\r\n\r\n"
|
149
|
+
@req.parse data
|
150
|
+
|
151
|
+
@server.quick @req, @res
|
152
|
+
|
153
|
+
assert_equal 200, @res.status, @res.body
|
154
|
+
assert @res['date']
|
155
|
+
assert_equal 'application/x-deflate', @res['content-type']
|
156
|
+
|
157
|
+
spec = YAML.load LibGems.inflate(@res.body)
|
158
|
+
assert_equal 'a', spec.name
|
159
|
+
assert_equal LibGems::Version.new(1), spec.version
|
160
|
+
end
|
161
|
+
|
162
|
+
def test_quick_index
|
163
|
+
data = StringIO.new "GET /quick/index HTTP/1.0\r\n\r\n"
|
164
|
+
@req.parse data
|
165
|
+
|
166
|
+
@server.quick @req, @res
|
167
|
+
|
168
|
+
assert_equal 200, @res.status, @res.body
|
169
|
+
assert_match %r| \d\d:\d\d:\d\d |, @res['date']
|
170
|
+
assert_equal 'text/plain', @res['content-type']
|
171
|
+
assert_equal "a-1\na-2", @res.body
|
172
|
+
end
|
173
|
+
|
174
|
+
def test_quick_index_rz
|
175
|
+
data = StringIO.new "GET /quick/index.rz HTTP/1.0\r\n\r\n"
|
176
|
+
@req.parse data
|
177
|
+
|
178
|
+
@server.quick @req, @res
|
179
|
+
|
180
|
+
assert_equal 200, @res.status, @res.body
|
181
|
+
assert_match %r| \d\d:\d\d:\d\d |, @res['date']
|
182
|
+
assert_equal 'application/x-deflate', @res['content-type']
|
183
|
+
assert_equal "a-1\na-2", LibGems.inflate(@res.body)
|
184
|
+
end
|
185
|
+
|
186
|
+
def test_quick_latest_index
|
187
|
+
data = StringIO.new "GET /quick/latest_index HTTP/1.0\r\n\r\n"
|
188
|
+
@req.parse data
|
189
|
+
|
190
|
+
@server.quick @req, @res
|
191
|
+
|
192
|
+
assert_equal 200, @res.status, @res.body
|
193
|
+
assert_match %r| \d\d:\d\d:\d\d |, @res['date']
|
194
|
+
assert_equal 'text/plain', @res['content-type']
|
195
|
+
assert_equal 'a-2', @res.body
|
196
|
+
end
|
197
|
+
|
198
|
+
def test_quick_latest_index_rz
|
199
|
+
data = StringIO.new "GET /quick/latest_index.rz HTTP/1.0\r\n\r\n"
|
200
|
+
@req.parse data
|
201
|
+
|
202
|
+
@server.quick @req, @res
|
203
|
+
|
204
|
+
assert_equal 200, @res.status, @res.body
|
205
|
+
assert_match %r| \d\d:\d\d:\d\d |, @res['date']
|
206
|
+
assert_equal 'application/x-deflate', @res['content-type']
|
207
|
+
assert_equal 'a-2', LibGems.inflate(@res.body)
|
208
|
+
end
|
209
|
+
|
210
|
+
def test_quick_missing
|
211
|
+
data = StringIO.new "GET /quick/z-9.gemspec.rz HTTP/1.0\r\n\r\n"
|
212
|
+
@req.parse data
|
213
|
+
|
214
|
+
@server.quick @req, @res
|
215
|
+
|
216
|
+
assert_equal 404, @res.status, @res.body
|
217
|
+
assert_match %r| \d\d:\d\d:\d\d |, @res['date']
|
218
|
+
assert_equal 'text/plain', @res['content-type']
|
219
|
+
assert_equal 'No gems found matching "z" "9" nil', @res.body
|
220
|
+
assert_equal 404, @res.status
|
221
|
+
end
|
222
|
+
|
223
|
+
def test_quick_marshal_a_1_gemspec_rz
|
224
|
+
data = StringIO.new "GET /quick/Marshal.#{LibGems.marshal_version}/a-1.gemspec.rz HTTP/1.0\r\n\r\n"
|
225
|
+
@req.parse data
|
226
|
+
|
227
|
+
@server.quick @req, @res
|
228
|
+
|
229
|
+
assert_equal 200, @res.status, @res.body
|
230
|
+
assert @res['date']
|
231
|
+
assert_equal 'application/x-deflate', @res['content-type']
|
232
|
+
|
233
|
+
spec = Marshal.load LibGems.inflate(@res.body)
|
234
|
+
assert_equal 'a', spec.name
|
235
|
+
assert_equal LibGems::Version.new(1), spec.version
|
236
|
+
end
|
237
|
+
|
238
|
+
def test_quick_marshal_a_1_mswin32_gemspec_rz
|
239
|
+
a1_p = quick_gem 'a', '1' do |s| s.platform = LibGems::Platform.local end
|
240
|
+
|
241
|
+
data = StringIO.new "GET /quick/Marshal.#{LibGems.marshal_version}/a-1-#{LibGems::Platform.local}.gemspec.rz HTTP/1.0\r\n\r\n"
|
242
|
+
@req.parse data
|
243
|
+
|
244
|
+
@server.quick @req, @res
|
245
|
+
|
246
|
+
assert_equal 200, @res.status, @res.body
|
247
|
+
assert @res['date']
|
248
|
+
assert_equal 'application/x-deflate', @res['content-type']
|
249
|
+
|
250
|
+
spec = Marshal.load LibGems.inflate(@res.body)
|
251
|
+
assert_equal 'a', spec.name
|
252
|
+
assert_equal LibGems::Version.new(1), spec.version
|
253
|
+
assert_equal LibGems::Platform.local, spec.platform
|
254
|
+
end
|
255
|
+
|
256
|
+
def test_rdoc
|
257
|
+
data = StringIO.new "GET /rdoc?q=a HTTP/1.0\r\n\r\n"
|
258
|
+
@req.parse data
|
259
|
+
|
260
|
+
@server.rdoc @req, @res
|
261
|
+
|
262
|
+
assert_equal 200, @res.status, @res.body
|
263
|
+
assert_match %r|No documentation found|, @res.body
|
264
|
+
assert_equal 'text/html', @res['content-type']
|
265
|
+
end
|
266
|
+
|
267
|
+
def test_root
|
268
|
+
data = StringIO.new "GET / HTTP/1.0\r\n\r\n"
|
269
|
+
@req.parse data
|
270
|
+
|
271
|
+
@server.root @req, @res
|
272
|
+
|
273
|
+
assert_equal 200, @res.status, @res.body
|
274
|
+
assert_match %r| \d\d:\d\d:\d\d |, @res['date']
|
275
|
+
assert_equal 'text/html', @res['content-type']
|
276
|
+
end
|
277
|
+
|
278
|
+
def test_specs
|
279
|
+
data = StringIO.new "GET /specs.#{LibGems.marshal_version} HTTP/1.0\r\n\r\n"
|
280
|
+
@req.parse data
|
281
|
+
|
282
|
+
@server.specs @req, @res
|
283
|
+
|
284
|
+
assert_equal 200, @res.status, @res.body
|
285
|
+
assert_match %r| \d\d:\d\d:\d\d |, @res['date']
|
286
|
+
assert_equal 'application/octet-stream', @res['content-type']
|
287
|
+
|
288
|
+
assert_equal [['a', LibGems::Version.new(1), LibGems::Platform::RUBY],
|
289
|
+
['a', LibGems::Version.new(2), LibGems::Platform::RUBY]],
|
290
|
+
Marshal.load(@res.body)
|
291
|
+
end
|
292
|
+
|
293
|
+
def test_specs_gz
|
294
|
+
data = StringIO.new "GET /specs.#{LibGems.marshal_version}.gz HTTP/1.0\r\n\r\n"
|
295
|
+
@req.parse data
|
296
|
+
|
297
|
+
@server.specs @req, @res
|
298
|
+
|
299
|
+
assert_equal 200, @res.status, @res.body
|
300
|
+
assert_match %r| \d\d:\d\d:\d\d |, @res['date']
|
301
|
+
assert_equal 'application/x-gzip', @res['content-type']
|
302
|
+
|
303
|
+
assert_equal [['a', LibGems::Version.new(1), LibGems::Platform::RUBY],
|
304
|
+
['a', LibGems::Version.new(2), LibGems::Platform::RUBY]],
|
305
|
+
Marshal.load(LibGems.gunzip(@res.body))
|
306
|
+
end
|
307
|
+
|
308
|
+
def test_yaml
|
309
|
+
data = StringIO.new "GET /yaml.#{LibGems.marshal_version} HTTP/1.0\r\n\r\n"
|
310
|
+
@req.parse data
|
311
|
+
|
312
|
+
@server.yaml @req, @res
|
313
|
+
|
314
|
+
assert_equal 200, @res.status, @res.body
|
315
|
+
assert_match %r| \d\d:\d\d:\d\d |, @res['date']
|
316
|
+
assert_equal 'text/plain', @res['content-type']
|
317
|
+
|
318
|
+
si = LibGems::SourceIndex.new
|
319
|
+
si.add_specs @a1, @a2
|
320
|
+
|
321
|
+
assert_equal si, YAML.load(@res.body)
|
322
|
+
end
|
323
|
+
|
324
|
+
def test_yaml_Z
|
325
|
+
data = StringIO.new "GET /yaml.#{LibGems.marshal_version}.Z HTTP/1.0\r\n\r\n"
|
326
|
+
@req.parse data
|
327
|
+
|
328
|
+
@server.yaml @req, @res
|
329
|
+
|
330
|
+
assert_equal 200, @res.status, @res.body
|
331
|
+
assert_match %r| \d\d:\d\d:\d\d |, @res['date']
|
332
|
+
assert_equal 'application/x-deflate', @res['content-type']
|
333
|
+
|
334
|
+
si = LibGems::SourceIndex.new
|
335
|
+
si.add_specs @a1, @a2
|
336
|
+
|
337
|
+
assert_equal si, YAML.load(LibGems.inflate(@res.body))
|
338
|
+
end
|
339
|
+
|
340
|
+
def util_listen
|
341
|
+
webrick = Object.new
|
342
|
+
webrick.instance_variable_set :@listeners, []
|
343
|
+
def webrick.listeners() @listeners end
|
344
|
+
def webrick.listen(host, port)
|
345
|
+
socket = Object.new
|
346
|
+
socket.instance_variable_set :@host, host
|
347
|
+
socket.instance_variable_set :@port, port
|
348
|
+
def socket.addr() [nil, @port, @host] end
|
349
|
+
@listeners << socket
|
350
|
+
end
|
351
|
+
|
352
|
+
@server.instance_variable_set :@server, webrick
|
353
|
+
end
|
354
|
+
|
355
|
+
end
|
356
|
+
|