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,209 @@
|
|
1
|
+
require File.expand_path('../gemutilities', __FILE__)
|
2
|
+
require 'libgems/commands/sources_command'
|
3
|
+
|
4
|
+
class TestGemCommandsSourcesCommand < RubyGemTestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
super
|
8
|
+
|
9
|
+
@cmd = LibGems::Commands::SourcesCommand.new
|
10
|
+
|
11
|
+
@new_repo = "http://beta-gems.example.com"
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_initialize_proxy
|
15
|
+
assert @cmd.handles?(['--http-proxy', 'http://proxy.example.com'])
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_execute
|
19
|
+
util_setup_spec_fetcher
|
20
|
+
@cmd.handle_options []
|
21
|
+
|
22
|
+
use_ui @ui do
|
23
|
+
@cmd.execute
|
24
|
+
end
|
25
|
+
|
26
|
+
expected = <<-EOF
|
27
|
+
*** CURRENT SOURCES ***
|
28
|
+
|
29
|
+
#{@gem_repo}
|
30
|
+
EOF
|
31
|
+
|
32
|
+
assert_equal expected, @ui.output
|
33
|
+
assert_equal '', @ui.error
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_execute_add
|
37
|
+
util_setup_fake_fetcher
|
38
|
+
|
39
|
+
si = LibGems::SourceIndex.new
|
40
|
+
si.add_spec @a1
|
41
|
+
|
42
|
+
specs = si.map do |_, spec|
|
43
|
+
[spec.name, spec.version, spec.original_platform]
|
44
|
+
end
|
45
|
+
|
46
|
+
specs_dump_gz = StringIO.new
|
47
|
+
Zlib::GzipWriter.wrap specs_dump_gz do |io|
|
48
|
+
Marshal.dump specs, io
|
49
|
+
end
|
50
|
+
|
51
|
+
@fetcher.data["#{@new_repo}/specs.#{@marshal_version}.gz"] =
|
52
|
+
specs_dump_gz.string
|
53
|
+
|
54
|
+
@cmd.handle_options %W[--add #{@new_repo}]
|
55
|
+
|
56
|
+
util_setup_spec_fetcher
|
57
|
+
|
58
|
+
use_ui @ui do
|
59
|
+
@cmd.execute
|
60
|
+
end
|
61
|
+
|
62
|
+
assert_equal [@gem_repo, @new_repo], LibGems.sources
|
63
|
+
|
64
|
+
expected = <<-EOF
|
65
|
+
#{@new_repo} added to sources
|
66
|
+
EOF
|
67
|
+
|
68
|
+
assert_equal expected, @ui.output
|
69
|
+
assert_equal '', @ui.error
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_execute_add_nonexistent_source
|
73
|
+
util_setup_fake_fetcher
|
74
|
+
|
75
|
+
uri = "http://beta-gems.example.com/specs.#{@marshal_version}.gz"
|
76
|
+
@fetcher.data[uri] = proc do
|
77
|
+
raise LibGems::RemoteFetcher::FetchError.new('it died', uri)
|
78
|
+
end
|
79
|
+
|
80
|
+
LibGems::RemoteFetcher.fetcher = @fetcher
|
81
|
+
|
82
|
+
@cmd.handle_options %w[--add http://beta-gems.example.com]
|
83
|
+
|
84
|
+
util_setup_spec_fetcher
|
85
|
+
|
86
|
+
use_ui @ui do
|
87
|
+
@cmd.execute
|
88
|
+
end
|
89
|
+
|
90
|
+
expected = <<-EOF
|
91
|
+
Error fetching http://beta-gems.example.com:
|
92
|
+
\tit died (#{uri})
|
93
|
+
EOF
|
94
|
+
|
95
|
+
assert_equal expected, @ui.output
|
96
|
+
assert_equal '', @ui.error
|
97
|
+
end
|
98
|
+
|
99
|
+
def test_execute_add_bad_uri
|
100
|
+
@cmd.handle_options %w[--add beta-gems.example.com]
|
101
|
+
|
102
|
+
util_setup_spec_fetcher
|
103
|
+
|
104
|
+
use_ui @ui do
|
105
|
+
@cmd.execute
|
106
|
+
end
|
107
|
+
|
108
|
+
assert_equal [@gem_repo], LibGems.sources
|
109
|
+
|
110
|
+
expected = <<-EOF
|
111
|
+
beta-gems.example.com is not a URI
|
112
|
+
EOF
|
113
|
+
|
114
|
+
assert_equal expected, @ui.output
|
115
|
+
assert_equal '', @ui.error
|
116
|
+
end
|
117
|
+
|
118
|
+
def test_execute_clear_all
|
119
|
+
@cmd.handle_options %w[--clear-all]
|
120
|
+
|
121
|
+
util_setup_spec_fetcher
|
122
|
+
|
123
|
+
fetcher = LibGems::SpecFetcher.fetcher
|
124
|
+
|
125
|
+
# HACK figure out how to force directory creation via fetcher
|
126
|
+
#assert File.directory?(fetcher.dir), 'cache dir exists'
|
127
|
+
|
128
|
+
use_ui @ui do
|
129
|
+
@cmd.execute
|
130
|
+
end
|
131
|
+
|
132
|
+
expected = <<-EOF
|
133
|
+
*** Removed specs cache ***
|
134
|
+
*** Removed user source cache ***
|
135
|
+
*** Removed latest user source cache ***
|
136
|
+
*** Removed system source cache ***
|
137
|
+
*** Removed latest system source cache ***
|
138
|
+
EOF
|
139
|
+
|
140
|
+
assert_equal expected, @ui.output
|
141
|
+
assert_equal '', @ui.error
|
142
|
+
|
143
|
+
refute File.exist?(fetcher.dir), 'cache dir removed'
|
144
|
+
end
|
145
|
+
|
146
|
+
def test_execute_remove
|
147
|
+
@cmd.handle_options %W[--remove #{@gem_repo}]
|
148
|
+
|
149
|
+
util_setup_spec_fetcher
|
150
|
+
|
151
|
+
use_ui @ui do
|
152
|
+
@cmd.execute
|
153
|
+
end
|
154
|
+
|
155
|
+
expected = "#{@gem_repo} removed from sources\n"
|
156
|
+
|
157
|
+
assert_equal expected, @ui.output
|
158
|
+
assert_equal '', @ui.error
|
159
|
+
end
|
160
|
+
|
161
|
+
def test_execute_remove_no_network
|
162
|
+
@cmd.handle_options %W[--remove #{@gem_repo}]
|
163
|
+
|
164
|
+
util_setup_fake_fetcher
|
165
|
+
|
166
|
+
@fetcher.data["#{@gem_repo}Marshal.#{LibGems.marshal_version}"] = proc do
|
167
|
+
raise LibGems::RemoteFetcher::FetchError
|
168
|
+
end
|
169
|
+
|
170
|
+
use_ui @ui do
|
171
|
+
@cmd.execute
|
172
|
+
end
|
173
|
+
|
174
|
+
expected = "#{@gem_repo} removed from sources\n"
|
175
|
+
|
176
|
+
assert_equal expected, @ui.output
|
177
|
+
assert_equal '', @ui.error
|
178
|
+
end
|
179
|
+
|
180
|
+
def test_execute_update
|
181
|
+
@cmd.handle_options %w[--update]
|
182
|
+
|
183
|
+
util_setup_fake_fetcher
|
184
|
+
source_index = util_setup_spec_fetcher @a1
|
185
|
+
|
186
|
+
specs = source_index.map do |name, spec|
|
187
|
+
[spec.name, spec.version, spec.original_platform]
|
188
|
+
end
|
189
|
+
|
190
|
+
@fetcher.data["#{@gem_repo}specs.#{LibGems.marshal_version}.gz"] =
|
191
|
+
util_gzip Marshal.dump(specs)
|
192
|
+
|
193
|
+
latest_specs = source_index.latest_specs.map do |spec|
|
194
|
+
[spec.name, spec.version, spec.original_platform]
|
195
|
+
end
|
196
|
+
|
197
|
+
@fetcher.data["#{@gem_repo}latest_specs.#{LibGems.marshal_version}.gz"] =
|
198
|
+
util_gzip Marshal.dump(latest_specs)
|
199
|
+
|
200
|
+
use_ui @ui do
|
201
|
+
@cmd.execute
|
202
|
+
end
|
203
|
+
|
204
|
+
assert_equal "source cache successfully updated\n", @ui.output
|
205
|
+
assert_equal '', @ui.error
|
206
|
+
end
|
207
|
+
|
208
|
+
end
|
209
|
+
|
@@ -0,0 +1,139 @@
|
|
1
|
+
require File.expand_path('../gemutilities', __FILE__)
|
2
|
+
require 'libgems/commands/specification_command'
|
3
|
+
|
4
|
+
class TestGemCommandsSpecificationCommand < RubyGemTestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
super
|
8
|
+
|
9
|
+
@cmd = LibGems::Commands::SpecificationCommand.new
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_execute
|
13
|
+
foo = quick_gem 'foo'
|
14
|
+
LibGems.source_index.add_spec foo
|
15
|
+
|
16
|
+
@cmd.options[:args] = %w[foo]
|
17
|
+
|
18
|
+
use_ui @ui do
|
19
|
+
@cmd.execute
|
20
|
+
end
|
21
|
+
|
22
|
+
assert_match %r|LibGems::Specification|, @ui.output
|
23
|
+
assert_match %r|name: foo|, @ui.output
|
24
|
+
assert_equal '', @ui.error
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_execute_all
|
28
|
+
foo1 = quick_gem 'foo', '0.0.1'
|
29
|
+
foo2 = quick_gem 'foo', '0.0.2'
|
30
|
+
|
31
|
+
@cmd.options[:args] = %w[foo]
|
32
|
+
@cmd.options[:all] = true
|
33
|
+
|
34
|
+
use_ui @ui do
|
35
|
+
@cmd.execute
|
36
|
+
end
|
37
|
+
|
38
|
+
assert_match %r|LibGems::Specification|, @ui.output
|
39
|
+
assert_match %r|name: foo|, @ui.output
|
40
|
+
assert_match %r|version: 0.0.1|, @ui.output
|
41
|
+
assert_match %r|version: 0.0.2|, @ui.output
|
42
|
+
assert_equal '', @ui.error
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_execute_bad_name
|
46
|
+
@cmd.options[:args] = %w[foo]
|
47
|
+
|
48
|
+
assert_raises MockGemUi::TermError do
|
49
|
+
use_ui @ui do
|
50
|
+
@cmd.execute
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
assert_equal '', @ui.output
|
55
|
+
assert_equal "ERROR: Unknown gem 'foo'\n", @ui.error
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_execute_exact_match
|
59
|
+
foo = quick_gem 'foo'
|
60
|
+
foo_bar = quick_gem 'foo_bar'
|
61
|
+
|
62
|
+
@cmd.options[:args] = %w[foo]
|
63
|
+
|
64
|
+
use_ui @ui do
|
65
|
+
@cmd.execute
|
66
|
+
end
|
67
|
+
|
68
|
+
assert_match %r|LibGems::Specification|, @ui.output
|
69
|
+
assert_match %r|name: foo|, @ui.output
|
70
|
+
assert_equal '', @ui.error
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_execute_field
|
74
|
+
foo = quick_gem 'foo'
|
75
|
+
LibGems.source_index.add_spec foo
|
76
|
+
|
77
|
+
@cmd.options[:args] = %w[foo name]
|
78
|
+
|
79
|
+
use_ui @ui do
|
80
|
+
@cmd.execute
|
81
|
+
end
|
82
|
+
|
83
|
+
assert_equal "foo", YAML.load(@ui.output)
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_execute_marshal
|
87
|
+
foo = quick_gem 'foo'
|
88
|
+
LibGems.source_index.add_spec foo
|
89
|
+
|
90
|
+
@cmd.options[:args] = %w[foo]
|
91
|
+
@cmd.options[:format] = :marshal
|
92
|
+
|
93
|
+
use_ui @ui do
|
94
|
+
@cmd.execute
|
95
|
+
end
|
96
|
+
|
97
|
+
assert_equal foo, Marshal.load(@ui.output)
|
98
|
+
assert_equal '', @ui.error
|
99
|
+
end
|
100
|
+
|
101
|
+
def test_execute_remote
|
102
|
+
foo = quick_gem 'foo'
|
103
|
+
|
104
|
+
@fetcher = LibGems::FakeFetcher.new
|
105
|
+
LibGems::RemoteFetcher.fetcher = @fetcher
|
106
|
+
|
107
|
+
util_setup_spec_fetcher foo
|
108
|
+
|
109
|
+
FileUtils.rm File.join(@gemhome, 'specifications', foo.spec_name)
|
110
|
+
|
111
|
+
@cmd.options[:args] = %w[foo]
|
112
|
+
@cmd.options[:domain] = :remote
|
113
|
+
|
114
|
+
use_ui @ui do
|
115
|
+
@cmd.execute
|
116
|
+
end
|
117
|
+
|
118
|
+
assert_match %r|\A--- !ruby/object:LibGems::Specification|, @ui.output
|
119
|
+
assert_match %r|name: foo|, @ui.output
|
120
|
+
end
|
121
|
+
|
122
|
+
def test_execute_ruby
|
123
|
+
foo = quick_gem 'foo'
|
124
|
+
LibGems.source_index.add_spec foo
|
125
|
+
|
126
|
+
@cmd.options[:args] = %w[foo]
|
127
|
+
@cmd.options[:format] = :ruby
|
128
|
+
|
129
|
+
use_ui @ui do
|
130
|
+
@cmd.execute
|
131
|
+
end
|
132
|
+
|
133
|
+
assert_match %r|LibGems::Specification.new|, @ui.output
|
134
|
+
assert_match %r|s.name = %q\{foo\}|, @ui.output
|
135
|
+
assert_equal '', @ui.error
|
136
|
+
end
|
137
|
+
|
138
|
+
end
|
139
|
+
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require File.expand_path('../gemutilities', __FILE__)
|
2
|
+
require 'libgems/commands/stale_command'
|
3
|
+
|
4
|
+
class TestGemCommandsStaleCommand < RubyGemTestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
super
|
8
|
+
@cmd = LibGems::Commands::StaleCommand.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_execute_sorts
|
12
|
+
files = %w[lib/foo_bar.rb Rakefile]
|
13
|
+
foo_bar = quick_gem 'foo_bar' do |gem|
|
14
|
+
gem.files = files
|
15
|
+
end
|
16
|
+
bar_baz = quick_gem 'bar_baz' do |gem|
|
17
|
+
gem.files = files
|
18
|
+
end
|
19
|
+
|
20
|
+
files.each do |file|
|
21
|
+
filename = bar_baz.full_gem_path + "/#{file}"
|
22
|
+
FileUtils.mkdir_p(File.dirname(filename))
|
23
|
+
FileUtils.touch(filename, :mtime => Time.now)
|
24
|
+
|
25
|
+
filename = foo_bar.full_gem_path + "/#{file}"
|
26
|
+
FileUtils.mkdir_p(File.dirname(filename))
|
27
|
+
FileUtils.touch(filename, :mtime => Time.now - 86400)
|
28
|
+
end
|
29
|
+
|
30
|
+
use_ui @ui do
|
31
|
+
@cmd.execute
|
32
|
+
end
|
33
|
+
lines = @ui.output.split("\n")
|
34
|
+
assert_equal("#{foo_bar.name}-#{foo_bar.version}", lines[0].split.first)
|
35
|
+
assert_equal("#{bar_baz.name}-#{bar_baz.version}", lines[1].split.first)
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
require File.expand_path('../gemutilities', __FILE__)
|
2
|
+
require File.expand_path('../gem_installer_test_case', __FILE__)
|
3
|
+
require 'libgems/commands/uninstall_command'
|
4
|
+
|
5
|
+
class TestGemCommandsUninstallCommand < LibGemsInstallerTestCase
|
6
|
+
|
7
|
+
def setup
|
8
|
+
super
|
9
|
+
|
10
|
+
ui = MockGemUi.new
|
11
|
+
util_setup_gem ui
|
12
|
+
|
13
|
+
build_rake_in do
|
14
|
+
use_ui ui do
|
15
|
+
@installer.install
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
@cmd = LibGems::Commands::UninstallCommand.new
|
20
|
+
@cmd.options[:executables] = true
|
21
|
+
@executable = File.join(@gemhome, 'bin', 'executable')
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_execute_removes_executable
|
25
|
+
if win_platform?
|
26
|
+
assert_equal true, File.exist?(@executable)
|
27
|
+
else
|
28
|
+
assert_equal true, File.symlink?(@executable)
|
29
|
+
end
|
30
|
+
|
31
|
+
# Evil hack to prevent false removal success
|
32
|
+
FileUtils.rm_f @executable
|
33
|
+
File.open(@executable, "wb+") {|f| f.puts "binary"}
|
34
|
+
|
35
|
+
@cmd.options[:args] = Array(@spec.name)
|
36
|
+
use_ui @ui do
|
37
|
+
@cmd.execute
|
38
|
+
end
|
39
|
+
|
40
|
+
output = @ui.output.split "\n"
|
41
|
+
assert_match(/Removing executable/, output.shift)
|
42
|
+
assert_match(/Successfully uninstalled/, output.shift)
|
43
|
+
assert_equal false, File.exist?(@executable)
|
44
|
+
assert_nil output.shift, "UI output should have contained only two lines"
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_execute_not_installed
|
48
|
+
@cmd.options[:args] = ["foo"]
|
49
|
+
e = assert_raises LibGems::InstallError do
|
50
|
+
use_ui @ui do
|
51
|
+
@cmd.execute
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
assert_match(/\Acannot uninstall, check `gem list -d foo`$/, e.message)
|
56
|
+
output = @ui.output.split "\n"
|
57
|
+
assert_empty output, "UI output should be empty after an uninstall error"
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_execute_prerelease
|
61
|
+
@spec = quick_gem "pre", "2.b"
|
62
|
+
@gem = File.join @tempdir, @spec.file_name
|
63
|
+
FileUtils.touch @gem
|
64
|
+
|
65
|
+
util_setup_gem
|
66
|
+
|
67
|
+
build_rake_in do
|
68
|
+
use_ui @ui do
|
69
|
+
@installer.install
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
@cmd.options[:args] = ["pre"]
|
74
|
+
|
75
|
+
use_ui @ui do
|
76
|
+
@cmd.execute
|
77
|
+
end
|
78
|
+
|
79
|
+
output = @ui.output
|
80
|
+
assert_match(/Successfully uninstalled/, output)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|