rubygems-update 1.8.30 → 2.0.0.preview2
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.
- checksums.yaml +6 -6
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +3 -0
- data/.autotest +6 -3
- data/History.txt +137 -63
- data/LICENSE.txt +1 -5
- data/Manifest.txt +69 -32
- data/README.rdoc +11 -9
- data/Rakefile +24 -38
- data/bin/gem +0 -9
- data/bin/update_rubygems +1 -0
- data/lib/rubygems.rb +193 -405
- data/lib/rubygems/available_set.rb +95 -0
- data/lib/rubygems/command.rb +88 -45
- data/lib/rubygems/command_manager.rb +67 -40
- data/lib/rubygems/commands/build_command.rb +5 -23
- data/lib/rubygems/commands/cert_command.rb +199 -57
- data/lib/rubygems/commands/check_command.rb +14 -39
- data/lib/rubygems/commands/cleanup_command.rb +9 -1
- data/lib/rubygems/commands/contents_command.rb +30 -12
- data/lib/rubygems/commands/dependency_command.rb +3 -8
- data/lib/rubygems/commands/environment_command.rb +13 -8
- data/lib/rubygems/commands/fetch_command.rb +3 -16
- data/lib/rubygems/commands/generate_index_command.rb +7 -47
- data/lib/rubygems/commands/help_command.rb +1 -1
- data/lib/rubygems/commands/install_command.rb +69 -36
- data/lib/rubygems/commands/list_command.rb +6 -4
- data/lib/rubygems/commands/lock_command.rb +1 -1
- data/lib/rubygems/commands/mirror_command.rb +17 -0
- data/lib/rubygems/commands/outdated_command.rb +6 -3
- data/lib/rubygems/commands/owner_command.rb +13 -5
- data/lib/rubygems/commands/pristine_command.rb +19 -4
- data/lib/rubygems/commands/push_command.rb +12 -1
- data/lib/rubygems/commands/query_command.rb +43 -27
- data/lib/rubygems/commands/rdoc_command.rb +23 -28
- data/lib/rubygems/commands/search_command.rb +4 -18
- data/lib/rubygems/commands/server_command.rb +1 -1
- data/lib/rubygems/commands/setup_command.rb +124 -38
- data/lib/rubygems/commands/sources_command.rb +16 -16
- data/lib/rubygems/commands/specification_command.rb +11 -13
- data/lib/rubygems/commands/uninstall_command.rb +24 -7
- data/lib/rubygems/commands/unpack_command.rb +7 -3
- data/lib/rubygems/commands/update_command.rb +22 -36
- data/lib/rubygems/commands/yank_command.rb +98 -0
- data/lib/rubygems/compatibility.rb +51 -0
- data/lib/rubygems/config_file.rb +82 -54
- data/lib/rubygems/core_ext/kernel_gem.rb +53 -0
- data/lib/rubygems/core_ext/kernel_require.rb +119 -0
- data/lib/rubygems/defaults.rb +10 -21
- data/lib/rubygems/dependency.rb +61 -10
- data/lib/rubygems/dependency_installer.rb +157 -69
- data/lib/rubygems/dependency_list.rb +11 -19
- data/lib/rubygems/dependency_resolver.rb +562 -0
- data/lib/rubygems/deprecate.rb +40 -40
- data/lib/rubygems/errors.rb +77 -24
- data/lib/rubygems/exceptions.rb +25 -7
- data/lib/rubygems/ext/builder.rb +20 -23
- data/lib/rubygems/ext/configure_builder.rb +2 -2
- data/lib/rubygems/ext/ext_conf_builder.rb +5 -45
- data/lib/rubygems/ext/rake_builder.rb +2 -2
- data/lib/rubygems/gem_runner.rb +3 -16
- data/lib/rubygems/gemcutter_utilities.rb +22 -7
- data/lib/rubygems/indexer.rb +6 -159
- data/lib/rubygems/install_message.rb +12 -0
- data/lib/rubygems/install_update_options.rb +56 -18
- data/lib/rubygems/installer.rb +244 -134
- data/lib/rubygems/installer_test_case.rb +71 -19
- data/lib/rubygems/mock_gem_ui.rb +17 -0
- data/lib/rubygems/name_tuple.rb +110 -0
- data/lib/rubygems/package.rb +514 -43
- data/lib/rubygems/package/digest_io.rb +64 -0
- data/lib/rubygems/package/old.rb +147 -0
- data/lib/rubygems/package/tar_header.rb +18 -55
- data/lib/rubygems/package/tar_reader.rb +20 -3
- data/lib/rubygems/package/tar_writer.rb +63 -7
- data/lib/rubygems/package_task.rb +3 -4
- data/lib/rubygems/path_support.rb +14 -7
- data/lib/rubygems/platform.rb +19 -26
- data/lib/rubygems/rdoc.rb +316 -0
- data/lib/rubygems/remote_fetcher.rb +117 -54
- data/lib/rubygems/request_set.rb +182 -0
- data/lib/rubygems/requirement.rb +63 -26
- data/lib/rubygems/security.rb +295 -555
- data/lib/rubygems/security/policies.rb +115 -0
- data/lib/rubygems/security/policy.rb +227 -0
- data/lib/rubygems/security/signer.rb +136 -0
- data/lib/rubygems/security/trust_dir.rb +104 -0
- data/lib/rubygems/server.rb +45 -55
- data/lib/rubygems/source.rb +144 -0
- data/lib/rubygems/source_list.rb +87 -0
- data/lib/rubygems/source_local.rb +92 -0
- data/lib/rubygems/source_specific_file.rb +28 -0
- data/lib/rubygems/spec_fetcher.rb +116 -184
- data/lib/rubygems/specification.rb +731 -335
- data/lib/rubygems/ssl_certs/AddTrustExternalCARoot.pem +88 -30
- data/lib/rubygems/ssl_certs/Entrust_net-Secure-Server-Certification-Authority.pem +90 -0
- data/lib/rubygems/ssl_certs/VerisignClass3PublicPrimaryCertificationAuthority-G2.pem +57 -0
- data/lib/rubygems/syck_hack.rb +2 -0
- data/lib/rubygems/test_case.rb +199 -109
- data/lib/rubygems/test_utilities.rb +25 -5
- data/lib/rubygems/uninstaller.rb +62 -20
- data/lib/rubygems/user_interaction.rb +10 -0
- data/lib/rubygems/validator.rb +33 -40
- data/lib/rubygems/version.rb +19 -8
- data/setup.rb +8 -1
- data/test/rubygems/alternate_cert.pem +9 -0
- data/test/rubygems/alternate_cert_32.pem +9 -0
- data/test/rubygems/alternate_key.pem +9 -0
- data/test/rubygems/bad_rake.rb +1 -0
- data/test/rubygems/child_cert.pem +9 -0
- data/test/rubygems/child_cert_32.pem +9 -0
- data/test/rubygems/child_key.pem +9 -0
- data/test/rubygems/data/null-type.gemspec.rz +0 -0
- data/test/rubygems/expired_cert.pem +9 -0
- data/test/rubygems/future_cert.pem +9 -0
- data/test/rubygems/future_cert_32.pem +9 -0
- data/test/rubygems/good_rake.rb +1 -0
- data/test/rubygems/grandchild_cert.pem +9 -0
- data/test/rubygems/grandchild_cert_32.pem +9 -0
- data/test/rubygems/grandchild_key.pem +9 -0
- data/test/rubygems/invalid_issuer_cert.pem +9 -0
- data/test/rubygems/invalid_issuer_cert_32.pem +9 -0
- data/test/rubygems/invalid_key.pem +9 -0
- data/test/rubygems/invalid_signer_cert.pem +9 -0
- data/test/rubygems/invalid_signer_cert_32.pem +9 -0
- data/test/rubygems/invalidchild_cert.pem +9 -0
- data/test/rubygems/invalidchild_cert_32.pem +9 -0
- data/test/rubygems/invalidchild_key.pem +9 -0
- data/test/rubygems/plugin/exception/rubygems_plugin.rb +1 -1
- data/test/rubygems/plugin/standarderror/rubygems_plugin.rb +1 -1
- data/test/rubygems/private_key.pem +7 -25
- data/test/rubygems/public_cert.pem +8 -18
- data/test/rubygems/public_cert_32.pem +10 -0
- data/test/rubygems/public_key.pem +4 -0
- data/test/rubygems/rubygems/commands/crash_command.rb +1 -1
- data/test/rubygems/test_config.rb +4 -6
- data/test/rubygems/test_deprecate.rb +76 -0
- data/test/rubygems/test_gem.rb +318 -83
- data/test/rubygems/test_gem_available_set.rb +106 -0
- data/test/rubygems/test_gem_command.rb +10 -0
- data/test/rubygems/test_gem_command_manager.rb +55 -9
- data/test/rubygems/test_gem_commands_build_command.rb +11 -19
- data/test/rubygems/test_gem_commands_cert_command.rb +441 -42
- data/test/rubygems/test_gem_commands_cleanup_command.rb +29 -1
- data/test/rubygems/test_gem_commands_contents_command.rb +23 -0
- data/test/rubygems/test_gem_commands_dependency_command.rb +5 -0
- data/test/rubygems/test_gem_commands_fetch_command.rb +19 -20
- data/test/rubygems/test_gem_commands_generate_index_command.rb +2 -83
- data/test/rubygems/test_gem_commands_help_command.rb +2 -1
- data/test/rubygems/test_gem_commands_install_command.rb +647 -48
- data/test/rubygems/test_gem_commands_mirror.rb +32 -0
- data/test/rubygems/test_gem_commands_owner_command.rb +4 -8
- data/test/rubygems/test_gem_commands_pristine_command.rb +99 -4
- data/test/rubygems/test_gem_commands_push_command.rb +62 -8
- data/test/rubygems/test_gem_commands_query_command.rb +51 -0
- data/test/rubygems/test_gem_commands_search_command.rb +25 -0
- data/test/rubygems/test_gem_commands_setup_command.rb +45 -0
- data/test/rubygems/test_gem_commands_sources_command.rb +21 -6
- data/test/rubygems/test_gem_commands_specification_command.rb +33 -1
- data/test/rubygems/test_gem_commands_uninstall_command.rb +91 -31
- data/test/rubygems/test_gem_commands_unpack_command.rb +3 -3
- data/test/rubygems/test_gem_commands_update_command.rb +56 -38
- data/test/rubygems/test_gem_commands_which_command.rb +4 -4
- data/test/rubygems/test_gem_commands_yank_command.rb +97 -0
- data/test/rubygems/test_gem_config_file.rb +66 -21
- data/test/rubygems/test_gem_dependency.rb +46 -0
- data/test/rubygems/test_gem_dependency_installer.rb +228 -18
- data/test/rubygems/test_gem_dependency_list.rb +0 -9
- data/test/rubygems/test_gem_dependency_resolver.rb +327 -0
- data/test/rubygems/test_gem_ext_configure_builder.rb +4 -4
- data/test/rubygems/test_gem_ext_ext_conf_builder.rb +21 -49
- data/test/rubygems/test_gem_ext_rake_builder.rb +13 -13
- data/test/rubygems/test_gem_gem_runner.rb +27 -5
- data/test/rubygems/test_gem_gemcutter_utilities.rb +19 -0
- data/test/rubygems/test_gem_indexer.rb +14 -227
- data/test/rubygems/test_gem_install_update_options.rb +83 -3
- data/test/rubygems/test_gem_installer.rb +211 -236
- data/test/rubygems/test_gem_local_remote_options.rb +8 -2
- data/test/rubygems/test_gem_name_tuple.rb +15 -0
- data/test/rubygems/test_gem_package.rb +547 -0
- data/test/rubygems/test_gem_package_old.rb +37 -0
- data/test/rubygems/test_gem_package_tar_reader.rb +32 -0
- data/test/rubygems/test_gem_package_tar_writer.rb +84 -1
- data/test/rubygems/test_gem_path_support.rb +4 -30
- data/test/rubygems/test_gem_platform.rb +3 -6
- data/test/rubygems/test_gem_rdoc.rb +245 -0
- data/test/rubygems/test_gem_remote_fetcher.rb +51 -5
- data/test/rubygems/test_gem_request_set.rb +70 -0
- data/test/rubygems/test_gem_requirement.rb +53 -24
- data/test/rubygems/test_gem_security.rb +189 -43
- data/test/rubygems/test_gem_security_policy.rb +376 -0
- data/test/rubygems/test_gem_security_signer.rb +184 -0
- data/test/rubygems/test_gem_security_trust_dir.rb +94 -0
- data/test/rubygems/test_gem_server.rb +31 -36
- data/test/rubygems/test_gem_silent_ui.rb +2 -2
- data/test/rubygems/test_gem_source.rb +188 -0
- data/test/rubygems/test_gem_source_list.rb +87 -0
- data/test/rubygems/test_gem_source_local.rb +83 -0
- data/test/rubygems/test_gem_source_specific_file.rb +33 -0
- data/test/rubygems/test_gem_spec_fetcher.rb +91 -255
- data/test/rubygems/test_gem_specification.rb +293 -39
- data/test/rubygems/test_gem_uninstaller.rb +136 -13
- data/test/rubygems/test_gem_validator.rb +14 -41
- data/test/rubygems/test_gem_version.rb +15 -21
- data/test/rubygems/test_require.rb +193 -0
- data/test/rubygems/wrong_key_cert.pem +9 -0
- data/test/rubygems/wrong_key_cert_32.pem +9 -0
- metadata +171 -83
- metadata.gz.sig +1 -0
- data/CVE-2013-4287.txt +0 -36
- data/CVE-2013-4363.txt +0 -45
- data/ci_build.sh +0 -27
- data/cruise_config.rb +0 -32
- data/lib/rbconfig/datadir.rb +0 -13
- data/lib/rubygems/builder.rb +0 -99
- data/lib/rubygems/custom_require.rb +0 -69
- data/lib/rubygems/doc_manager.rb +0 -243
- data/lib/rubygems/format.rb +0 -82
- data/lib/rubygems/gem_openssl.rb +0 -90
- data/lib/rubygems/gem_path_searcher.rb +0 -172
- data/lib/rubygems/old_format.rb +0 -153
- data/lib/rubygems/package/f_sync_dir.rb +0 -23
- data/lib/rubygems/package/tar_input.rb +0 -234
- data/lib/rubygems/package/tar_output.rb +0 -146
- data/lib/rubygems/require_paths_builder.rb +0 -18
- data/lib/rubygems/source_index.rb +0 -406
- data/lib/rubygems/ssl_certs/AddTrustExternalCARoot-2048.pem +0 -25
- data/lib/rubygems/ssl_certs/Class3PublicPrimaryCertificationAuthority.pem +0 -14
- data/lib/rubygems/ssl_certs/DigiCertHighAssuranceEVRootCA.pem +0 -23
- data/lib/rubygems/ssl_certs/EntrustnetSecureServerCertificationAuthority.pem +0 -28
- data/lib/rubygems/ssl_certs/GeoTrustGlobalCA.pem +0 -20
- data/test/rubygems/test_bundled_ca.rb +0 -59
- data/test/rubygems/test_gem_builder.rb +0 -44
- data/test/rubygems/test_gem_doc_manager.rb +0 -32
- data/test/rubygems/test_gem_ext_builder.rb +0 -58
- data/test/rubygems/test_gem_format.rb +0 -88
- data/test/rubygems/test_gem_gem_path_searcher.rb +0 -94
- data/test/rubygems/test_gem_package_tar_input.rb +0 -129
- data/test/rubygems/test_gem_package_tar_output.rb +0 -101
- data/test/rubygems/test_gem_source_index.rb +0 -250
- data/util/update_bundled_ca_certificates.rb +0 -103
@@ -0,0 +1,83 @@
|
|
1
|
+
require 'rubygems/test_case'
|
2
|
+
require 'rubygems/source_local'
|
3
|
+
|
4
|
+
require 'fileutils'
|
5
|
+
|
6
|
+
class TestGemSourceLocal < Gem::TestCase
|
7
|
+
def setup
|
8
|
+
super
|
9
|
+
|
10
|
+
@sl = Gem::Source::Local.new
|
11
|
+
|
12
|
+
@a, @a_gem = util_gem "a", '1'
|
13
|
+
@ap, @ap_gem = util_gem "a", '2.a'
|
14
|
+
@b, @b_gem = util_gem "b", '1'
|
15
|
+
|
16
|
+
FileUtils.mv @a_gem, @tempdir
|
17
|
+
FileUtils.mv @ap_gem, @tempdir
|
18
|
+
FileUtils.mv @b_gem, @tempdir
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_load_specs_released
|
22
|
+
assert_equal [@a.name_tuple, @b.name_tuple].sort,
|
23
|
+
@sl.load_specs(:released).sort
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_load_specs_prerelease
|
27
|
+
assert_equal [@ap.name_tuple], @sl.load_specs(:prerelease)
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_load_specs_latest
|
31
|
+
a2, a2_gem = util_gem "a", "2"
|
32
|
+
|
33
|
+
FileUtils.mv a2_gem, @tempdir
|
34
|
+
|
35
|
+
assert_equal [a2.name_tuple, @b.name_tuple].sort,
|
36
|
+
@sl.load_specs(:latest).sort
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_find_gem
|
40
|
+
assert_equal "a-1", @sl.find_gem("a").full_name
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_find_gem_highest_version
|
44
|
+
_, a2_gem = util_gem "a", "2"
|
45
|
+
FileUtils.mv a2_gem, @tempdir
|
46
|
+
|
47
|
+
assert_equal "a-2", @sl.find_gem("a").full_name
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_find_gem_specific_version
|
51
|
+
_, a2_gem = util_gem "a", "2"
|
52
|
+
FileUtils.mv a2_gem, @tempdir
|
53
|
+
|
54
|
+
req = Gem::Requirement.create("= 1")
|
55
|
+
|
56
|
+
assert_equal "a-1", @sl.find_gem("a", req).full_name
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_find_gem_prerelease
|
60
|
+
req = Gem::Requirement.create(">= 0")
|
61
|
+
assert_equal "a-2.a", @sl.find_gem("a", req, true).full_name
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_fetch_spec
|
65
|
+
s = @sl.fetch_spec @a.name_tuple
|
66
|
+
assert_equal s, @a
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_download
|
70
|
+
path = @sl.download @a
|
71
|
+
|
72
|
+
assert_equal File.expand_path(@a.file_name), path
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_compare
|
76
|
+
uri = URI.parse "http://gems.example/foo"
|
77
|
+
s = Gem::Source.new uri
|
78
|
+
|
79
|
+
assert_equal(-1, (@sl <=> s))
|
80
|
+
assert_equal 1, (s <=> @sl)
|
81
|
+
assert_equal 0, (@sl <=> @sl)
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'rubygems/test_case'
|
2
|
+
require 'rubygems/source_specific_file'
|
3
|
+
|
4
|
+
class TestGemSourceSpecificFile < Gem::TestCase
|
5
|
+
def setup
|
6
|
+
super
|
7
|
+
|
8
|
+
@a, @a_gem = util_gem "a", '1'
|
9
|
+
@sf = Gem::Source::SpecificFile.new(@a_gem)
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_spec
|
13
|
+
assert_equal @a, @sf.spec
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_load_specs
|
17
|
+
assert_equal [@a.name_tuple], @sf.load_specs
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_fetch_spec
|
21
|
+
assert_equal @a, @sf.fetch_spec(@a.name_tuple)
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_fetch_spec_fails_on_unknown_name
|
25
|
+
assert_raises Gem::Exception do
|
26
|
+
@sf.fetch_spec(nil)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_download
|
31
|
+
assert_equal @a_gem, @sf.download(@a)
|
32
|
+
end
|
33
|
+
end
|
@@ -3,10 +3,15 @@ require 'rubygems/spec_fetcher'
|
|
3
3
|
|
4
4
|
class TestGemSpecFetcher < Gem::TestCase
|
5
5
|
|
6
|
+
def tuple(*args)
|
7
|
+
Gem::NameTuple.new(*args)
|
8
|
+
end
|
9
|
+
|
6
10
|
def setup
|
7
11
|
super
|
8
12
|
|
9
13
|
@uri = URI.parse @gem_repo
|
14
|
+
@source = Gem::Source.new(@uri)
|
10
15
|
|
11
16
|
util_setup_fake_fetcher
|
12
17
|
|
@@ -16,108 +21,114 @@ class TestGemSpecFetcher < Gem::TestCase
|
|
16
21
|
|
17
22
|
Gem::Specification.remove_spec @b2
|
18
23
|
|
19
|
-
|
20
|
-
|
24
|
+
all = Gem::Specification.map { |spec|
|
25
|
+
Gem::NameTuple.new(spec.name, spec.version, spec.original_platform)
|
21
26
|
}.sort
|
22
27
|
|
28
|
+
@prerelease_specs, @specs = all.partition { |g| g.prerelease? }
|
29
|
+
|
23
30
|
# TODO: couldn't all of this come from the fake spec fetcher?
|
24
31
|
@latest_specs = Gem::Specification.latest_specs.sort.map { |spec|
|
25
|
-
|
32
|
+
Gem::NameTuple.new(spec.name, spec.version, spec.original_platform)
|
26
33
|
}
|
27
34
|
|
28
|
-
prerelease = Gem::Specification.find_all { |s| s.version.prerelease? }
|
29
|
-
@prerelease_specs = prerelease.map { |spec|
|
30
|
-
[spec.name, spec.version, spec.original_platform]
|
31
|
-
}.sort
|
32
|
-
|
33
35
|
v = Gem.marshal_version
|
34
|
-
s_zip = util_gzip(Marshal.dump(@specs))
|
35
|
-
l_zip = util_gzip(Marshal.dump(@latest_specs))
|
36
|
-
p_zip = util_gzip(Marshal.dump(@prerelease_specs))
|
36
|
+
s_zip = util_gzip(Marshal.dump(Gem::NameTuple.to_basic(@specs)))
|
37
|
+
l_zip = util_gzip(Marshal.dump(Gem::NameTuple.to_basic(@latest_specs)))
|
38
|
+
p_zip = util_gzip(Marshal.dump(Gem::NameTuple.to_basic(@prerelease_specs)))
|
37
39
|
@fetcher.data["#{@gem_repo}specs.#{v}.gz"] = s_zip
|
38
40
|
@fetcher.data["#{@gem_repo}latest_specs.#{v}.gz"] = l_zip
|
39
41
|
@fetcher.data["#{@gem_repo}prerelease_specs.#{v}.gz"] = p_zip
|
40
42
|
|
41
43
|
@sf = Gem::SpecFetcher.new
|
44
|
+
|
45
|
+
@released = Gem::NameTuple.from_list \
|
46
|
+
[["a", Gem::Version.new("1"), "ruby"],
|
47
|
+
["a", Gem::Version.new("2"), "ruby"],
|
48
|
+
["a_evil", Gem::Version.new("9"), "ruby"],
|
49
|
+
["c", Gem::Version.new("1.2"), "ruby"],
|
50
|
+
['dep_x', Gem::Version.new(1), 'ruby'],
|
51
|
+
["pl", Gem::Version.new("1"), "i386-linux"],
|
52
|
+
['x', Gem::Version.new(1), 'ruby']]
|
42
53
|
end
|
43
54
|
|
44
|
-
def
|
55
|
+
def test_spec_for_dependency_all
|
45
56
|
d = "#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}"
|
46
57
|
@fetcher.data["#{d}#{@a1.spec_name}.rz"] = util_zip(Marshal.dump(@a1))
|
47
58
|
@fetcher.data["#{d}#{@a2.spec_name}.rz"] = util_zip(Marshal.dump(@a2))
|
48
59
|
@fetcher.data["#{d}#{@a_pre.spec_name}.rz"] = util_zip(Marshal.dump(@a_pre))
|
49
60
|
@fetcher.data["#{d}#{@a3a.spec_name}.rz"] = util_zip(Marshal.dump(@a3a))
|
50
61
|
|
51
|
-
dep = Gem::Dependency.new 'a', 1
|
62
|
+
dep = Gem::Dependency.new 'a', ">= 1"
|
52
63
|
|
53
|
-
specs_and_sources = @sf.
|
64
|
+
specs_and_sources, _ = @sf.spec_for_dependency dep
|
54
65
|
|
55
66
|
spec_names = specs_and_sources.map do |spec, source_uri|
|
56
67
|
[spec.full_name, source_uri]
|
57
68
|
end
|
58
69
|
|
59
|
-
expected = [[@a1.full_name, @
|
70
|
+
expected = [[@a1.full_name, @source], [@a2.full_name, @source]]
|
60
71
|
|
61
72
|
assert_equal expected, spec_names
|
62
73
|
|
63
74
|
assert_same specs_and_sources.first.last, specs_and_sources.last.last
|
64
75
|
end
|
65
76
|
|
66
|
-
def
|
77
|
+
def test_spec_for_dependency_latest
|
67
78
|
d = "#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}"
|
68
79
|
@fetcher.data["#{d}#{@a1.spec_name}.rz"] = util_zip(Marshal.dump(@a1))
|
69
80
|
@fetcher.data["#{d}#{@a2.spec_name}.rz"] = util_zip(Marshal.dump(@a2))
|
70
81
|
@fetcher.data["#{d}#{@a_pre.spec_name}.rz"] = util_zip(Marshal.dump(@a_pre))
|
71
82
|
|
72
|
-
dep = Gem::Dependency.new 'a'
|
73
|
-
specs_and_sources = @sf.
|
83
|
+
dep = Gem::Dependency.new 'a'
|
84
|
+
specs_and_sources, _ = @sf.spec_for_dependency dep
|
74
85
|
|
75
86
|
spec_names = specs_and_sources.map do |spec, source_uri|
|
76
87
|
[spec.full_name, source_uri]
|
77
88
|
end
|
78
89
|
|
79
|
-
assert_equal [[@a2.full_name, @gem_repo]], spec_names
|
90
|
+
assert_equal [[@a2.full_name, Gem::Source.new(@gem_repo)]], spec_names
|
80
91
|
end
|
81
92
|
|
82
|
-
def
|
93
|
+
def test_spec_for_dependency_prerelease
|
83
94
|
d = "#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}"
|
84
95
|
@fetcher.data["#{d}#{@a1.spec_name}.rz"] = util_zip(Marshal.dump(@a1))
|
85
96
|
@fetcher.data["#{d}#{@a2.spec_name}.rz"] = util_zip(Marshal.dump(@a2))
|
86
97
|
@fetcher.data["#{d}#{@a_pre.spec_name}.rz"] = util_zip(Marshal.dump(@a_pre))
|
87
98
|
|
88
|
-
specs_and_sources = @sf.
|
99
|
+
specs_and_sources, _ = @sf.spec_for_dependency dep('a', '1.a')
|
89
100
|
|
90
101
|
spec_names = specs_and_sources.map do |spec, source_uri|
|
91
102
|
[spec.full_name, source_uri]
|
92
103
|
end
|
93
104
|
|
94
|
-
assert_equal [[@a_pre.full_name, @gem_repo]], spec_names
|
105
|
+
assert_equal [[@a_pre.full_name, Gem::Source.new(@gem_repo)]], spec_names
|
95
106
|
end
|
96
107
|
|
97
|
-
def
|
108
|
+
def test_spec_for_dependency_platform
|
98
109
|
util_set_arch 'i386-linux'
|
99
110
|
|
100
111
|
@fetcher.data["#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}#{@pl1.original_name}.gemspec.rz"] =
|
101
112
|
util_zip(Marshal.dump(@pl1))
|
102
113
|
|
103
114
|
dep = Gem::Dependency.new 'pl', 1
|
104
|
-
specs_and_sources = @sf.
|
115
|
+
specs_and_sources, _ = @sf.spec_for_dependency dep
|
105
116
|
|
106
117
|
spec_names = specs_and_sources.map do |spec, source_uri|
|
107
118
|
[spec.full_name, source_uri]
|
108
119
|
end
|
109
120
|
|
110
|
-
assert_equal [[@pl1.full_name, @gem_repo]], spec_names
|
121
|
+
assert_equal [[@pl1.full_name, Gem::Source.new(@gem_repo)]], spec_names
|
111
122
|
end
|
112
123
|
|
113
|
-
def
|
124
|
+
def test_spec_for_dependency_mismatched_platform
|
114
125
|
util_set_arch 'hrpa-989'
|
115
126
|
|
116
127
|
@fetcher.data["#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}#{@pl1.original_name}.gemspec.rz"] =
|
117
128
|
util_zip(Marshal.dump(@pl1))
|
118
129
|
|
119
130
|
dep = Gem::Dependency.new 'pl', 1
|
120
|
-
specs_and_sources, errors = @sf.
|
131
|
+
specs_and_sources, errors = @sf.spec_for_dependency dep
|
121
132
|
|
122
133
|
assert_equal 0, specs_and_sources.size
|
123
134
|
assert_equal 1, errors.size
|
@@ -125,284 +136,109 @@ class TestGemSpecFetcher < Gem::TestCase
|
|
125
136
|
assert_equal "i386-linux", errors[0].platforms.first
|
126
137
|
end
|
127
138
|
|
128
|
-
def
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
spec = @sf.fetch_spec ['a', Gem::Version.new(1), 'ruby'], @uri
|
133
|
-
assert_equal @a1.full_name, spec.full_name
|
134
|
-
|
135
|
-
cache_dir = @sf.cache_dir URI.parse(spec_uri)
|
136
|
-
|
137
|
-
cache_file = File.join cache_dir, @a1.spec_name
|
138
|
-
|
139
|
-
assert File.exist?(cache_file)
|
140
|
-
end
|
141
|
-
|
142
|
-
def test_fetch_spec_cached
|
143
|
-
spec_uri = "#{@gem_repo}/#{Gem::MARSHAL_SPEC_DIR}#{@a1.spec_name}"
|
144
|
-
@fetcher.data["#{spec_uri}.rz"] = nil
|
145
|
-
|
146
|
-
cache_dir = @sf.cache_dir URI.parse(spec_uri)
|
147
|
-
FileUtils.mkdir_p cache_dir
|
148
|
-
|
149
|
-
cache_file = File.join cache_dir, @a1.spec_name
|
150
|
-
|
151
|
-
open cache_file, 'wb' do |io|
|
152
|
-
Marshal.dump @a1, io
|
139
|
+
def test_spec_for_dependency_bad_fetch_spec
|
140
|
+
src = Gem::Source.new(@gem_repo)
|
141
|
+
def src.fetch_spec(name)
|
142
|
+
raise Gem::RemoteFetcher::FetchError.new("bad news from the internet", @uri)
|
153
143
|
end
|
154
144
|
|
155
|
-
|
156
|
-
assert_equal @a1.full_name, spec.full_name
|
157
|
-
end
|
158
|
-
|
159
|
-
def test_fetch_spec_platform
|
160
|
-
@fetcher.data["#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}#{@pl1.original_name}.gemspec.rz"] =
|
161
|
-
util_zip(Marshal.dump(@pl1))
|
162
|
-
|
163
|
-
spec = @sf.fetch_spec ['pl', Gem::Version.new(1), 'i386-linux'], @uri
|
145
|
+
Gem.sources.replace [src]
|
164
146
|
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
@fetcher.data["#{
|
170
|
-
util_zip(Marshal.dump(@a1))
|
171
|
-
|
172
|
-
spec = @sf.fetch_spec ['a', Gem::Version.new(1), nil], @uri
|
173
|
-
assert_equal @a1.full_name, spec.full_name
|
147
|
+
d = "#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}"
|
148
|
+
@fetcher.data["#{d}#{@a1.spec_name}.rz"] = util_zip(Marshal.dump(@a1))
|
149
|
+
@fetcher.data["#{d}#{@a2.spec_name}.rz"] = util_zip(Marshal.dump(@a2))
|
150
|
+
@fetcher.data["#{d}#{@a_pre.spec_name}.rz"] = util_zip(Marshal.dump(@a_pre))
|
151
|
+
@fetcher.data["#{d}#{@a3a.spec_name}.rz"] = util_zip(Marshal.dump(@a3a))
|
174
152
|
|
175
|
-
|
176
|
-
assert_equal @a1.full_name, spec.full_name
|
177
|
-
end
|
153
|
+
dep = Gem::Dependency.new 'a', ">= 1"
|
178
154
|
|
179
|
-
|
180
|
-
dep = Gem::Dependency.new 'a', 1
|
181
|
-
specs = @sf.find_matching dep, true
|
155
|
+
specs_and_sources, errors = @sf.spec_for_dependency dep
|
182
156
|
|
183
|
-
|
184
|
-
|
185
|
-
[['a', Gem::Version.new(2), Gem::Platform::RUBY], @gem_repo],
|
186
|
-
]
|
157
|
+
assert_equal [], specs_and_sources
|
158
|
+
sfp = errors.first
|
187
159
|
|
188
|
-
|
160
|
+
assert_kind_of Gem::SourceFetchProblem, sfp
|
161
|
+
assert_equal src, sfp.source
|
162
|
+
assert_equal "bad news from the internet (#{@gem_repo})", sfp.error.message
|
189
163
|
end
|
190
164
|
|
191
|
-
def
|
192
|
-
|
193
|
-
specs = @sf.find_matching dep
|
165
|
+
def test_available_specs_latest
|
166
|
+
specs, _ = @sf.available_specs(:latest)
|
194
167
|
|
195
|
-
|
196
|
-
|
197
|
-
]
|
198
|
-
|
199
|
-
assert_equal expected, specs
|
168
|
+
assert_equal [@source], specs.keys
|
169
|
+
assert_equal @latest_specs, specs[@source].sort
|
200
170
|
end
|
201
171
|
|
202
|
-
def
|
203
|
-
|
204
|
-
specs = @sf.find_matching dep, false, true, true
|
172
|
+
def test_available_specs_released
|
173
|
+
specs, _ = @sf.available_specs(:released)
|
205
174
|
|
206
|
-
|
207
|
-
[['a', Gem::Version.new('1.a'), Gem::Platform::RUBY], @gem_repo],
|
208
|
-
]
|
175
|
+
assert_equal [@source], specs.keys
|
209
176
|
|
210
|
-
assert_equal
|
177
|
+
assert_equal @released, specs[@source].sort
|
211
178
|
end
|
212
179
|
|
213
|
-
def
|
214
|
-
|
180
|
+
def test_available_specs_complete
|
181
|
+
specs, _ = @sf.available_specs(:complete)
|
215
182
|
|
216
|
-
|
217
|
-
specs = @sf.find_matching dep
|
218
|
-
|
219
|
-
expected = [
|
220
|
-
[['pl', Gem::Version.new(1), 'i386-linux'], @gem_repo],
|
221
|
-
]
|
222
|
-
|
223
|
-
assert_equal expected, specs
|
224
|
-
|
225
|
-
util_set_arch 'i386-freebsd6'
|
226
|
-
|
227
|
-
dep = Gem::Dependency.new 'pl', 1
|
228
|
-
specs = @sf.find_matching dep
|
229
|
-
|
230
|
-
assert_equal [], specs
|
231
|
-
end
|
232
|
-
|
233
|
-
def test_find_matching_with_errors_matched_platform
|
234
|
-
util_set_arch 'i386-linux'
|
235
|
-
|
236
|
-
dep = Gem::Dependency.new 'pl', 1
|
237
|
-
specs, errors = @sf.find_matching_with_errors dep
|
183
|
+
assert_equal [@source], specs.keys
|
238
184
|
|
239
|
-
|
240
|
-
[['pl', Gem::Version.new(1), 'i386-linux'], @gem_repo],
|
241
|
-
]
|
185
|
+
comp = @prerelease_specs + @released
|
242
186
|
|
243
|
-
assert_equal
|
244
|
-
assert_equal 0, errors.size
|
187
|
+
assert_equal comp.sort, specs[@source].sort
|
245
188
|
end
|
246
189
|
|
247
|
-
def
|
248
|
-
|
249
|
-
|
250
|
-
dep = Gem::Dependency.new 'pl', 1
|
251
|
-
specs, errors = @sf.find_matching_with_errors dep
|
252
|
-
|
253
|
-
assert_equal 0, specs.size
|
254
|
-
|
255
|
-
assert_equal 1, errors.size
|
256
|
-
|
257
|
-
assert_equal "i386-linux", errors[0].platforms.first
|
258
|
-
end
|
190
|
+
def test_available_specs_complete_handles_no_prerelease
|
191
|
+
v = Gem.marshal_version
|
192
|
+
@fetcher.data.delete "#{@gem_repo}prerelease_specs.#{v}.gz"
|
259
193
|
|
260
|
-
|
261
|
-
util_set_arch 'i386-freebsd6'
|
194
|
+
specs, _ = @sf.available_specs(:complete)
|
262
195
|
|
263
|
-
|
264
|
-
specs = @sf.find_matching dep, false, false
|
196
|
+
assert_equal [@source], specs.keys
|
265
197
|
|
266
|
-
|
267
|
-
[['pl', Gem::Version.new(1), 'i386-linux'], @gem_repo],
|
268
|
-
]
|
198
|
+
comp = @released
|
269
199
|
|
270
|
-
assert_equal
|
200
|
+
assert_equal comp.sort, specs[@source].sort
|
271
201
|
end
|
272
202
|
|
273
|
-
def test_list
|
274
|
-
specs = @sf.list
|
275
|
-
|
276
|
-
assert_equal [@uri], specs.keys
|
277
|
-
assert_equal @latest_specs, specs[@uri].sort
|
278
|
-
end
|
279
203
|
|
280
|
-
def
|
281
|
-
specs = @sf.
|
204
|
+
def test_available_specs_cache
|
205
|
+
specs, _ = @sf.available_specs(:latest)
|
282
206
|
|
283
|
-
|
284
|
-
|
285
|
-
assert_equal([["a", Gem::Version.new("1"), "ruby"],
|
286
|
-
["a", Gem::Version.new("2"), "ruby"],
|
287
|
-
["a_evil", Gem::Version.new("9"), "ruby"],
|
288
|
-
["c", Gem::Version.new("1.2"), "ruby"],
|
289
|
-
["pl", Gem::Version.new("1"), "i386-linux"]],
|
290
|
-
specs[@uri].sort)
|
291
|
-
end
|
292
|
-
|
293
|
-
def test_list_cache
|
294
|
-
specs = @sf.list
|
295
|
-
|
296
|
-
refute specs[@uri].empty?
|
207
|
+
refute specs[@source].empty?
|
297
208
|
|
298
209
|
@fetcher.data["#{@gem_repo}/latest_specs.#{Gem.marshal_version}.gz"] = nil
|
299
210
|
|
300
|
-
cached_specs = @sf.
|
211
|
+
cached_specs, _ = @sf.available_specs(:latest)
|
301
212
|
|
302
213
|
assert_equal specs, cached_specs
|
303
214
|
end
|
304
215
|
|
305
|
-
def
|
306
|
-
specs = @sf.
|
216
|
+
def test_available_specs_cache_released
|
217
|
+
specs, _ = @sf.available_specs(:released)
|
307
218
|
|
308
|
-
refute specs[@
|
219
|
+
refute specs[@source].empty?
|
309
220
|
|
310
221
|
@fetcher.data["#{@gem_repo}/specs.#{Gem.marshal_version}.gz"] = nil
|
311
222
|
|
312
|
-
cached_specs = @sf.
|
223
|
+
cached_specs, _ = @sf.available_specs(:released)
|
313
224
|
|
314
225
|
assert_equal specs, cached_specs
|
315
226
|
end
|
316
227
|
|
317
|
-
def
|
318
|
-
specs = @sf.
|
319
|
-
|
320
|
-
assert_equal [@latest_specs], specs.values
|
321
|
-
|
322
|
-
specs = @sf.list true
|
228
|
+
def test_available_specs_prerelease
|
229
|
+
specs, _ = @sf.available_specs(:prerelease)
|
323
230
|
|
324
|
-
assert_equal
|
325
|
-
["a", Gem::Version.new("2"), "ruby"],
|
326
|
-
["a_evil", Gem::Version.new("9"), "ruby"],
|
327
|
-
["c", Gem::Version.new("1.2"), "ruby"],
|
328
|
-
["pl", Gem::Version.new("1"), "i386-linux"]]],
|
329
|
-
specs.values, 'specs file not loaded')
|
231
|
+
assert_equal @prerelease_specs, specs[@source].sort
|
330
232
|
end
|
331
233
|
|
332
|
-
def
|
333
|
-
|
334
|
-
|
335
|
-
assert_equal @prerelease_specs, specs[@uri].sort
|
336
|
-
end
|
234
|
+
def test_available_specs_with_bad_source
|
235
|
+
Gem.sources.replace ["http://not-there.nothing"]
|
337
236
|
|
338
|
-
|
339
|
-
expected = [
|
340
|
-
['a', Gem::Version.new('1.a'), Gem::Platform::RUBY],
|
341
|
-
['a', Gem::Version.new(1), Gem::Platform::RUBY],
|
342
|
-
['a', Gem::Version.new(2), Gem::Platform::RUBY],
|
343
|
-
['a', Gem::Version.new('3.a'), Gem::Platform::RUBY],
|
344
|
-
['a_evil', Gem::Version.new(9), Gem::Platform::RUBY],
|
345
|
-
['c', Gem::Version.new('1.2'), Gem::Platform::RUBY],
|
346
|
-
['pl', Gem::Version.new(1), 'i386-linux'],
|
347
|
-
]
|
237
|
+
specs, errors = @sf.available_specs(:latest)
|
348
238
|
|
349
|
-
assert_equal
|
350
|
-
|
351
|
-
cache_dir = File.join Gem.user_home, '.gem', 'specs', 'gems.example.com%80'
|
352
|
-
assert File.exist?(cache_dir), "#{cache_dir} does not exist"
|
353
|
-
|
354
|
-
cache_file = File.join cache_dir, "specs.#{Gem.marshal_version}"
|
355
|
-
assert File.exist?(cache_file)
|
356
|
-
end
|
357
|
-
|
358
|
-
def test_load_specs_cached
|
359
|
-
@fetcher.data["#{@gem_repo}latest_specs.#{Gem.marshal_version}.gz"] = nil
|
360
|
-
@fetcher.data["#{@gem_repo}latest_specs.#{Gem.marshal_version}"] =
|
361
|
-
' ' * Marshal.dump(@latest_specs).length
|
362
|
-
|
363
|
-
cache_dir = File.join Gem.user_home, '.gem', 'specs', 'gems.example.com%80'
|
364
|
-
|
365
|
-
FileUtils.mkdir_p cache_dir
|
366
|
-
|
367
|
-
cache_file = File.join cache_dir, "latest_specs.#{Gem.marshal_version}"
|
368
|
-
|
369
|
-
open cache_file, 'wb' do |io|
|
370
|
-
Marshal.dump @latest_specs, io
|
371
|
-
end
|
372
|
-
|
373
|
-
latest_specs = @sf.load_specs @uri, 'latest_specs'
|
374
|
-
|
375
|
-
assert_equal @latest_specs, latest_specs
|
239
|
+
assert_equal({}, specs)
|
240
|
+
assert_kind_of Gem::SourceFetchProblem, errors.first
|
376
241
|
end
|
377
242
|
|
378
|
-
def test_load_specs_cached_empty
|
379
|
-
@fetcher.data["#{@gem_repo}latest_specs.#{Gem.marshal_version}.gz"] =
|
380
|
-
proc do
|
381
|
-
@fetcher.data["#{@gem_repo}latest_specs.#{Gem.marshal_version}.gz"] =
|
382
|
-
util_gzip(Marshal.dump(@latest_specs))
|
383
|
-
|
384
|
-
nil
|
385
|
-
end
|
386
|
-
|
387
|
-
cache_dir = File.join Gem.user_home, '.gem', 'specs', 'gems.example.com%80'
|
388
|
-
|
389
|
-
FileUtils.mkdir_p cache_dir
|
390
|
-
|
391
|
-
cache_file = File.join cache_dir, "latest_specs.#{Gem.marshal_version}"
|
392
|
-
|
393
|
-
open cache_file, 'wb' do |io|
|
394
|
-
io.write Marshal.dump(@latest_specs)[0, 10]
|
395
|
-
end
|
396
|
-
|
397
|
-
latest_specs = @sf.load_specs @uri, 'latest_specs'
|
398
|
-
|
399
|
-
assert_equal @latest_specs, latest_specs
|
400
|
-
end
|
401
|
-
|
402
|
-
def test_cache_dir_escapes_windows_paths
|
403
|
-
uri = URI.parse("file:///C:/WINDOWS/Temp/gem_repo")
|
404
|
-
cache_dir = @sf.cache_dir(uri).gsub(@sf.dir, '')
|
405
|
-
assert cache_dir !~ /:/, "#{cache_dir} should not contain a :"
|
406
|
-
end
|
407
243
|
end
|
408
244
|
|