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,199 @@
|
|
1
|
+
require File.expand_path('../gemutilities', __FILE__)
|
2
|
+
require 'rubygems/commands/unpack_command'
|
3
|
+
|
4
|
+
class TestGemCommandsUnpackCommand < RubyGemTestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
super
|
8
|
+
|
9
|
+
Dir.chdir @tempdir do
|
10
|
+
@cmd = Gem::Commands::UnpackCommand.new
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_find_in_cache
|
15
|
+
util_make_gems
|
16
|
+
|
17
|
+
assert_equal(
|
18
|
+
@cmd.find_in_cache(@a1.file_name),
|
19
|
+
File.join(@gemhome, 'cache', @a1.file_name),
|
20
|
+
'found a-1.gem in the cache'
|
21
|
+
)
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_get_path
|
25
|
+
util_make_gems
|
26
|
+
util_setup_fake_fetcher
|
27
|
+
util_setup_spec_fetcher @a1
|
28
|
+
|
29
|
+
a1_data = nil
|
30
|
+
|
31
|
+
open File.join(@gemhome, 'cache', @a1.file_name), 'rb' do |fp|
|
32
|
+
a1_data = fp.read
|
33
|
+
end
|
34
|
+
|
35
|
+
Gem::RemoteFetcher.fetcher.data['http://gems.example.com/gems/a-1.gem'] =
|
36
|
+
a1_data
|
37
|
+
|
38
|
+
dep = Gem::Dependency.new(@a1.name, @a1.version)
|
39
|
+
assert_equal(
|
40
|
+
@cmd.get_path(dep),
|
41
|
+
File.join(@gemhome, 'cache', @a1.file_name),
|
42
|
+
'fetches a-1 and returns the cache path'
|
43
|
+
)
|
44
|
+
|
45
|
+
FileUtils.rm File.join(@gemhome, 'cache', @a1.file_name)
|
46
|
+
|
47
|
+
assert_equal(
|
48
|
+
@cmd.get_path(dep),
|
49
|
+
File.join(@gemhome, 'cache', @a1.file_name),
|
50
|
+
'when removed from cache, refetches a-1'
|
51
|
+
)
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_execute
|
55
|
+
util_make_gems
|
56
|
+
|
57
|
+
@cmd.options[:args] = %w[a b]
|
58
|
+
|
59
|
+
use_ui @ui do
|
60
|
+
Dir.chdir @tempdir do
|
61
|
+
@cmd.execute
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
assert File.exist?(File.join(@tempdir, 'a-3.a')), 'a should be unpacked'
|
66
|
+
assert File.exist?(File.join(@tempdir, 'b-2')), 'b should be unpacked'
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_execute_gem_path
|
70
|
+
util_make_gems
|
71
|
+
|
72
|
+
Gem.clear_paths
|
73
|
+
|
74
|
+
gemhome2 = File.join @tempdir, 'gemhome2'
|
75
|
+
|
76
|
+
Gem.send :set_paths, [gemhome2, @gemhome].join(File::PATH_SEPARATOR)
|
77
|
+
Gem.send :set_home, gemhome2
|
78
|
+
|
79
|
+
@cmd.options[:args] = %w[a]
|
80
|
+
|
81
|
+
use_ui @ui do
|
82
|
+
Dir.chdir @tempdir do
|
83
|
+
@cmd.execute
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
assert File.exist?(File.join(@tempdir, 'a-3.a'))
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_execute_gem_path_missing
|
91
|
+
util_make_gems
|
92
|
+
util_setup_spec_fetcher
|
93
|
+
|
94
|
+
Gem.clear_paths
|
95
|
+
|
96
|
+
gemhome2 = File.join @tempdir, 'gemhome2'
|
97
|
+
|
98
|
+
Gem.send :set_paths, [gemhome2, @gemhome].join(File::PATH_SEPARATOR)
|
99
|
+
Gem.send :set_home, gemhome2
|
100
|
+
|
101
|
+
@cmd.options[:args] = %w[z]
|
102
|
+
|
103
|
+
use_ui @ui do
|
104
|
+
Dir.chdir @tempdir do
|
105
|
+
@cmd.execute
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
assert_equal '', @ui.output
|
110
|
+
end
|
111
|
+
|
112
|
+
def test_execute_remote
|
113
|
+
util_setup_fake_fetcher
|
114
|
+
util_setup_spec_fetcher @a1, @a2
|
115
|
+
util_clear_gems
|
116
|
+
|
117
|
+
a2_data = nil
|
118
|
+
open File.join(@gemhome, 'cache', @a2.file_name), 'rb' do |fp|
|
119
|
+
a2_data = fp.read
|
120
|
+
end
|
121
|
+
|
122
|
+
Gem::RemoteFetcher.fetcher.data['http://gems.example.com/gems/a-2.gem'] =
|
123
|
+
a2_data
|
124
|
+
|
125
|
+
Gem.configuration.verbose = :really
|
126
|
+
@cmd.options[:args] = %w[a]
|
127
|
+
|
128
|
+
use_ui @ui do
|
129
|
+
Dir.chdir @tempdir do
|
130
|
+
@cmd.execute
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
assert File.exist?(File.join(@tempdir, 'a-2')), 'a should be unpacked'
|
135
|
+
end
|
136
|
+
|
137
|
+
def test_execute_sudo
|
138
|
+
util_make_gems
|
139
|
+
|
140
|
+
File.chmod 0555, @gemhome
|
141
|
+
|
142
|
+
@cmd.options[:args] = %w[b]
|
143
|
+
|
144
|
+
use_ui @ui do
|
145
|
+
Dir.chdir @tempdir do
|
146
|
+
@cmd.execute
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
assert File.exist?(File.join(@tempdir, 'b-2')), 'b should be unpacked'
|
151
|
+
ensure
|
152
|
+
File.chmod 0755, @gemhome
|
153
|
+
end
|
154
|
+
|
155
|
+
def test_execute_with_target_option
|
156
|
+
util_make_gems
|
157
|
+
|
158
|
+
target = 'with_target'
|
159
|
+
@cmd.options[:args] = %w[a]
|
160
|
+
@cmd.options[:target] = target
|
161
|
+
|
162
|
+
use_ui @ui do
|
163
|
+
Dir.chdir @tempdir do
|
164
|
+
@cmd.execute
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
assert File.exist?(File.join(@tempdir, target, 'a-3.a'))
|
169
|
+
end
|
170
|
+
|
171
|
+
def test_execute_exact_match
|
172
|
+
foo_spec = quick_gem 'foo'
|
173
|
+
foo_bar_spec = quick_gem 'foo_bar'
|
174
|
+
|
175
|
+
use_ui @ui do
|
176
|
+
Dir.chdir @tempdir do
|
177
|
+
Gem::Builder.new(foo_spec).build
|
178
|
+
Gem::Builder.new(foo_bar_spec).build
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
foo_path = File.join(@tempdir, "#{foo_spec.full_name}.gem")
|
183
|
+
foo_bar_path = File.join(@tempdir, "#{foo_bar_spec.full_name}.gem")
|
184
|
+
Gem::Installer.new(foo_path).install
|
185
|
+
Gem::Installer.new(foo_bar_path).install
|
186
|
+
|
187
|
+
@cmd.options[:args] = %w[foo]
|
188
|
+
|
189
|
+
use_ui @ui do
|
190
|
+
Dir.chdir @tempdir do
|
191
|
+
@cmd.execute
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
assert File.exist?(File.join(@tempdir, foo_spec.full_name))
|
196
|
+
end
|
197
|
+
|
198
|
+
end
|
199
|
+
|
@@ -0,0 +1,353 @@
|
|
1
|
+
require File.expand_path('../gemutilities', __FILE__)
|
2
|
+
require 'rubygems/commands/update_command'
|
3
|
+
|
4
|
+
class TestGemCommandsUpdateCommand < RubyGemTestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
super
|
8
|
+
|
9
|
+
@oldpath = Dir.pwd
|
10
|
+
Dir.chdir(File.dirname(__FILE__))
|
11
|
+
|
12
|
+
@cmd = Gem::Commands::UpdateCommand.new
|
13
|
+
|
14
|
+
@cmd.options[:generate_rdoc] = false
|
15
|
+
@cmd.options[:generate_ri] = false
|
16
|
+
|
17
|
+
util_setup_fake_fetcher
|
18
|
+
|
19
|
+
@a1_path = File.join @gemhome, 'cache', @a1.file_name
|
20
|
+
@a2_path = File.join @gemhome, 'cache', @a2.file_name
|
21
|
+
|
22
|
+
util_setup_spec_fetcher @a1, @a2
|
23
|
+
|
24
|
+
@fetcher.data["#{@gem_repo}gems/#{@a1.file_name}"] =
|
25
|
+
read_binary @a1_path
|
26
|
+
@fetcher.data["#{@gem_repo}gems/#{@a2.file_name}"] =
|
27
|
+
read_binary @a2_path
|
28
|
+
end
|
29
|
+
|
30
|
+
def teardown
|
31
|
+
super
|
32
|
+
Dir.chdir(@oldpath)
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_execute
|
36
|
+
util_clear_gems
|
37
|
+
|
38
|
+
Gem::Installer.new(@a1_path).install
|
39
|
+
|
40
|
+
@cmd.options[:args] = []
|
41
|
+
@cmd.options[:generate_rdoc] = true
|
42
|
+
@cmd.options[:generate_ri] = true
|
43
|
+
|
44
|
+
use_ui @ui do
|
45
|
+
@cmd.execute
|
46
|
+
end
|
47
|
+
|
48
|
+
out = @ui.output.split "\n"
|
49
|
+
assert_match "Updating installed gems", out.shift
|
50
|
+
assert_match "Updating #{@a2.name}", out.shift
|
51
|
+
assert_match "Successfully installed #{@a2.full_name}", out.shift
|
52
|
+
assert_match "Gems updated: #{@a2.name}", out.shift
|
53
|
+
assert_match "Installing ri documentation for a-2...", out.join
|
54
|
+
assert_match "Installing RDoc documentation for a-2...", out.join
|
55
|
+
end
|
56
|
+
|
57
|
+
def util_setup_rubygem version
|
58
|
+
gem = quick_gem(Gem::GEM_NAME, version.to_s) do |s|
|
59
|
+
s.files = %w[setup.rb]
|
60
|
+
end
|
61
|
+
write_file File.join(*%W[gems #{gem.original_name} setup.rb])
|
62
|
+
util_build_gem gem
|
63
|
+
util_setup_spec_fetcher gem
|
64
|
+
gem
|
65
|
+
end
|
66
|
+
|
67
|
+
def util_setup_rubygem8
|
68
|
+
@rubygem8 = util_setup_rubygem 8
|
69
|
+
end
|
70
|
+
|
71
|
+
def util_setup_rubygem9
|
72
|
+
@rubygem9 = util_setup_rubygem 9
|
73
|
+
end
|
74
|
+
|
75
|
+
def util_setup_rubygem_current
|
76
|
+
@rubygem_current = util_setup_rubygem Gem::VERSION
|
77
|
+
end
|
78
|
+
|
79
|
+
def util_add_to_fetcher *specs
|
80
|
+
specs.each do |spec|
|
81
|
+
gem_file = File.join @gemhome, 'cache', spec.file_name
|
82
|
+
|
83
|
+
@fetcher.data["http://gems.example.com/gems/#{spec.file_name}"] =
|
84
|
+
Gem.read_binary gem_file
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def test_execute_system
|
89
|
+
util_setup_rubygem9
|
90
|
+
util_setup_spec_fetcher @rubygem9
|
91
|
+
util_add_to_fetcher @rubygem9
|
92
|
+
util_clear_gems
|
93
|
+
|
94
|
+
@cmd.options[:args] = []
|
95
|
+
@cmd.options[:system] = true
|
96
|
+
@cmd.options[:generate_rdoc] = false
|
97
|
+
@cmd.options[:generate_ri] = false
|
98
|
+
|
99
|
+
use_ui @ui do
|
100
|
+
@cmd.execute
|
101
|
+
end
|
102
|
+
|
103
|
+
out = @ui.output.split "\n"
|
104
|
+
assert_equal "Updating #{Gem::GEM_NAME}", out.shift
|
105
|
+
assert_equal "Successfully installed #{Gem::GEM_NAME}-9", out.shift
|
106
|
+
assert_equal "#{Gem::NAME} system software updated (9)", out.shift
|
107
|
+
|
108
|
+
assert_empty out
|
109
|
+
end
|
110
|
+
|
111
|
+
def test_execute_system_at_latest
|
112
|
+
util_setup_rubygem_current
|
113
|
+
util_setup_spec_fetcher @rubygem_current
|
114
|
+
util_add_to_fetcher @rubygem_current
|
115
|
+
util_clear_gems
|
116
|
+
|
117
|
+
@cmd.options[:args] = []
|
118
|
+
@cmd.options[:system] = true
|
119
|
+
@cmd.options[:generate_rdoc] = false
|
120
|
+
@cmd.options[:generate_ri] = false
|
121
|
+
|
122
|
+
assert_raises Gem::SystemExitException do
|
123
|
+
use_ui @ui do
|
124
|
+
@cmd.execute
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
out = @ui.output.split "\n"
|
129
|
+
assert_equal "#{Gem::NAME} is already up-to-date (#{Gem::VERSION})", out.shift
|
130
|
+
assert_empty out
|
131
|
+
end
|
132
|
+
|
133
|
+
def test_execute_system_multiple
|
134
|
+
util_setup_rubygem9
|
135
|
+
util_setup_rubygem8
|
136
|
+
util_setup_spec_fetcher @rubygem8, @rubygem9
|
137
|
+
util_add_to_fetcher @rubygem8, @rubygem9
|
138
|
+
util_clear_gems
|
139
|
+
|
140
|
+
@cmd.options[:args] = []
|
141
|
+
@cmd.options[:system] = true
|
142
|
+
@cmd.options[:generate_rdoc] = false
|
143
|
+
@cmd.options[:generate_ri] = false
|
144
|
+
|
145
|
+
use_ui @ui do
|
146
|
+
@cmd.execute
|
147
|
+
end
|
148
|
+
|
149
|
+
out = @ui.output.split "\n"
|
150
|
+
assert_equal "Updating #{Gem::GEM_NAME}", out.shift
|
151
|
+
assert_equal "Successfully installed #{Gem::GEM_NAME}-9", out.shift
|
152
|
+
assert_equal "#{Gem::NAME} system software updated (9)", out.shift
|
153
|
+
|
154
|
+
assert_empty out
|
155
|
+
end
|
156
|
+
|
157
|
+
def test_execute_system_specific
|
158
|
+
util_clear_gems
|
159
|
+
util_setup_rubygem9
|
160
|
+
util_setup_rubygem8
|
161
|
+
util_setup_spec_fetcher @rubygem8, @rubygem9
|
162
|
+
util_add_to_fetcher @rubygem8, @rubygem9
|
163
|
+
|
164
|
+
@cmd.options[:args] = []
|
165
|
+
@cmd.options[:system] = "8"
|
166
|
+
@cmd.options[:generate_rdoc] = false
|
167
|
+
@cmd.options[:generate_ri] = false
|
168
|
+
|
169
|
+
use_ui @ui do
|
170
|
+
@cmd.execute
|
171
|
+
end
|
172
|
+
|
173
|
+
out = @ui.output.split "\n"
|
174
|
+
assert_equal "Updating #{Gem::GEM_NAME}", out.shift
|
175
|
+
assert_equal "Successfully installed #{Gem::GEM_NAME}-8", out.shift
|
176
|
+
assert_equal "#{Gem::NAME} system software updated (8)", out.shift
|
177
|
+
|
178
|
+
assert_empty out
|
179
|
+
end
|
180
|
+
|
181
|
+
def test_execute_system_with_gems
|
182
|
+
@cmd.options[:args] = %w[gem]
|
183
|
+
@cmd.options[:system] = true
|
184
|
+
@cmd.options[:generate_rdoc] = false
|
185
|
+
@cmd.options[:generate_ri] = false
|
186
|
+
|
187
|
+
assert_raises MockGemUi::TermError do
|
188
|
+
use_ui @ui do
|
189
|
+
@cmd.execute
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
assert_empty @ui.output
|
194
|
+
assert_equal "ERROR: Gem names are not allowed with the --system option\n",
|
195
|
+
@ui.error
|
196
|
+
end
|
197
|
+
|
198
|
+
# before:
|
199
|
+
# a1 -> c1.2
|
200
|
+
# after:
|
201
|
+
# a2 -> b2 # new dependency
|
202
|
+
# a2 -> c2
|
203
|
+
|
204
|
+
def test_execute_dependencies
|
205
|
+
@a1.add_dependency 'c', '1.2'
|
206
|
+
|
207
|
+
@c2 = quick_gem 'c', '2' do |s|
|
208
|
+
s.files = %w[lib/code.rb]
|
209
|
+
s.require_paths = %w[lib]
|
210
|
+
end
|
211
|
+
|
212
|
+
@a2.add_dependency 'c', '2'
|
213
|
+
@a2.add_dependency 'b', '2'
|
214
|
+
|
215
|
+
@b2_path = File.join @gemhome, 'cache', @b2.file_name
|
216
|
+
@c1_2_path = File.join @gemhome, 'cache', @c1_2.file_name
|
217
|
+
@c2_path = File.join @gemhome, 'cache', @c2.file_name
|
218
|
+
|
219
|
+
@source_index = Gem::SourceIndex.new
|
220
|
+
@source_index.add_spec @a1
|
221
|
+
@source_index.add_spec @a2
|
222
|
+
@source_index.add_spec @b2
|
223
|
+
@source_index.add_spec @c1_2
|
224
|
+
@source_index.add_spec @c2
|
225
|
+
|
226
|
+
util_build_gem @a1
|
227
|
+
util_build_gem @a2
|
228
|
+
util_build_gem @c2
|
229
|
+
|
230
|
+
@fetcher.data["#{@gem_repo}gems/#{@a1.file_name}"] = read_binary @a1_path
|
231
|
+
@fetcher.data["#{@gem_repo}gems/#{@a2.file_name}"] = read_binary @a2_path
|
232
|
+
@fetcher.data["#{@gem_repo}gems/#{@b2.file_name}"] = read_binary @b2_path
|
233
|
+
@fetcher.data["#{@gem_repo}gems/#{@c1_2.file_name}"] =
|
234
|
+
read_binary @c1_2_path
|
235
|
+
@fetcher.data["#{@gem_repo}gems/#{@c2.file_name}"] = read_binary @c2_path
|
236
|
+
|
237
|
+
util_setup_spec_fetcher @a1, @a2, @b2, @c1_2, @c2
|
238
|
+
util_clear_gems
|
239
|
+
|
240
|
+
Gem::Installer.new(@c1_2_path).install
|
241
|
+
Gem::Installer.new(@a1_path).install
|
242
|
+
|
243
|
+
@cmd.options[:args] = []
|
244
|
+
|
245
|
+
use_ui @ui do
|
246
|
+
@cmd.execute
|
247
|
+
end
|
248
|
+
|
249
|
+
out = @ui.output.split "\n"
|
250
|
+
assert_equal "Updating installed gems", out.shift
|
251
|
+
assert_equal "Updating #{@a2.name}", out.shift
|
252
|
+
assert_equal "Successfully installed #{@c2.full_name}", out.shift
|
253
|
+
assert_equal "Successfully installed #{@b2.full_name}", out.shift
|
254
|
+
assert_equal "Successfully installed #{@a2.full_name}", out.shift
|
255
|
+
assert_equal "Gems updated: #{@c2.name}, #{@b2.name}, #{@a2.name}",
|
256
|
+
out.shift
|
257
|
+
|
258
|
+
assert_empty out
|
259
|
+
end
|
260
|
+
|
261
|
+
def test_execute_named
|
262
|
+
util_clear_gems
|
263
|
+
|
264
|
+
Gem::Installer.new(@a1_path).install
|
265
|
+
|
266
|
+
@cmd.options[:args] = [@a1.name]
|
267
|
+
|
268
|
+
use_ui @ui do
|
269
|
+
@cmd.execute
|
270
|
+
end
|
271
|
+
|
272
|
+
out = @ui.output.split "\n"
|
273
|
+
assert_equal "Updating installed gems", out.shift
|
274
|
+
assert_equal "Updating #{@a2.name}", out.shift
|
275
|
+
assert_equal "Successfully installed #{@a2.full_name}", out.shift
|
276
|
+
assert_equal "Gems updated: #{@a2.name}", out.shift
|
277
|
+
|
278
|
+
assert_empty out
|
279
|
+
end
|
280
|
+
|
281
|
+
def test_execute_named_up_to_date
|
282
|
+
util_clear_gems
|
283
|
+
|
284
|
+
Gem::Installer.new(@a2_path).install
|
285
|
+
|
286
|
+
@cmd.options[:args] = [@a2.name]
|
287
|
+
|
288
|
+
use_ui @ui do
|
289
|
+
@cmd.execute
|
290
|
+
end
|
291
|
+
|
292
|
+
out = @ui.output.split "\n"
|
293
|
+
assert_equal "Updating installed gems", out.shift
|
294
|
+
assert_equal "Nothing to update", out.shift
|
295
|
+
|
296
|
+
assert_empty out
|
297
|
+
end
|
298
|
+
|
299
|
+
def test_execute_up_to_date
|
300
|
+
util_clear_gems
|
301
|
+
|
302
|
+
Gem::Installer.new(@a2_path).install
|
303
|
+
|
304
|
+
@cmd.options[:args] = []
|
305
|
+
|
306
|
+
use_ui @ui do
|
307
|
+
@cmd.execute
|
308
|
+
end
|
309
|
+
|
310
|
+
out = @ui.output.split "\n"
|
311
|
+
assert_equal "Updating installed gems", out.shift
|
312
|
+
assert_equal "Nothing to update", out.shift
|
313
|
+
|
314
|
+
assert_empty out
|
315
|
+
end
|
316
|
+
|
317
|
+
def test_handle_options_system
|
318
|
+
@cmd.handle_options %w[--system]
|
319
|
+
|
320
|
+
expected = {
|
321
|
+
:generate_ri => true,
|
322
|
+
:system => true,
|
323
|
+
:force => false,
|
324
|
+
:args => [],
|
325
|
+
:generate_rdoc => true,
|
326
|
+
:test => false,
|
327
|
+
}
|
328
|
+
|
329
|
+
assert_equal expected, @cmd.options
|
330
|
+
end
|
331
|
+
|
332
|
+
def test_handle_options_system_non_version
|
333
|
+
assert_raises ArgumentError do
|
334
|
+
@cmd.handle_options %w[--system non-version]
|
335
|
+
end
|
336
|
+
end
|
337
|
+
|
338
|
+
def test_handle_options_system_specific
|
339
|
+
@cmd.handle_options %w[--system 1.3.7]
|
340
|
+
|
341
|
+
expected = {
|
342
|
+
:generate_ri => true,
|
343
|
+
:system => "1.3.7",
|
344
|
+
:force => false,
|
345
|
+
:args => [],
|
346
|
+
:generate_rdoc => true,
|
347
|
+
:test => false,
|
348
|
+
}
|
349
|
+
|
350
|
+
assert_equal expected, @cmd.options
|
351
|
+
end
|
352
|
+
|
353
|
+
end
|