rubygems-update 0.9.4 → 0.9.5
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rubygems-update might be problematic. Click here for more details.
- data/ChangeLog +587 -0
- data/README +0 -1
- data/Rakefile +39 -12
- data/TODO +0 -5
- data/bin/gem +7 -7
- data/bin/update_rubygems +1 -1
- data/examples/application/an-app.gemspec +1 -1
- data/gemspecs/cgikit-1.1.0.gemspec +1 -2
- data/gemspecs/jabber4r.gemspec +1 -1
- data/gemspecs/linguistics.gemspec +1 -1
- data/gemspecs/ook.gemspec +1 -1
- data/gemspecs/progressbar.gemspec +1 -1
- data/gemspecs/redcloth.gemspec +1 -1
- data/gemspecs/rublog.gemspec +1 -1
- data/gemspecs/ruby-doom.gemspec +1 -1
- data/gemspecs/rubyjdwp.gemspec +1 -1
- data/gemspecs/statistics.gemspec +1 -1
- data/lib/rubygems.rb +167 -105
- data/lib/rubygems/builder.rb +12 -10
- data/lib/rubygems/command.rb +177 -60
- data/lib/rubygems/command_manager.rb +30 -38
- data/lib/rubygems/commands/build_command.rb +42 -46
- data/lib/rubygems/commands/cert_command.rb +72 -69
- data/lib/rubygems/commands/check_command.rb +63 -63
- data/lib/rubygems/commands/cleanup_command.rb +25 -7
- data/lib/rubygems/commands/contents_command.rb +70 -62
- data/lib/rubygems/commands/dependency_command.rb +131 -86
- data/lib/rubygems/commands/environment_command.rb +67 -46
- data/lib/rubygems/commands/fetch_command.rb +62 -0
- data/lib/rubygems/commands/generate_index_command.rb +57 -0
- data/lib/rubygems/commands/help_command.rb +163 -73
- data/lib/rubygems/commands/install_command.rb +114 -128
- data/lib/rubygems/commands/list_command.rb +10 -8
- data/lib/rubygems/commands/lock_command.rb +101 -0
- data/lib/rubygems/commands/mirror_command.rb +105 -0
- data/lib/rubygems/commands/outdated_command.rb +24 -15
- data/lib/rubygems/commands/pristine_command.rb +118 -88
- data/lib/rubygems/commands/query_command.rb +109 -77
- data/lib/rubygems/commands/rdoc_command.rb +13 -10
- data/lib/rubygems/commands/search_command.rb +10 -8
- data/lib/rubygems/commands/server_command.rb +48 -0
- data/lib/rubygems/commands/sources_command.rb +104 -83
- data/lib/rubygems/commands/specification_command.rb +65 -51
- data/lib/rubygems/commands/uninstall_command.rb +17 -12
- data/lib/rubygems/commands/unpack_command.rb +68 -68
- data/lib/rubygems/commands/update_command.rb +72 -25
- data/lib/rubygems/commands/which_command.rb +86 -0
- data/lib/rubygems/config_file.rb +202 -78
- data/lib/rubygems/custom_require.rb +7 -88
- data/lib/rubygems/dependency.rb +65 -0
- data/lib/rubygems/dependency_installer.rb +232 -0
- data/lib/rubygems/dependency_list.rb +133 -105
- data/lib/rubygems/digest/md5.rb +4 -1
- data/lib/rubygems/digest/sha2.rb +1 -1
- data/lib/rubygems/doc_manager.rb +41 -19
- data/lib/rubygems/exceptions.rb +63 -0
- data/lib/rubygems/ext.rb +18 -0
- data/lib/rubygems/ext/builder.rb +56 -0
- data/lib/rubygems/ext/configure_builder.rb +24 -0
- data/lib/rubygems/ext/ext_conf_builder.rb +23 -0
- data/lib/rubygems/ext/rake_builder.rb +27 -0
- data/lib/rubygems/format.rb +16 -6
- data/lib/rubygems/gem_openssl.rb +43 -6
- data/lib/rubygems/gem_path_searcher.rb +84 -0
- data/lib/rubygems/gem_runner.rb +20 -5
- data/lib/rubygems/indexer.rb +163 -0
- data/lib/rubygems/indexer/abstract_index_builder.rb +80 -0
- data/lib/rubygems/indexer/marshal_index_builder.rb +17 -0
- data/lib/rubygems/indexer/master_index_builder.rb +53 -0
- data/lib/rubygems/indexer/quick_index_builder.rb +48 -0
- data/lib/rubygems/install_update_options.rb +87 -0
- data/lib/rubygems/installer.rb +316 -562
- data/lib/rubygems/local_remote_options.rb +106 -0
- data/lib/rubygems/old_format.rb +5 -13
- data/lib/rubygems/open-uri.rb +2 -0
- data/lib/rubygems/package.rb +28 -32
- data/lib/rubygems/platform.rb +187 -0
- data/lib/rubygems/remote_fetcher.rb +46 -29
- data/lib/rubygems/remote_installer.rb +11 -18
- data/lib/rubygems/requirement.rb +157 -0
- data/lib/rubygems/rubygems_version.rb +1 -1
- data/lib/rubygems/security.rb +715 -457
- data/lib/rubygems/server.rb +77 -59
- data/lib/rubygems/source_index.rb +154 -83
- data/lib/rubygems/source_info_cache.rb +73 -30
- data/lib/rubygems/source_info_cache_entry.rb +12 -3
- data/lib/rubygems/specification.rb +378 -145
- data/lib/rubygems/uninstaller.rb +183 -0
- data/lib/rubygems/user_interaction.rb +38 -9
- data/lib/rubygems/validator.rb +53 -24
- data/lib/rubygems/version.rb +126 -289
- data/lib/rubygems/version_option.rb +49 -0
- data/pkgs/sources/lib/sources.rb +1 -4
- data/pkgs/sources/sources.gemspec +3 -3
- data/scripts/gemdoc.rb +0 -1
- data/setup.rb +166 -1505
- data/test/bogussources.rb +0 -1
- data/test/data/gem-private_key.pem +27 -0
- data/test/data/gem-public_cert.pem +20 -0
- data/test/functional.rb +3 -105
- data/test/gemutilities.rb +145 -24
- data/test/insure_session.rb +0 -1
- data/test/{test_datadir.rb → test_config.rb} +7 -13
- data/test/test_gem.rb +360 -9
- data/test/test_gem_builder.rb +34 -0
- data/test/{test_command.rb → test_gem_command.rb} +119 -62
- data/test/{test_parse_commands.rb → test_gem_command_manager.rb} +64 -40
- data/test/test_gem_commands_build_command.rb +75 -0
- data/test/test_gem_commands_cert_command.rb +122 -0
- data/test/test_gem_commands_check_command.rb +25 -0
- data/test/test_gem_commands_contents_command.rb +92 -0
- data/test/test_gem_commands_dependency_command.rb +108 -0
- data/test/test_gem_commands_environment_command.rb +117 -0
- data/test/test_gem_commands_fetch_command.rb +34 -0
- data/test/test_gem_commands_generate_index_command.rb +32 -0
- data/test/test_gem_commands_install_command.rb +160 -0
- data/test/test_gem_commands_mirror_command.rb +56 -0
- data/test/test_gem_commands_pristine_command.rb +100 -0
- data/test/test_gem_commands_query_command.rb +82 -0
- data/test/test_gem_commands_sources_command.rb +147 -0
- data/test/test_gem_commands_specification_command.rb +93 -0
- data/test/test_gem_commands_unpack_command.rb +55 -0
- data/test/test_gem_config_file.rb +210 -0
- data/test/test_gem_dependency.rb +89 -0
- data/test/test_gem_dependency_installer.rb +542 -0
- data/test/test_gem_dependency_list.rb +212 -0
- data/test/test_gem_doc_manager.rb +32 -0
- data/test/test_gem_ext_configure_builder.rb +13 -17
- data/test/test_gem_ext_ext_conf_builder.rb +9 -9
- data/test/test_gem_ext_rake_builder.rb +23 -11
- data/test/test_gem_format.rb +69 -0
- data/test/test_gem_gem_path_searcher.rb +57 -0
- data/test/test_gem_gem_runner.rb +35 -0
- data/test/test_gem_indexer.rb +119 -0
- data/test/test_gem_install_update_options.rb +40 -0
- data/test/test_gem_installer.rb +796 -0
- data/test/test_gem_local_remote_options.rb +84 -0
- data/test/test_gem_outdated_command.rb +11 -9
- data/test/test_gem_platform.rb +240 -0
- data/test/{test_remote_fetcher.rb → test_gem_remote_fetcher.rb} +124 -55
- data/test/{test_remote_installer.rb → test_gem_remote_installer.rb} +3 -4
- data/test/test_gem_requirement.rb +223 -0
- data/test/test_gem_server.rb +71 -0
- data/test/test_gem_source_index.rb +429 -0
- data/test/test_gem_source_info_cache.rb +79 -17
- data/test/test_gem_source_info_cache_entry.rb +11 -9
- data/test/test_gem_specification.rb +738 -0
- data/test/test_gem_stream_ui.rb +117 -0
- data/test/test_gem_validator.rb +70 -0
- data/test/test_gem_version.rb +191 -0
- data/test/test_gem_version_option.rb +77 -0
- data/test/{test_require_gem.rb → test_kernel.rb} +19 -12
- data/test/test_open_uri.rb +1 -2
- data/test/test_package.rb +45 -34
- metadata +116 -141
- data/Releases +0 -127
- data/bin/gem_mirror +0 -73
- data/bin/gem_server +0 -6
- data/bin/gemlock +0 -127
- data/bin/gemri +0 -24
- data/bin/gemwhich +0 -89
- data/bin/index_gem_repository.rb +0 -302
- data/lib/gemconfigure.rb +0 -24
- data/lib/rubygems/gem_commands.rb +0 -273
- data/pkgs/sources/sources-0.0.1.gem +0 -0
- data/post-install.rb +0 -121
- data/test/brokenbuildgem.rb +0 -35
- data/test/data/PostMessage-0.0.1.gem +0 -0
- data/test/data/a-0.0.1.gem +0 -0
- data/test/data/a-0.0.2.gem +0 -0
- data/test/data/b-0.0.2.gem +0 -0
- data/test/data/broken-1.0.0.gem +0 -0
- data/test/data/broken_build/broken-build.gemspec +0 -20
- data/test/data/broken_build/ext/extconf.rb +0 -3
- data/test/data/broken_build/ext/foo.c +0 -1
- data/test/data/c-1.2.gem +0 -0
- data/test/data/gemhome/cache/a-0.0.1.gem +0 -0
- data/test/data/gemhome/cache/a-0.0.2.gem +0 -0
- data/test/data/gemhome/cache/b-0.0.2.gem +0 -0
- data/test/data/gemhome/cache/c-1.2.gem +0 -0
- data/test/data/gemhome/gems/a-0.0.1/lib/code.rb +0 -1
- data/test/data/gemhome/gems/a-0.0.2/lib/code.rb +0 -1
- data/test/data/gemhome/gems/b-0.0.2/lib/code.rb +0 -1
- data/test/data/gemhome/gems/c-1.2/lib/code.rb +0 -1
- data/test/data/gemhome/specifications/a-0.0.1.gemspec +0 -8
- data/test/data/gemhome/specifications/a-0.0.2.gemspec +0 -8
- data/test/data/gemhome/specifications/b-0.0.2.gemspec +0 -8
- data/test/data/gemhome/specifications/c-1.2.gemspec +0 -8
- data/test/data/legacy/keyedlist-0.4.0.ruby +0 -11
- data/test/data/legacy/keyedlist-0.4.0.yaml +0 -16
- data/test/data/lib/code.rb +0 -1
- data/test/data/one/README.one +0 -1
- data/test/data/one/lib/one.rb +0 -9
- data/test/data/one/one-0.0.1.gem +0 -0
- data/test/data/one/one.gemspec +0 -17
- data/test/data/one/one.yaml +0 -40
- data/test/data/post_install.gemspec +0 -19
- data/test/functional_extension_gems.rb +0 -48
- data/test/functional_generate_yaml_index.rb +0 -104
- data/test/gemenvironment.rb +0 -59
- data/test/io_capture.rb +0 -33
- data/test/mock/gems/gems/sources-0.0.1/lib/sources.rb +0 -11
- data/test/mock/gems/specifications/sources-0.0.1.gemspec +0 -8
- data/test/onegem.rb +0 -35
- data/test/test_builder.rb +0 -34
- data/test/test_check_command.rb +0 -34
- data/test/test_configfile.rb +0 -42
- data/test/test_dependency_list.rb +0 -169
- data/test/test_file_list.rb +0 -101
- data/test/test_format.rb +0 -49
- data/test/test_gem_sources_command.rb +0 -135
- data/test/test_gemloadpaths.rb +0 -51
- data/test/test_gempaths.rb +0 -170
- data/test/test_installer.rb +0 -369
- data/test/test_loadmanager.rb +0 -48
- data/test/test_process_commands.rb +0 -52
- data/test/test_source_index.rb +0 -231
- data/test/test_specific_extras.rb +0 -46
- data/test/test_specification.rb +0 -565
- data/test/test_user_interaction.rb +0 -48
- data/test/test_validator.rb +0 -59
- data/test/test_version_comparison.rb +0 -321
- data/test/testgem.rc +0 -7
- data/test/user_capture.rb +0 -7
- data/test/yaml_data.rb +0 -63
data/test/insure_session.rb
CHANGED
@@ -6,27 +6,21 @@
|
|
6
6
|
#++
|
7
7
|
|
8
8
|
require 'test/unit'
|
9
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
9
10
|
require 'rbconfig'
|
10
11
|
require 'rubygems'
|
11
12
|
|
12
|
-
class
|
13
|
-
|
13
|
+
class TestConfig < RubyGemTestCase
|
14
|
+
|
15
|
+
def test_gem_original_datadir
|
14
16
|
datadir = Config::CONFIG['datadir']
|
15
17
|
assert_equal "#{datadir}/xyz", Config.gem_original_datadir('xyz')
|
16
18
|
end
|
17
19
|
|
18
|
-
def
|
19
|
-
gem 'sources'
|
20
|
-
assert_match %r{gems/1.8/gems/sources-0.0.1/data/sources$}, Gem.datadir('sources')
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_gem_dir_with_bad_package
|
24
|
-
gem 'sources'
|
25
|
-
assert_nil Gem.datadir('xyzzy')
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_basic_dir
|
20
|
+
def test_datadir
|
29
21
|
datadir = Config::CONFIG['datadir']
|
30
22
|
assert_equal "#{datadir}/xyz", Config.datadir('xyz')
|
31
23
|
end
|
24
|
+
|
32
25
|
end
|
26
|
+
|
data/test/test_gem.rb
CHANGED
@@ -1,24 +1,375 @@
|
|
1
1
|
require 'test/unit'
|
2
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
2
3
|
require 'rubygems'
|
3
|
-
require '
|
4
|
+
require 'rubygems/gem_openssl'
|
5
|
+
require 'pathname'
|
4
6
|
|
5
|
-
class TestGem <
|
7
|
+
class TestGem < RubyGemTestCase
|
8
|
+
|
9
|
+
def setup
|
10
|
+
super
|
11
|
+
|
12
|
+
@additional = %w[a b].map { |d| File.join @tempdir, d }
|
13
|
+
@default_dir_re = %r|/[Rr]uby/[Gg]ems/[0-9.]+|
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_self_all_load_paths
|
17
|
+
util_make_gems
|
18
|
+
|
19
|
+
expected = [
|
20
|
+
File.join(@gemhome, *%W[gems #{@a0_0_1.full_name} lib]),
|
21
|
+
File.join(@gemhome, *%W[gems #{@a0_0_2.full_name} lib]),
|
22
|
+
File.join(@gemhome, *%W[gems #{@b0_0_2.full_name} lib]),
|
23
|
+
File.join(@gemhome, *%W[gems #{@c1_2.full_name} lib]),
|
24
|
+
File.join(@gemhome, *%W[gems #{@pl1.full_name} lib]),
|
25
|
+
]
|
26
|
+
|
27
|
+
assert_equal expected, Gem.all_load_paths.sort
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_self_bindir
|
31
|
+
assert_equal File.join(@gemhome, 'bin'), Gem.bindir
|
32
|
+
assert_equal File.join(@gemhome, 'bin'), Gem.bindir(Gem.dir)
|
33
|
+
assert_equal File.join(@gemhome, 'bin'), Gem.bindir(Pathname.new(Gem.dir))
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_self_bindir_default_dir
|
37
|
+
default = Gem.default_dir
|
38
|
+
bindir = (defined? RUBY_FRAMEWORK_VERSION) ? '/usr/bin' : Config::CONFIG['bindir']
|
39
|
+
assert_equal bindir, Gem.bindir(default)
|
40
|
+
assert_equal bindir, Gem.bindir(Pathname.new(default))
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_self_clear_paths
|
44
|
+
Gem.dir
|
45
|
+
Gem.path
|
46
|
+
searcher = Gem.searcher
|
47
|
+
source_index = Gem.source_index
|
48
|
+
|
49
|
+
Gem.clear_paths
|
50
|
+
|
51
|
+
assert_equal nil, Gem.instance_variable_get(:@gem_home)
|
52
|
+
assert_equal nil, Gem.instance_variable_get(:@gem_path)
|
53
|
+
assert_not_equal searcher, Gem.searcher
|
54
|
+
assert_not_equal source_index, Gem.source_index
|
55
|
+
end
|
6
56
|
|
7
57
|
def test_self_configuration
|
8
|
-
expected =
|
9
|
-
Gem.
|
58
|
+
expected = Gem::ConfigFile.new []
|
59
|
+
Gem.configuration = nil
|
10
60
|
|
11
61
|
assert_equal expected, Gem.configuration
|
62
|
+
end
|
12
63
|
|
13
|
-
|
14
|
-
|
64
|
+
def test_self_datadir
|
65
|
+
foo = nil
|
15
66
|
|
16
|
-
|
17
|
-
|
67
|
+
Dir.chdir @tempdir do
|
68
|
+
FileUtils.mkdir_p 'data'
|
69
|
+
File.open File.join('data', 'foo.txt'), 'w' do |fp|
|
70
|
+
fp.puts 'blah'
|
71
|
+
end
|
72
|
+
|
73
|
+
foo = quick_gem 'foo' do |s| s.files = %w[data/foo.txt] end
|
74
|
+
install_gem foo
|
75
|
+
end
|
76
|
+
|
77
|
+
gem 'foo'
|
78
|
+
|
79
|
+
expected = File.join @gemhome, 'gems', foo.full_name, 'data', 'foo'
|
80
|
+
|
81
|
+
assert_equal expected, Gem.datadir('foo')
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_self_datadir_nonexistent_package
|
85
|
+
assert_nil Gem.datadir('xyzzy')
|
86
|
+
end
|
87
|
+
|
88
|
+
def test_self_default_dir
|
89
|
+
assert_match @default_dir_re, Gem.default_dir
|
90
|
+
end
|
91
|
+
|
92
|
+
def test_self_default_sources
|
93
|
+
assert_equal %w[http://gems.rubyforge.org], Gem.default_sources
|
94
|
+
end
|
95
|
+
|
96
|
+
def test_self_dir
|
97
|
+
assert_equal @gemhome, Gem.dir
|
98
|
+
|
99
|
+
Gem::DIRECTORIES.each do |filename|
|
100
|
+
assert File.directory?(File.join(Gem.dir, filename)),
|
101
|
+
"expected #{filename} to exist"
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
def test_self_ensure_gem_directories
|
106
|
+
FileUtils.rm_r @gemhome
|
107
|
+
Gem.use_paths @gemhome
|
108
|
+
|
109
|
+
Gem.ensure_gem_subdirectories @gemhome
|
110
|
+
|
111
|
+
assert File.directory?(File.join(@gemhome, "cache"))
|
112
|
+
end
|
113
|
+
|
114
|
+
def test_self_ensure_gem_directories_missing_parents
|
115
|
+
gemdir = File.join @tempdir, 'a/b/c/gemdir'
|
116
|
+
FileUtils.rm_rf File.join(@tempdir, 'a') rescue nil
|
117
|
+
assert !File.exist?(File.join(@tempdir, 'a')),
|
118
|
+
"manually remove #{File.join @tempdir, 'a'}, tests are broken"
|
119
|
+
Gem.use_paths gemdir
|
120
|
+
|
121
|
+
Gem.ensure_gem_subdirectories gemdir
|
122
|
+
|
123
|
+
assert File.directory?("#{gemdir}/cache")
|
124
|
+
end
|
125
|
+
|
126
|
+
unless win_platform? then # only for FS that support write protection
|
127
|
+
def test_self_ensure_gem_directories_write_protected
|
128
|
+
gemdir = File.join @tempdir, "egd"
|
129
|
+
FileUtils.rm_r gemdir rescue nil
|
130
|
+
assert !File.exist?(gemdir), "manually remove #{gemdir}, tests are broken"
|
131
|
+
FileUtils.mkdir_p gemdir
|
132
|
+
FileUtils.chmod 0400, gemdir
|
133
|
+
Gem.use_paths gemdir
|
134
|
+
|
135
|
+
Gem.ensure_gem_subdirectories gemdir
|
136
|
+
|
137
|
+
assert !File.exist?("#{gemdir}/cache")
|
138
|
+
ensure
|
139
|
+
FileUtils.chmod 0600, gemdir
|
140
|
+
end
|
141
|
+
|
142
|
+
def test_self_ensure_gem_directories_write_protected_parents
|
143
|
+
parent = File.join(@tempdir, "egd")
|
144
|
+
gemdir = "#{parent}/a/b/c"
|
145
|
+
|
146
|
+
FileUtils.rm_r parent rescue nil
|
147
|
+
assert !File.exist?(parent), "manually remove #{parent}, tests are broken"
|
148
|
+
FileUtils.mkdir_p parent
|
149
|
+
FileUtils.chmod 0400, parent
|
150
|
+
Gem.use_paths(gemdir)
|
151
|
+
|
152
|
+
Gem.ensure_gem_subdirectories gemdir
|
153
|
+
|
154
|
+
assert !File.exist?("#{gemdir}/cache")
|
155
|
+
ensure
|
156
|
+
FileUtils.chmod 0600, parent
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
def test_ensure_ssl_available
|
161
|
+
orig_Gem_ssl_available = Gem.ssl_available?
|
162
|
+
|
163
|
+
Gem.ssl_available = true
|
164
|
+
assert_nothing_raised do Gem.ensure_ssl_available end
|
165
|
+
|
166
|
+
Gem.ssl_available = false
|
167
|
+
e = assert_raise Gem::Exception do Gem.ensure_ssl_available end
|
168
|
+
assert_equal 'SSL is not installed on this system', e.message
|
169
|
+
ensure
|
170
|
+
Gem.ssl_available = orig_Gem_ssl_available
|
171
|
+
end
|
172
|
+
|
173
|
+
def test_self_latest_load_paths
|
174
|
+
util_make_gems
|
175
|
+
|
176
|
+
expected = [
|
177
|
+
File.join(@gemhome, *%W[gems #{@a0_0_2.full_name} lib]),
|
178
|
+
File.join(@gemhome, *%W[gems #{@b0_0_2.full_name} lib]),
|
179
|
+
File.join(@gemhome, *%W[gems #{@c1_2.full_name} lib]),
|
180
|
+
File.join(@gemhome, *%W[gems #{@pl1.full_name} lib]),
|
181
|
+
]
|
182
|
+
|
183
|
+
assert_equal expected, Gem.latest_load_paths.sort
|
18
184
|
end
|
19
185
|
|
20
186
|
def test_self_loaded_specs
|
21
|
-
|
187
|
+
foo = quick_gem 'foo'
|
188
|
+
install_gem foo
|
189
|
+
Gem.source_index = nil
|
190
|
+
|
191
|
+
Gem.activate 'foo', false
|
192
|
+
|
193
|
+
assert_equal true, Gem.loaded_specs.keys.include?('foo')
|
194
|
+
end
|
195
|
+
|
196
|
+
def test_self_path
|
197
|
+
assert_equal [Gem.dir], Gem.path
|
198
|
+
end
|
199
|
+
|
200
|
+
def test_self_path_ENV_PATH
|
201
|
+
Gem.clear_paths
|
202
|
+
path_count = Gem.path.size
|
203
|
+
Gem.clear_paths
|
204
|
+
util_ensure_gem_dirs
|
205
|
+
|
206
|
+
ENV['GEM_PATH'] = @additional.join(File::PATH_SEPARATOR)
|
207
|
+
|
208
|
+
assert_equal @additional, Gem.path[0,2]
|
209
|
+
assert_equal path_count + @additional.size, Gem.path.size
|
210
|
+
assert_match Gem.dir, Gem.path.last
|
211
|
+
end
|
212
|
+
|
213
|
+
def test_self_path_duplicate
|
214
|
+
Gem.clear_paths
|
215
|
+
util_ensure_gem_dirs
|
216
|
+
dirs = @additional + [@gemhome] + [File.join(@tempdir, 'a')]
|
217
|
+
|
218
|
+
ENV['GEM_HOME'] = @gemhome
|
219
|
+
ENV['GEM_PATH'] = dirs.join File::PATH_SEPARATOR
|
220
|
+
|
221
|
+
assert_equal @gemhome, Gem.dir
|
222
|
+
paths = [Gem.dir]
|
223
|
+
paths << APPLE_GEM_HOME if defined? APPLE_GEM_HOME
|
224
|
+
assert_equal @additional + paths, Gem.path
|
225
|
+
end
|
226
|
+
|
227
|
+
def test_self_path_overlap
|
228
|
+
Gem.clear_paths
|
229
|
+
|
230
|
+
util_ensure_gem_dirs
|
231
|
+
ENV['GEM_HOME'] = @gemhome
|
232
|
+
ENV['GEM_PATH'] = @additional.join(File::PATH_SEPARATOR)
|
233
|
+
|
234
|
+
assert_equal @gemhome, Gem.dir
|
235
|
+
paths = [Gem.dir]
|
236
|
+
paths.insert(0, APPLE_GEM_HOME) if defined? APPLE_GEM_HOME
|
237
|
+
assert_equal @additional + paths, Gem.path
|
238
|
+
end
|
239
|
+
|
240
|
+
def test_self_platforms
|
241
|
+
assert_equal [Gem::Platform::RUBY, Gem::Platform.local], Gem.platforms
|
242
|
+
end
|
243
|
+
|
244
|
+
def test_self_prefix
|
245
|
+
file_name = File.expand_path __FILE__
|
246
|
+
assert_equal File.dirname(File.dirname(file_name)), Gem.prefix
|
247
|
+
end
|
248
|
+
|
249
|
+
def test_self_required_location
|
250
|
+
util_make_gems
|
251
|
+
|
252
|
+
assert_equal File.join(@tempdir, *%w[gemhome gems c-1.2 lib code.rb]),
|
253
|
+
Gem.required_location("c", "code.rb")
|
254
|
+
assert_equal File.join(@tempdir, *%w[gemhome gems a-0.0.1 lib code.rb]),
|
255
|
+
Gem.required_location("a", "code.rb", "<0.0.2")
|
256
|
+
assert_equal File.join(@tempdir, *%w[gemhome gems a-0.0.2 lib code.rb]),
|
257
|
+
Gem.required_location("a", "code.rb", "=0.0.2")
|
258
|
+
end
|
259
|
+
|
260
|
+
def test_self_searcher
|
261
|
+
assert_kind_of Gem::GemPathSearcher, Gem.searcher
|
262
|
+
end
|
263
|
+
|
264
|
+
def test_self_source_index
|
265
|
+
assert_kind_of Gem::SourceIndex, Gem.source_index
|
266
|
+
end
|
267
|
+
|
268
|
+
def test_self_sources
|
269
|
+
assert_equal %w[http://gems.example.com], Gem.sources
|
270
|
+
end
|
271
|
+
|
272
|
+
def test_ssl_available_eh
|
273
|
+
orig_Gem_ssl_available = Gem.ssl_available?
|
274
|
+
|
275
|
+
Gem.ssl_available = true
|
276
|
+
assert_equal true, Gem.ssl_available?
|
277
|
+
|
278
|
+
Gem.ssl_available = false
|
279
|
+
assert_equal false, Gem.ssl_available?
|
280
|
+
ensure
|
281
|
+
Gem.ssl_available = orig_Gem_ssl_available
|
282
|
+
end
|
283
|
+
|
284
|
+
def test_self_use_paths
|
285
|
+
util_ensure_gem_dirs
|
286
|
+
|
287
|
+
Gem.use_paths @gemhome, @additional
|
288
|
+
|
289
|
+
assert_equal @gemhome, Gem.dir
|
290
|
+
assert_equal @additional + [Gem.dir], Gem.path
|
291
|
+
end
|
292
|
+
|
293
|
+
def test_self_user_home
|
294
|
+
if ENV['HOME'] then
|
295
|
+
assert_equal ENV['HOME'], Gem.user_home
|
296
|
+
else
|
297
|
+
assert true, 'count this test'
|
298
|
+
end
|
299
|
+
end
|
300
|
+
|
301
|
+
def test_require_gem_autorequire
|
302
|
+
name = "AutorequireArray"
|
303
|
+
files = %w(a.rb b.rb)
|
304
|
+
gem = quick_gem(name) do |s|
|
305
|
+
s.files = files.map { |f| File.join("lib", f) }
|
306
|
+
s.autorequire = files
|
307
|
+
end
|
308
|
+
|
309
|
+
fullname = gem.full_name
|
310
|
+
|
311
|
+
write_file "gems/#{fullname}/lib/a.rb" do |io|
|
312
|
+
io.puts "$LOADED_A = true"
|
313
|
+
end
|
314
|
+
|
315
|
+
write_file "gems/#{fullname}/lib/b.rb" do |io|
|
316
|
+
io.puts "$LOADED_B = true"
|
317
|
+
end
|
318
|
+
|
319
|
+
Gem.source_index = nil
|
320
|
+
|
321
|
+
old_loaded = $".dup
|
322
|
+
old_verbose = $VERBOSE
|
323
|
+
$VERBOSE = nil
|
324
|
+
require_gem name
|
325
|
+
$VERBOSE = old_verbose
|
326
|
+
new_loaded = $".dup
|
327
|
+
|
328
|
+
if RUBY_VERSION > "1.9" then
|
329
|
+
files = files.map do |file|
|
330
|
+
File.join @gemhome, 'gems', gem.full_name, 'lib', file
|
331
|
+
end
|
332
|
+
end
|
333
|
+
|
334
|
+
assert_equal files, (new_loaded - old_loaded)
|
335
|
+
assert defined?($LOADED_A)
|
336
|
+
assert defined?($LOADED_B)
|
337
|
+
end
|
338
|
+
|
339
|
+
def test_require_gem_autorequire_string
|
340
|
+
name = "AutorequireString"
|
341
|
+
file = "c.rb"
|
342
|
+
gem = quick_gem(name) do |s|
|
343
|
+
s.files = File.join("lib", file)
|
344
|
+
s.autorequire = file
|
345
|
+
end
|
346
|
+
|
347
|
+
fullname = gem.full_name
|
348
|
+
|
349
|
+
write_file("gems/#{fullname}/lib/c.rb") do |io|
|
350
|
+
io.puts "$LOADED_C = true"
|
351
|
+
end
|
352
|
+
|
353
|
+
old_loaded = $".dup
|
354
|
+
old_verbose = $VERBOSE
|
355
|
+
$VERBOSE = nil
|
356
|
+
require_gem name
|
357
|
+
$VERBOSE = old_verbose
|
358
|
+
new_loaded = $".dup
|
359
|
+
|
360
|
+
if RUBY_VERSION > "1.9" then
|
361
|
+
file = File.join @gemhome, 'gems', gem.full_name, 'lib', file
|
362
|
+
end
|
363
|
+
|
364
|
+
assert_equal(Array(file), (new_loaded - old_loaded))
|
365
|
+
assert(defined? $LOADED_C)
|
366
|
+
end
|
367
|
+
|
368
|
+
def util_ensure_gem_dirs
|
369
|
+
Gem.ensure_gem_subdirectories @gemhome
|
370
|
+
@additional.each do |dir|
|
371
|
+
Gem.ensure_gem_subdirectories @gemhome
|
372
|
+
end
|
22
373
|
end
|
23
374
|
|
24
375
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
|
3
|
+
# All rights reserved.
|
4
|
+
# See LICENSE.txt for permissions.
|
5
|
+
#++
|
6
|
+
|
7
|
+
require 'test/unit'
|
8
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
9
|
+
require 'rubygems/builder'
|
10
|
+
|
11
|
+
class TestGemBuilder < RubyGemTestCase
|
12
|
+
|
13
|
+
def test_build
|
14
|
+
builder = Gem::Builder.new quick_gem('a')
|
15
|
+
|
16
|
+
use_ui @ui do
|
17
|
+
Dir.chdir @tempdir do
|
18
|
+
builder.build
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
assert_match %r|Successfully built RubyGem\n Name: a|, @ui.output
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_build_validates
|
26
|
+
builder = Gem::Builder.new Gem::Specification.new
|
27
|
+
|
28
|
+
assert_raises Gem::InvalidSpecificationException do
|
29
|
+
builder.build
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|