slimgems 1.3.8
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 +120 -0
- data/bin/gem +25 -0
- data/bin/update_slimgems +35 -0
- data/bootstrap/Rakefile +4 -0
- data/hide_lib_for_update/note.txt +5 -0
- data/lib/gauntlet_rubygems.rb +50 -0
- data/lib/rbconfig/datadir.rb +20 -0
- data/lib/rubygems.rb +1220 -0
- data/lib/rubygems/builder.rb +102 -0
- data/lib/rubygems/command.rb +534 -0
- data/lib/rubygems/command_manager.rb +182 -0
- data/lib/rubygems/commands/build_command.rb +53 -0
- data/lib/rubygems/commands/cert_command.rb +86 -0
- data/lib/rubygems/commands/check_command.rb +80 -0
- data/lib/rubygems/commands/cleanup_command.rb +106 -0
- data/lib/rubygems/commands/contents_command.rb +98 -0
- data/lib/rubygems/commands/dependency_command.rb +195 -0
- data/lib/rubygems/commands/environment_command.rb +132 -0
- data/lib/rubygems/commands/fetch_command.rb +67 -0
- data/lib/rubygems/commands/generate_index_command.rb +133 -0
- data/lib/rubygems/commands/help_command.rb +172 -0
- data/lib/rubygems/commands/install_command.rb +178 -0
- data/lib/rubygems/commands/list_command.rb +35 -0
- data/lib/rubygems/commands/lock_command.rb +110 -0
- data/lib/rubygems/commands/mirror_command.rb +111 -0
- data/lib/rubygems/commands/outdated_command.rb +33 -0
- data/lib/rubygems/commands/owner_command.rb +75 -0
- data/lib/rubygems/commands/pristine_command.rb +93 -0
- data/lib/rubygems/commands/push_command.rb +56 -0
- data/lib/rubygems/commands/query_command.rb +280 -0
- data/lib/rubygems/commands/rdoc_command.rb +91 -0
- data/lib/rubygems/commands/search_command.rb +31 -0
- data/lib/rubygems/commands/server_command.rb +86 -0
- data/lib/rubygems/commands/setup_command.rb +387 -0
- data/lib/rubygems/commands/sources_command.rb +157 -0
- data/lib/rubygems/commands/specification_command.rb +125 -0
- data/lib/rubygems/commands/stale_command.rb +27 -0
- data/lib/rubygems/commands/uninstall_command.rb +83 -0
- data/lib/rubygems/commands/unpack_command.rb +121 -0
- data/lib/rubygems/commands/update_command.rb +212 -0
- data/lib/rubygems/commands/which_command.rb +86 -0
- data/lib/rubygems/config_file.rb +345 -0
- data/lib/rubygems/custom_require.rb +44 -0
- data/lib/rubygems/defaults.rb +101 -0
- data/lib/rubygems/dependency.rb +227 -0
- data/lib/rubygems/dependency_installer.rb +286 -0
- data/lib/rubygems/dependency_list.rb +208 -0
- data/lib/rubygems/doc_manager.rb +242 -0
- data/lib/rubygems/errors.rb +35 -0
- data/lib/rubygems/exceptions.rb +91 -0
- data/lib/rubygems/ext.rb +18 -0
- data/lib/rubygems/ext/builder.rb +56 -0
- data/lib/rubygems/ext/configure_builder.rb +25 -0
- data/lib/rubygems/ext/ext_conf_builder.rb +24 -0
- data/lib/rubygems/ext/rake_builder.rb +39 -0
- data/lib/rubygems/format.rb +81 -0
- data/lib/rubygems/gem_openssl.rb +92 -0
- data/lib/rubygems/gem_path_searcher.rb +100 -0
- data/lib/rubygems/gem_runner.rb +79 -0
- data/lib/rubygems/gemcutter_utilities.rb +49 -0
- data/lib/rubygems/indexer.rb +720 -0
- data/lib/rubygems/install_update_options.rb +125 -0
- data/lib/rubygems/installer.rb +604 -0
- data/lib/rubygems/local_remote_options.rb +135 -0
- data/lib/rubygems/old_format.rb +153 -0
- data/lib/rubygems/package.rb +97 -0
- data/lib/rubygems/package/f_sync_dir.rb +23 -0
- data/lib/rubygems/package/tar_header.rb +266 -0
- data/lib/rubygems/package/tar_input.rb +222 -0
- data/lib/rubygems/package/tar_output.rb +144 -0
- data/lib/rubygems/package/tar_reader.rb +106 -0
- data/lib/rubygems/package/tar_reader/entry.rb +141 -0
- data/lib/rubygems/package/tar_writer.rb +241 -0
- data/lib/rubygems/package_task.rb +126 -0
- data/lib/rubygems/platform.rb +183 -0
- data/lib/rubygems/remote_fetcher.rb +414 -0
- data/lib/rubygems/require_paths_builder.rb +18 -0
- data/lib/rubygems/requirement.rb +153 -0
- data/lib/rubygems/security.rb +814 -0
- data/lib/rubygems/server.rb +872 -0
- data/lib/rubygems/source_index.rb +597 -0
- data/lib/rubygems/source_info_cache.rb +395 -0
- data/lib/rubygems/source_info_cache_entry.rb +56 -0
- data/lib/rubygems/spec_fetcher.rb +337 -0
- data/lib/rubygems/specification.rb +1486 -0
- data/lib/rubygems/test_utilities.rb +147 -0
- data/lib/rubygems/text.rb +65 -0
- data/lib/rubygems/uninstaller.rb +278 -0
- data/lib/rubygems/user_interaction.rb +527 -0
- data/lib/rubygems/validator.rb +240 -0
- data/lib/rubygems/version.rb +316 -0
- data/lib/rubygems/version_option.rb +65 -0
- data/lib/ubygems.rb +10 -0
- data/setup.rb +42 -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/functional.rb +92 -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/rubygems_plugin.rb +2 -0
- data/test/plugin/load/rubygems_plugin.rb +1 -0
- data/test/plugin/standarderror/rubygems_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 +766 -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 +353 -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 +1291 -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 +413 -0
@@ -0,0 +1,218 @@
|
|
1
|
+
require File.expand_path('../gemutilities', __FILE__)
|
2
|
+
require 'rubygems/user_interaction'
|
3
|
+
require 'timeout'
|
4
|
+
|
5
|
+
class TestGemStreamUI < RubyGemTestCase
|
6
|
+
|
7
|
+
module IsTty
|
8
|
+
attr_accessor :tty
|
9
|
+
|
10
|
+
def tty?
|
11
|
+
@tty = true unless defined? @tty
|
12
|
+
return @tty
|
13
|
+
end
|
14
|
+
|
15
|
+
alias_method :isatty, :tty?
|
16
|
+
end
|
17
|
+
|
18
|
+
def setup
|
19
|
+
super
|
20
|
+
|
21
|
+
@cfg = Gem.configuration
|
22
|
+
|
23
|
+
@in = StringIO.new
|
24
|
+
@out = StringIO.new
|
25
|
+
@err = StringIO.new
|
26
|
+
|
27
|
+
@in.extend IsTty
|
28
|
+
@out.extend IsTty
|
29
|
+
|
30
|
+
@sui = Gem::StreamUI.new @in, @out, @err
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_ask
|
34
|
+
timeout(1) do
|
35
|
+
expected_answer = "Arthur, King of the Britons"
|
36
|
+
@in.string = "#{expected_answer}\n"
|
37
|
+
actual_answer = @sui.ask("What is your name?")
|
38
|
+
assert_equal expected_answer, actual_answer
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_ask_no_tty
|
43
|
+
@in.tty = false
|
44
|
+
|
45
|
+
timeout(0.1) do
|
46
|
+
answer = @sui.ask("what is your favorite color?")
|
47
|
+
assert_equal nil, answer
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_ask_for_password
|
52
|
+
skip 'Always uses $stdin on windows' if Gem.win_platform?
|
53
|
+
|
54
|
+
timeout(1) do
|
55
|
+
expected_answer = "Arthur, King of the Britons"
|
56
|
+
@in.string = "#{expected_answer}\n"
|
57
|
+
actual_answer = @sui.ask_for_password("What is your name?")
|
58
|
+
assert_equal expected_answer, actual_answer
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_ask_for_password_no_tty
|
63
|
+
@in.tty = false
|
64
|
+
|
65
|
+
timeout(0.1) do
|
66
|
+
answer = @sui.ask_for_password("what is the airspeed velocity of an unladen swallow?")
|
67
|
+
assert_equal nil, answer
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_ask_yes_no_no_tty_with_default
|
72
|
+
@in.tty = false
|
73
|
+
|
74
|
+
timeout(0.1) do
|
75
|
+
answer = @sui.ask_yes_no("do coconuts migrate?", false)
|
76
|
+
assert_equal false, answer
|
77
|
+
|
78
|
+
answer = @sui.ask_yes_no("do coconuts migrate?", true)
|
79
|
+
assert_equal true, answer
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_ask_yes_no_no_tty_without_default
|
84
|
+
@in.tty = false
|
85
|
+
|
86
|
+
timeout(0.1) do
|
87
|
+
assert_raises(Gem::OperationNotSupportedError) do
|
88
|
+
@sui.ask_yes_no("do coconuts migrate?")
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_choose_from_list
|
94
|
+
@in.puts "1"
|
95
|
+
@in.rewind
|
96
|
+
|
97
|
+
result = @sui.choose_from_list 'which one?', %w[foo bar]
|
98
|
+
|
99
|
+
assert_equal ['foo', 0], result
|
100
|
+
assert_equal "which one?\n 1. foo\n 2. bar\n> ", @out.string
|
101
|
+
end
|
102
|
+
|
103
|
+
def test_choose_from_list_EOF
|
104
|
+
result = @sui.choose_from_list 'which one?', %w[foo bar]
|
105
|
+
|
106
|
+
assert_equal [nil, nil], result
|
107
|
+
assert_equal "which one?\n 1. foo\n 2. bar\n> ", @out.string
|
108
|
+
end
|
109
|
+
|
110
|
+
def test_progress_reporter_silent_nil
|
111
|
+
@cfg.verbose = nil
|
112
|
+
reporter = @sui.progress_reporter 10, 'hi'
|
113
|
+
assert_kind_of Gem::StreamUI::SilentProgressReporter, reporter
|
114
|
+
end
|
115
|
+
|
116
|
+
def test_progress_reporter_silent_false
|
117
|
+
@cfg.verbose = false
|
118
|
+
reporter = @sui.progress_reporter 10, 'hi'
|
119
|
+
assert_kind_of Gem::StreamUI::SilentProgressReporter, reporter
|
120
|
+
assert_equal "", @out.string
|
121
|
+
end
|
122
|
+
|
123
|
+
def test_progress_reporter_simple
|
124
|
+
@cfg.verbose = true
|
125
|
+
reporter = @sui.progress_reporter 10, 'hi'
|
126
|
+
assert_kind_of Gem::StreamUI::SimpleProgressReporter, reporter
|
127
|
+
assert_equal "hi\n", @out.string
|
128
|
+
end
|
129
|
+
|
130
|
+
def test_progress_reporter_verbose
|
131
|
+
@cfg.verbose = 0
|
132
|
+
reporter = @sui.progress_reporter 10, 'hi'
|
133
|
+
assert_kind_of Gem::StreamUI::VerboseProgressReporter, reporter
|
134
|
+
assert_equal "hi\n", @out.string
|
135
|
+
end
|
136
|
+
|
137
|
+
def test_download_reporter_silent_nil
|
138
|
+
@cfg.verbose = nil
|
139
|
+
reporter = @sui.download_reporter
|
140
|
+
reporter.fetch 'a.gem', 1024
|
141
|
+
assert_kind_of Gem::StreamUI::SilentDownloadReporter, reporter
|
142
|
+
assert_equal "", @out.string
|
143
|
+
end
|
144
|
+
|
145
|
+
def test_download_reporter_silent_false
|
146
|
+
@cfg.verbose = false
|
147
|
+
reporter = @sui.download_reporter
|
148
|
+
reporter.fetch 'a.gem', 1024
|
149
|
+
assert_kind_of Gem::StreamUI::SilentDownloadReporter, reporter
|
150
|
+
assert_equal "", @out.string
|
151
|
+
end
|
152
|
+
|
153
|
+
def test_download_reporter_anything
|
154
|
+
@cfg.verbose = 0
|
155
|
+
reporter = @sui.download_reporter
|
156
|
+
assert_kind_of Gem::StreamUI::VerboseDownloadReporter, reporter
|
157
|
+
end
|
158
|
+
|
159
|
+
def test_verbose_download_reporter
|
160
|
+
@cfg.verbose = true
|
161
|
+
reporter = @sui.download_reporter
|
162
|
+
reporter.fetch 'a.gem', 1024
|
163
|
+
assert_equal "Fetching: a.gem", @out.string
|
164
|
+
end
|
165
|
+
|
166
|
+
def test_verbose_download_reporter_progress
|
167
|
+
@cfg.verbose = true
|
168
|
+
reporter = @sui.download_reporter
|
169
|
+
reporter.fetch 'a.gem', 1024
|
170
|
+
reporter.update 512
|
171
|
+
assert_equal "Fetching: a.gem\rFetching: a.gem ( 50%)", @out.string
|
172
|
+
end
|
173
|
+
|
174
|
+
def test_verbose_download_reporter_progress_once
|
175
|
+
@cfg.verbose = true
|
176
|
+
reporter = @sui.download_reporter
|
177
|
+
reporter.fetch 'a.gem', 1024
|
178
|
+
reporter.update 510
|
179
|
+
reporter.update 512
|
180
|
+
assert_equal "Fetching: a.gem\rFetching: a.gem ( 50%)", @out.string
|
181
|
+
end
|
182
|
+
|
183
|
+
def test_verbose_download_reporter_progress_complete
|
184
|
+
@cfg.verbose = true
|
185
|
+
reporter = @sui.download_reporter
|
186
|
+
reporter.fetch 'a.gem', 1024
|
187
|
+
reporter.update 510
|
188
|
+
reporter.done
|
189
|
+
assert_equal "Fetching: a.gem\rFetching: a.gem ( 50%)\rFetching: a.gem (100%)\n", @out.string
|
190
|
+
end
|
191
|
+
|
192
|
+
def test_verbose_download_reporter_progress_nil_length
|
193
|
+
@cfg.verbose = true
|
194
|
+
reporter = @sui.download_reporter
|
195
|
+
reporter.fetch 'a.gem', nil
|
196
|
+
reporter.update 1024
|
197
|
+
reporter.done
|
198
|
+
assert_equal "Fetching: a.gem\rFetching: a.gem (1024B)\rFetching: a.gem (1024B)\n", @out.string
|
199
|
+
end
|
200
|
+
|
201
|
+
def test_verbose_download_reporter_progress_zero_length
|
202
|
+
@cfg.verbose = true
|
203
|
+
reporter = @sui.download_reporter
|
204
|
+
reporter.fetch 'a.gem', 0
|
205
|
+
reporter.update 1024
|
206
|
+
reporter.done
|
207
|
+
assert_equal "Fetching: a.gem\rFetching: a.gem (1024B)\rFetching: a.gem (1024B)\n", @out.string
|
208
|
+
end
|
209
|
+
|
210
|
+
def test_verbose_download_reporter_no_tty
|
211
|
+
@out.tty = false
|
212
|
+
|
213
|
+
@cfg.verbose = true
|
214
|
+
reporter = @sui.download_reporter
|
215
|
+
reporter.fetch 'a.gem', 1024
|
216
|
+
assert_equal "", @out.string
|
217
|
+
end
|
218
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require File.expand_path('../gemutilities', __FILE__)
|
2
|
+
require "rubygems/text"
|
3
|
+
|
4
|
+
class TestGemText < RubyGemTestCase
|
5
|
+
include Gem::Text
|
6
|
+
|
7
|
+
def test_format_text
|
8
|
+
assert_equal "text to\nwrap", format_text("text to wrap", 8)
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_format_text_indent
|
12
|
+
assert_equal " text to\n wrap", format_text("text to wrap", 8, 2)
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_format_text_none
|
16
|
+
assert_equal "text to wrap", format_text("text to wrap", 40)
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_format_text_none_indent
|
20
|
+
assert_equal " text to wrap", format_text("text to wrap", 40, 2)
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_levenshtein_distance_add
|
24
|
+
assert_equal 2, levenshtein_distance("zentest", "zntst")
|
25
|
+
assert_equal 2, levenshtein_distance("zntst", "zentest")
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_levenshtein_distance_empty
|
29
|
+
assert_equal 5, levenshtein_distance("abcde", "")
|
30
|
+
assert_equal 5, levenshtein_distance("", "abcde")
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_levenshtein_distance_remove
|
34
|
+
assert_equal 3, levenshtein_distance("zentest", "zentestxxx")
|
35
|
+
assert_equal 3, levenshtein_distance("zentestxxx", "zentest")
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_levenshtein_distance_replace
|
39
|
+
assert_equal 2, levenshtein_distance("zentest", "ZenTest")
|
40
|
+
assert_equal 7, levenshtein_distance("xxxxxxx", "ZenTest")
|
41
|
+
assert_equal 7, levenshtein_distance("zentest", "xxxxxxx")
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,146 @@
|
|
1
|
+
require File.expand_path('../gem_installer_test_case', __FILE__)
|
2
|
+
require 'rubygems/uninstaller'
|
3
|
+
|
4
|
+
class TestGemUninstaller < GemInstallerTestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
super
|
8
|
+
|
9
|
+
ui = MockGemUi.new
|
10
|
+
util_setup_gem ui
|
11
|
+
|
12
|
+
@user_spec.executables = ["my_exec"]
|
13
|
+
|
14
|
+
# HACK util_make_exec
|
15
|
+
user_bin_dir = File.join Gem.user_dir, 'gems', @user_spec.full_name, 'bin'
|
16
|
+
FileUtils.mkdir_p user_bin_dir
|
17
|
+
exec_path = File.join user_bin_dir, "my_exec"
|
18
|
+
File.open exec_path, 'w' do |f|
|
19
|
+
f.puts "#!/usr/bin/ruby"
|
20
|
+
end
|
21
|
+
|
22
|
+
user_bin_dir = File.join Gem.user_dir, 'bin'
|
23
|
+
FileUtils.mkdir_p user_bin_dir
|
24
|
+
exec_path = File.join user_bin_dir, "my_exec"
|
25
|
+
File.open exec_path, 'w' do |f|
|
26
|
+
f.puts "#!/usr/bin/ruby"
|
27
|
+
end
|
28
|
+
|
29
|
+
build_rake_in do
|
30
|
+
use_ui ui do
|
31
|
+
@installer.install
|
32
|
+
@user_installer.install
|
33
|
+
Gem::Uninstaller.new(@user_spec.name, :executables => false).uninstall
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_initialize_expand_path
|
39
|
+
uninstaller = Gem::Uninstaller.new nil, :install_dir => '/foo//bar'
|
40
|
+
|
41
|
+
assert_match %r|/foo/bar$|, uninstaller.instance_variable_get(:@gem_home)
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_remove_executables_force_keep
|
45
|
+
uninstaller = Gem::Uninstaller.new nil, :executables => false
|
46
|
+
|
47
|
+
use_ui @ui do
|
48
|
+
uninstaller.remove_executables @spec
|
49
|
+
end
|
50
|
+
|
51
|
+
assert_equal true, File.exist?(File.join(@gemhome, 'bin', 'executable'))
|
52
|
+
|
53
|
+
assert_equal "Executables and scripts will remain installed.\n", @ui.output
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_remove_executables_force_remove
|
57
|
+
uninstaller = Gem::Uninstaller.new nil, :executables => true
|
58
|
+
|
59
|
+
use_ui @ui do
|
60
|
+
uninstaller.remove_executables @spec
|
61
|
+
end
|
62
|
+
|
63
|
+
assert_equal "Removing executable\n", @ui.output
|
64
|
+
|
65
|
+
assert_equal false, File.exist?(File.join(@gemhome, 'bin', 'executable'))
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_remove_executables_user
|
69
|
+
uninstaller = Gem::Uninstaller.new nil, :executables => true
|
70
|
+
|
71
|
+
use_ui @ui do
|
72
|
+
uninstaller.remove_executables @user_spec
|
73
|
+
end
|
74
|
+
|
75
|
+
exec_path = File.join Gem.user_dir, 'bin', 'my_exec'
|
76
|
+
assert_equal false, File.exist?(exec_path), 'removed exec from bin dir'
|
77
|
+
|
78
|
+
assert_equal "Removing my_exec\n", @ui.output
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_path_ok_eh
|
82
|
+
uninstaller = Gem::Uninstaller.new nil
|
83
|
+
|
84
|
+
assert_equal true, uninstaller.path_ok?(@gemhome, @spec)
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_path_ok_eh_legacy
|
88
|
+
uninstaller = Gem::Uninstaller.new nil
|
89
|
+
|
90
|
+
@spec.loaded_from.gsub! @spec.full_name, '\&-legacy'
|
91
|
+
@spec.platform = 'legacy'
|
92
|
+
|
93
|
+
assert_equal true, uninstaller.path_ok?(@gemhome, @spec)
|
94
|
+
end
|
95
|
+
|
96
|
+
def test_path_ok_eh_user
|
97
|
+
uninstaller = Gem::Uninstaller.new nil
|
98
|
+
|
99
|
+
assert_equal true, uninstaller.path_ok?(Gem.user_dir, @user_spec)
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_uninstall
|
103
|
+
uninstaller = Gem::Uninstaller.new @spec.name, :executables => true
|
104
|
+
|
105
|
+
gem_dir = File.join @gemhome, 'gems', @spec.full_name
|
106
|
+
|
107
|
+
Gem.pre_uninstall do
|
108
|
+
assert File.exist?(gem_dir), 'gem_dir should exist'
|
109
|
+
end
|
110
|
+
|
111
|
+
Gem.post_uninstall do
|
112
|
+
refute File.exist?(gem_dir), 'gem_dir should not exist'
|
113
|
+
end
|
114
|
+
|
115
|
+
uninstaller.uninstall
|
116
|
+
|
117
|
+
refute File.exist?(gem_dir)
|
118
|
+
|
119
|
+
assert_same uninstaller, @pre_uninstall_hook_arg
|
120
|
+
assert_same uninstaller, @post_uninstall_hook_arg
|
121
|
+
end
|
122
|
+
|
123
|
+
def test_uninstall_user
|
124
|
+
uninstaller = Gem::Uninstaller.new @user_spec.name, :executables => true,
|
125
|
+
:user_install => true
|
126
|
+
|
127
|
+
gem_dir = File.join Gem.user_dir, 'gems', @user_spec.full_name
|
128
|
+
|
129
|
+
Gem.pre_uninstall do
|
130
|
+
assert File.exist?(gem_dir), 'gem_dir should exist'
|
131
|
+
end
|
132
|
+
|
133
|
+
Gem.post_uninstall do
|
134
|
+
refute File.exist?(gem_dir), 'gem_dir should not exist'
|
135
|
+
end
|
136
|
+
|
137
|
+
uninstaller.uninstall
|
138
|
+
|
139
|
+
refute File.exist?(gem_dir)
|
140
|
+
|
141
|
+
assert_same uninstaller, @pre_uninstall_hook_arg
|
142
|
+
assert_same uninstaller, @post_uninstall_hook_arg
|
143
|
+
end
|
144
|
+
|
145
|
+
end
|
146
|
+
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require File.expand_path('../gemutilities', __FILE__)
|
2
|
+
require File.expand_path('../simple_gem', __FILE__)
|
3
|
+
require 'rubygems/validator'
|
4
|
+
|
5
|
+
class TestGemValidator < RubyGemTestCase
|
6
|
+
|
7
|
+
def setup
|
8
|
+
super
|
9
|
+
|
10
|
+
@simple_gem = SIMPLE_GEM
|
11
|
+
@validator = Gem::Validator.new
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_verify_gem_file
|
15
|
+
gem_file = File.join @tempdir, 'simple_gem.gem'
|
16
|
+
File.open gem_file, 'wb' do |fp| fp.write @simple_gem end
|
17
|
+
|
18
|
+
assert_equal nil, @validator.verify_gem_file(gem_file)
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_verify_gem_file_empty
|
22
|
+
e = assert_raises Gem::VerificationError do
|
23
|
+
@validator.verify_gem_file ''
|
24
|
+
end
|
25
|
+
|
26
|
+
assert_equal 'missing gem file ', e.message
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_verify_gem_file_nonexistent
|
30
|
+
file = '/nonexistent/nonexistent.gem'
|
31
|
+
e = assert_raises Gem::VerificationError do
|
32
|
+
@validator.verify_gem_file file
|
33
|
+
end
|
34
|
+
|
35
|
+
assert_equal "missing gem file #{file}", e.message
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_verify_gem
|
39
|
+
assert_equal nil, @validator.verify_gem(@simple_gem)
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_verify_gem_empty
|
43
|
+
e = assert_raises Gem::VerificationError do
|
44
|
+
@validator.verify_gem ''
|
45
|
+
end
|
46
|
+
|
47
|
+
assert_equal 'empty gem file', e.message
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_verify_gem_invalid_checksum
|
51
|
+
e = assert_raises Gem::VerificationError do
|
52
|
+
@validator.verify_gem @simple_gem.upcase
|
53
|
+
end
|
54
|
+
|
55
|
+
assert_equal 'invalid checksum for gem file', e.message
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_verify_gem_no_sum
|
59
|
+
assert_equal nil, @validator.verify_gem('words')
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|