libgems 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,113 @@
|
|
|
1
|
+
require 'rubygems/test_case' # Looks like it's defined somewhere else
|
|
2
|
+
require 'libgems/user_interaction'
|
|
3
|
+
require 'timeout'
|
|
4
|
+
|
|
5
|
+
class TestGemSilentUI < Gem::TestCase
|
|
6
|
+
|
|
7
|
+
def setup
|
|
8
|
+
super
|
|
9
|
+
@sui = LibGems::SilentUI.new
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def test_ask
|
|
13
|
+
value = nil
|
|
14
|
+
out, err = capture_io do
|
|
15
|
+
use_ui @sui do
|
|
16
|
+
value = @sui.ask 'Problem?'
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
assert_empty out, 'No output'
|
|
21
|
+
assert_empty err, 'No output'
|
|
22
|
+
|
|
23
|
+
assert_nil value, 'No value'
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def test_ask_for_password
|
|
27
|
+
value = nil
|
|
28
|
+
out, err = capture_io do
|
|
29
|
+
use_ui @sui do
|
|
30
|
+
value = @sui.ask_for_password 'Problem?'
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
assert_empty out, 'No output'
|
|
35
|
+
assert_empty err, 'No output'
|
|
36
|
+
|
|
37
|
+
assert_nil value, 'No value'
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def test_ask_yes_no
|
|
41
|
+
value = nil
|
|
42
|
+
out, err = capture_io do
|
|
43
|
+
use_ui @sui do
|
|
44
|
+
assert_raises(LibGems::OperationNotSupportedError) do
|
|
45
|
+
@sui.ask_yes_no 'Problem?'
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
assert_empty out, 'No output'
|
|
51
|
+
assert_empty err, 'No output'
|
|
52
|
+
|
|
53
|
+
out, err = capture_io do
|
|
54
|
+
use_ui @sui do
|
|
55
|
+
value = @sui.ask_yes_no 'Problem?', true
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
assert_empty out, 'No output'
|
|
60
|
+
assert_empty err, 'No output'
|
|
61
|
+
|
|
62
|
+
assert value, 'Value is true'
|
|
63
|
+
|
|
64
|
+
out, err = capture_io do
|
|
65
|
+
use_ui @sui do
|
|
66
|
+
value = @sui.ask_yes_no 'Problem?', false
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
assert_empty out, 'No output'
|
|
71
|
+
assert_empty err, 'No output'
|
|
72
|
+
|
|
73
|
+
assert_equal value, false, 'Value is false'
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def test_choose_from_list
|
|
77
|
+
value = nil
|
|
78
|
+
out, err = capture_io do
|
|
79
|
+
use_ui @sui do
|
|
80
|
+
value = @sui.choose_from_list 'Problem?', %w[yes no]
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
assert_empty out, 'No output'
|
|
85
|
+
assert_empty err, 'No output'
|
|
86
|
+
|
|
87
|
+
assert_equal [nil, nil], value, 'Value is nil!'
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def test_progress_reporter
|
|
91
|
+
value = nil
|
|
92
|
+
out, err = capture_io do
|
|
93
|
+
use_ui @sui do
|
|
94
|
+
@sui.progress_reporter 10, 'hi'
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
assert_empty out, 'No output'
|
|
99
|
+
assert_empty err, 'No output'
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def test_download_reporter
|
|
103
|
+
value = nil
|
|
104
|
+
out, err = capture_io do
|
|
105
|
+
use_ui @sui do
|
|
106
|
+
@sui.download_reporter.fetch 'a.gem', 1024
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
assert_empty out, 'No output'
|
|
111
|
+
assert_empty err, 'No output'
|
|
112
|
+
end
|
|
113
|
+
end
|
|
@@ -0,0 +1,461 @@
|
|
|
1
|
+
require File.expand_path('../gemutilities', __FILE__)
|
|
2
|
+
require 'libgems/source_index'
|
|
3
|
+
require 'libgems/config_file'
|
|
4
|
+
|
|
5
|
+
class LibGems::SourceIndex
|
|
6
|
+
public :fetcher, :fetch_bulk_index, :fetch_quick_index,
|
|
7
|
+
:find_missing, :gems, :remove_extra,
|
|
8
|
+
:update_with_missing, :unzip
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
class TestGemSourceIndex < RubyGemTestCase
|
|
12
|
+
|
|
13
|
+
def setup
|
|
14
|
+
super
|
|
15
|
+
|
|
16
|
+
util_setup_fake_fetcher
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def test_self_from_gems_in
|
|
20
|
+
spec_dir = File.join @gemhome, 'specifications'
|
|
21
|
+
|
|
22
|
+
FileUtils.rm_r spec_dir
|
|
23
|
+
|
|
24
|
+
FileUtils.mkdir_p spec_dir
|
|
25
|
+
|
|
26
|
+
a1 = quick_gem 'a', '1' do |spec| spec.author = 'author 1' end
|
|
27
|
+
|
|
28
|
+
spec_file = File.join spec_dir, a1.spec_name
|
|
29
|
+
|
|
30
|
+
File.open spec_file, 'w' do |fp|
|
|
31
|
+
fp.write a1.to_ruby
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
si = LibGems::SourceIndex.from_gems_in spec_dir
|
|
35
|
+
|
|
36
|
+
assert_equal [spec_dir], si.spec_dirs
|
|
37
|
+
assert_equal [a1.full_name], si.gems.keys
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def test_self_load_specification
|
|
41
|
+
spec_dir = File.join @gemhome, 'specifications'
|
|
42
|
+
|
|
43
|
+
FileUtils.rm_r spec_dir
|
|
44
|
+
|
|
45
|
+
FileUtils.mkdir_p spec_dir
|
|
46
|
+
|
|
47
|
+
a1 = quick_gem 'a', '1' do |spec| spec.author = 'author 1' end
|
|
48
|
+
|
|
49
|
+
spec_file = File.join spec_dir, a1.spec_name
|
|
50
|
+
|
|
51
|
+
File.open spec_file, 'w' do |fp|
|
|
52
|
+
fp.write a1.to_ruby
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
spec = LibGems::SourceIndex.load_specification spec_file
|
|
56
|
+
|
|
57
|
+
assert_equal a1.author, spec.author
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def test_self_load_specification_utf_8
|
|
61
|
+
spec_dir = File.join @gemhome, 'specifications'
|
|
62
|
+
|
|
63
|
+
FileUtils.rm_r spec_dir
|
|
64
|
+
|
|
65
|
+
FileUtils.mkdir_p spec_dir
|
|
66
|
+
|
|
67
|
+
spec_file = File.join spec_dir, "utf-8.gemspec"
|
|
68
|
+
spec_data = <<-SPEC
|
|
69
|
+
LibGems::Specification.new do |s|
|
|
70
|
+
s.name = %q{utf}
|
|
71
|
+
s.version = "8"
|
|
72
|
+
|
|
73
|
+
s.required_rubygems_version = LibGems::Requirement.new(">= 0")
|
|
74
|
+
s.authors = ["\317\200"]
|
|
75
|
+
s.date = %q{2008-09-10}
|
|
76
|
+
s.description = %q{This is a test description}
|
|
77
|
+
s.email = %q{example@example.com}
|
|
78
|
+
s.has_rdoc = true
|
|
79
|
+
s.homepage = %q{http://example.com}
|
|
80
|
+
s.require_paths = ["lib"]
|
|
81
|
+
s.rubygems_version = %q{1.2.0}
|
|
82
|
+
s.summary = %q{this is a summary}
|
|
83
|
+
|
|
84
|
+
if s.respond_to? :specification_version then
|
|
85
|
+
current_version = LibGems::Specification::CURRENT_SPECIFICATION_VERSION
|
|
86
|
+
s.specification_version = 2
|
|
87
|
+
|
|
88
|
+
if LibGems::Version.new(LibGems::VERSION) >= LibGems::Version.new('1.2.0') then
|
|
89
|
+
else
|
|
90
|
+
end
|
|
91
|
+
else
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
SPEC
|
|
95
|
+
|
|
96
|
+
spec_data.force_encoding 'UTF-8'
|
|
97
|
+
|
|
98
|
+
File.open spec_file, 'w' do |io| io.write spec_data end
|
|
99
|
+
|
|
100
|
+
spec = LibGems::SourceIndex.load_specification spec_file
|
|
101
|
+
|
|
102
|
+
pi = "\317\200"
|
|
103
|
+
pi.force_encoding 'UTF-8' if pi.respond_to? :force_encoding
|
|
104
|
+
|
|
105
|
+
assert_equal pi, spec.author
|
|
106
|
+
end if LibGems.ruby_version > LibGems::Version.new('1.9')
|
|
107
|
+
|
|
108
|
+
def test_self_load_specification_exception
|
|
109
|
+
spec_dir = File.join @gemhome, 'specifications'
|
|
110
|
+
|
|
111
|
+
FileUtils.mkdir_p spec_dir
|
|
112
|
+
|
|
113
|
+
spec_file = File.join spec_dir, 'a-1.gemspec'
|
|
114
|
+
|
|
115
|
+
File.open spec_file, 'w' do |fp|
|
|
116
|
+
fp.write 'raise Exception, "epic fail"'
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
use_ui @ui do
|
|
120
|
+
assert_equal nil, LibGems::SourceIndex.load_specification(spec_file)
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
assert_equal '', @ui.output
|
|
124
|
+
|
|
125
|
+
expected = <<-EOF
|
|
126
|
+
WARNING: #<Exception: epic fail>
|
|
127
|
+
raise Exception, "epic fail"
|
|
128
|
+
WARNING: Invalid .gemspec format in '#{spec_file}'
|
|
129
|
+
EOF
|
|
130
|
+
|
|
131
|
+
assert_equal expected, @ui.error
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
def test_self_load_specification_interrupt
|
|
135
|
+
spec_dir = File.join @gemhome, 'specifications'
|
|
136
|
+
|
|
137
|
+
FileUtils.mkdir_p spec_dir
|
|
138
|
+
|
|
139
|
+
spec_file = File.join spec_dir, 'a-1.gemspec'
|
|
140
|
+
|
|
141
|
+
File.open spec_file, 'w' do |fp|
|
|
142
|
+
fp.write 'raise Interrupt, "^C"'
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
use_ui @ui do
|
|
146
|
+
assert_raises Interrupt do
|
|
147
|
+
LibGems::SourceIndex.load_specification(spec_file)
|
|
148
|
+
end
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
assert_equal '', @ui.output
|
|
152
|
+
assert_equal '', @ui.error
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
def test_self_load_specification_syntax_error
|
|
156
|
+
spec_dir = File.join @gemhome, 'specifications'
|
|
157
|
+
|
|
158
|
+
FileUtils.mkdir_p spec_dir
|
|
159
|
+
|
|
160
|
+
spec_file = File.join spec_dir, 'a-1.gemspec'
|
|
161
|
+
|
|
162
|
+
File.open spec_file, 'w' do |fp|
|
|
163
|
+
fp.write '1 +'
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
use_ui @ui do
|
|
167
|
+
assert_equal nil, LibGems::SourceIndex.load_specification(spec_file)
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
assert_equal '', @ui.output
|
|
171
|
+
|
|
172
|
+
assert_match(/syntax error/, @ui.error)
|
|
173
|
+
assert_match(/1 \+/, @ui.error)
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
def test_self_load_specification_system_exit
|
|
177
|
+
spec_dir = File.join @gemhome, 'specifications'
|
|
178
|
+
|
|
179
|
+
FileUtils.mkdir_p spec_dir
|
|
180
|
+
|
|
181
|
+
spec_file = File.join spec_dir, 'a-1.gemspec'
|
|
182
|
+
|
|
183
|
+
File.open spec_file, 'w' do |fp|
|
|
184
|
+
fp.write 'raise SystemExit, "bye-bye"'
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
use_ui @ui do
|
|
188
|
+
assert_raises SystemExit do
|
|
189
|
+
LibGems::SourceIndex.load_specification(spec_file)
|
|
190
|
+
end
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
assert_equal '', @ui.output
|
|
194
|
+
assert_equal '', @ui.error
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
def test_create_from_directory
|
|
198
|
+
# TODO
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
def test_fetcher
|
|
202
|
+
assert_equal @fetcher, @source_index.fetcher
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
def test_find_missing
|
|
206
|
+
missing = @source_index.find_missing [@b2.full_name]
|
|
207
|
+
assert_equal [@b2.full_name], missing
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
def test_find_missing_none_missing
|
|
211
|
+
missing = @source_index.find_missing [
|
|
212
|
+
@a1.full_name, @a2.full_name, @c1_2.full_name
|
|
213
|
+
]
|
|
214
|
+
|
|
215
|
+
assert_equal [], missing
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
def test_find_name
|
|
219
|
+
assert_equal [@a1, @a2, @a3a], @source_index.find_name('a')
|
|
220
|
+
assert_equal [@a2], @source_index.find_name('a', '= 2')
|
|
221
|
+
assert_equal [], @source_index.find_name('bogusstring')
|
|
222
|
+
assert_equal [], @source_index.find_name('a', '= 3')
|
|
223
|
+
|
|
224
|
+
source_index = LibGems::SourceIndex.new
|
|
225
|
+
source_index.add_spec @a1
|
|
226
|
+
source_index.add_spec @a2
|
|
227
|
+
|
|
228
|
+
assert_equal [@a1], source_index.find_name(@a1.name, '= 1')
|
|
229
|
+
|
|
230
|
+
r1 = LibGems::Requirement.create '= 1'
|
|
231
|
+
assert_equal [@a1], source_index.find_name(@a1.name, r1)
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
def test_find_name_empty_cache
|
|
235
|
+
empty_source_index = LibGems::SourceIndex.new({})
|
|
236
|
+
assert_equal [], empty_source_index.find_name("foo")
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
def test_latest_specs
|
|
240
|
+
p1_ruby = quick_gem 'p', '1'
|
|
241
|
+
p1_platform = quick_gem 'p', '1' do |spec|
|
|
242
|
+
spec.platform = LibGems::Platform::CURRENT
|
|
243
|
+
end
|
|
244
|
+
|
|
245
|
+
a1_platform = quick_gem @a1.name, (@a1.version) do |s|
|
|
246
|
+
s.platform = LibGems::Platform.new 'x86-my_platform1'
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
a2_platform = quick_gem @a2.name, (@a2.version) do |s|
|
|
250
|
+
s.platform = LibGems::Platform.new 'x86-my_platform1'
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
a2_platform_other = quick_gem @a2.name, (@a2.version) do |s|
|
|
254
|
+
s.platform = LibGems::Platform.new 'x86-other_platform1'
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
a3_platform_other = quick_gem @a2.name, (@a2.version.bump) do |s|
|
|
258
|
+
s.platform = LibGems::Platform.new 'x86-other_platform1'
|
|
259
|
+
end
|
|
260
|
+
|
|
261
|
+
@source_index.add_spec p1_ruby
|
|
262
|
+
@source_index.add_spec p1_platform
|
|
263
|
+
@source_index.add_spec a1_platform
|
|
264
|
+
@source_index.add_spec a2_platform
|
|
265
|
+
@source_index.add_spec a2_platform_other
|
|
266
|
+
@source_index.add_spec a3_platform_other
|
|
267
|
+
|
|
268
|
+
expected = [
|
|
269
|
+
@a2.full_name,
|
|
270
|
+
a2_platform.full_name,
|
|
271
|
+
a3_platform_other.full_name,
|
|
272
|
+
@c1_2.full_name,
|
|
273
|
+
@a_evil9.full_name,
|
|
274
|
+
p1_ruby.full_name,
|
|
275
|
+
p1_platform.full_name,
|
|
276
|
+
].sort
|
|
277
|
+
|
|
278
|
+
latest_specs = @source_index.latest_specs.map { |s| s.full_name }.sort
|
|
279
|
+
|
|
280
|
+
assert_equal expected, latest_specs
|
|
281
|
+
end
|
|
282
|
+
|
|
283
|
+
def test_load_gems_in
|
|
284
|
+
spec_dir1 = File.join @gemhome, 'specifications'
|
|
285
|
+
spec_dir2 = File.join @tempdir, 'gemhome2', 'specifications'
|
|
286
|
+
|
|
287
|
+
FileUtils.rm_r spec_dir1
|
|
288
|
+
|
|
289
|
+
FileUtils.mkdir_p spec_dir1
|
|
290
|
+
FileUtils.mkdir_p spec_dir2
|
|
291
|
+
|
|
292
|
+
a1 = quick_gem 'a', '1' do |spec| spec.author = 'author 1' end
|
|
293
|
+
a2 = quick_gem 'a', '1' do |spec| spec.author = 'author 2' end
|
|
294
|
+
|
|
295
|
+
File.open File.join(spec_dir1, a1.spec_name), 'w' do |fp|
|
|
296
|
+
fp.write a1.to_ruby
|
|
297
|
+
end
|
|
298
|
+
|
|
299
|
+
File.open File.join(spec_dir2, a2.spec_name), 'w' do |fp|
|
|
300
|
+
fp.write a2.to_ruby
|
|
301
|
+
end
|
|
302
|
+
|
|
303
|
+
@source_index.load_gems_in spec_dir1, spec_dir2
|
|
304
|
+
|
|
305
|
+
assert_equal a1.author, @source_index.specification(a1.full_name).author
|
|
306
|
+
end
|
|
307
|
+
|
|
308
|
+
def test_outdated
|
|
309
|
+
util_setup_spec_fetcher
|
|
310
|
+
|
|
311
|
+
assert_equal [], @source_index.outdated
|
|
312
|
+
|
|
313
|
+
updated = quick_gem @a2.name, (@a2.version.bump)
|
|
314
|
+
util_setup_spec_fetcher updated
|
|
315
|
+
|
|
316
|
+
assert_equal [updated.name], @source_index.outdated
|
|
317
|
+
|
|
318
|
+
updated_platform = quick_gem @a2.name, (updated.version.bump) do |s|
|
|
319
|
+
s.platform = LibGems::Platform.new 'x86-other_platform1'
|
|
320
|
+
end
|
|
321
|
+
|
|
322
|
+
util_setup_spec_fetcher updated, updated_platform
|
|
323
|
+
|
|
324
|
+
assert_equal [updated_platform.name], @source_index.outdated
|
|
325
|
+
end
|
|
326
|
+
|
|
327
|
+
def test_prerelease_specs_kept_in_right_place
|
|
328
|
+
gem_a1_alpha = quick_gem 'abba', '1.a'
|
|
329
|
+
@source_index.add_spec gem_a1_alpha
|
|
330
|
+
|
|
331
|
+
refute @source_index.latest_specs.include?(gem_a1_alpha)
|
|
332
|
+
assert @source_index.find_name(gem_a1_alpha.full_name).empty?
|
|
333
|
+
assert @source_index.prerelease_specs.include?(gem_a1_alpha)
|
|
334
|
+
end
|
|
335
|
+
|
|
336
|
+
def test_refresh_bang
|
|
337
|
+
a1_spec = File.join @gemhome, "specifications", @a1.spec_name
|
|
338
|
+
|
|
339
|
+
FileUtils.mv a1_spec, @tempdir
|
|
340
|
+
|
|
341
|
+
source_index = LibGems::SourceIndex.from_installed_gems
|
|
342
|
+
|
|
343
|
+
refute source_index.gems.include?(@a1.full_name)
|
|
344
|
+
|
|
345
|
+
FileUtils.mv File.join(@tempdir, @a1.spec_name), a1_spec
|
|
346
|
+
|
|
347
|
+
source_index.refresh!
|
|
348
|
+
|
|
349
|
+
assert source_index.gems.include?(@a1.full_name)
|
|
350
|
+
end
|
|
351
|
+
|
|
352
|
+
def test_refresh_bang_not_from_dir
|
|
353
|
+
source_index = LibGems::SourceIndex.new
|
|
354
|
+
|
|
355
|
+
e = assert_raises RuntimeError do
|
|
356
|
+
source_index.refresh!
|
|
357
|
+
end
|
|
358
|
+
|
|
359
|
+
assert_equal 'source index not created from disk', e.message
|
|
360
|
+
end
|
|
361
|
+
|
|
362
|
+
def test_remove_extra
|
|
363
|
+
@source_index.add_spec @a1
|
|
364
|
+
@source_index.add_spec @a2
|
|
365
|
+
@source_index.add_spec @pl1
|
|
366
|
+
|
|
367
|
+
@source_index.remove_extra [@a1.full_name, @pl1.full_name]
|
|
368
|
+
|
|
369
|
+
assert_equal [@a1.full_name],
|
|
370
|
+
@source_index.gems.map { |n,s| n }.sort
|
|
371
|
+
end
|
|
372
|
+
|
|
373
|
+
def test_remove_extra_no_changes
|
|
374
|
+
gems = [@a1.full_name, @a2.full_name]
|
|
375
|
+
@source_index.add_spec @a1
|
|
376
|
+
@source_index.add_spec @a2
|
|
377
|
+
|
|
378
|
+
@source_index.remove_extra gems
|
|
379
|
+
|
|
380
|
+
assert_equal gems, @source_index.gems.map { |n,s| n }.sort
|
|
381
|
+
end
|
|
382
|
+
|
|
383
|
+
def test_remove_spec
|
|
384
|
+
deleted = @source_index.remove_spec 'a-1'
|
|
385
|
+
|
|
386
|
+
assert_equal %w[a-2 a-3.a a_evil-9 c-1.2],
|
|
387
|
+
@source_index.all_gems.values.map { |s| s.full_name }.sort
|
|
388
|
+
|
|
389
|
+
deleted = @source_index.remove_spec 'a-3.a'
|
|
390
|
+
|
|
391
|
+
assert_equal %w[a-2 a_evil-9 c-1.2],
|
|
392
|
+
@source_index.all_gems.values.map { |s| s.full_name }.sort
|
|
393
|
+
end
|
|
394
|
+
|
|
395
|
+
def test_search
|
|
396
|
+
requirement = LibGems::Requirement.create '= 9'
|
|
397
|
+
with_version = LibGems::Dependency.new(/^a/, requirement)
|
|
398
|
+
assert_equal [@a_evil9], @source_index.search(with_version)
|
|
399
|
+
|
|
400
|
+
with_default = LibGems::Dependency.new(/^a/, LibGems::Requirement.default)
|
|
401
|
+
assert_equal [@a1, @a2, @a3a, @a_evil9], @source_index.search(with_default)
|
|
402
|
+
|
|
403
|
+
c1_1_dep = LibGems::Dependency.new 'c', '~> 1.1'
|
|
404
|
+
assert_equal [@c1_2], @source_index.search(c1_1_dep)
|
|
405
|
+
end
|
|
406
|
+
|
|
407
|
+
def test_search_platform
|
|
408
|
+
util_set_arch 'x86-my_platform1'
|
|
409
|
+
|
|
410
|
+
a1 = quick_gem 'a', '1'
|
|
411
|
+
a1_mine = quick_gem 'a', '1' do |s|
|
|
412
|
+
s.platform = LibGems::Platform.new 'x86-my_platform1'
|
|
413
|
+
end
|
|
414
|
+
a1_other = quick_gem 'a', '1' do |s|
|
|
415
|
+
s.platform = LibGems::Platform.new 'x86-other_platform1'
|
|
416
|
+
end
|
|
417
|
+
|
|
418
|
+
si = LibGems::SourceIndex.new(a1.full_name => a1, a1_mine.full_name => a1_mine,
|
|
419
|
+
a1_other.full_name => a1_other)
|
|
420
|
+
|
|
421
|
+
dep = LibGems::Dependency.new 'a', LibGems::Requirement.new('1')
|
|
422
|
+
|
|
423
|
+
gems = si.search dep, true
|
|
424
|
+
|
|
425
|
+
assert_equal [a1, a1_mine], gems.sort
|
|
426
|
+
end
|
|
427
|
+
|
|
428
|
+
def test_signature
|
|
429
|
+
sig = @source_index.gem_signature('foo-1.2.3')
|
|
430
|
+
assert_equal 64, sig.length
|
|
431
|
+
assert_match(/^[a-f0-9]{64}$/, sig)
|
|
432
|
+
end
|
|
433
|
+
|
|
434
|
+
def test_specification
|
|
435
|
+
assert_equal @a1, @source_index.specification(@a1.full_name)
|
|
436
|
+
|
|
437
|
+
assert_nil @source_index.specification("foo-1.2.4")
|
|
438
|
+
end
|
|
439
|
+
|
|
440
|
+
def test_index_signature
|
|
441
|
+
sig = @source_index.index_signature
|
|
442
|
+
assert_match(/^[a-f0-9]{64}$/, sig)
|
|
443
|
+
end
|
|
444
|
+
|
|
445
|
+
def test_unzip
|
|
446
|
+
input = "x\234+\316\317MU(I\255(\001\000\021\350\003\232"
|
|
447
|
+
assert_equal 'some text', @source_index.unzip(input)
|
|
448
|
+
end
|
|
449
|
+
|
|
450
|
+
def util_setup_bulk_fetch(compressed)
|
|
451
|
+
source_index = @source_index.dump
|
|
452
|
+
|
|
453
|
+
if compressed then
|
|
454
|
+
@fetcher.data["#{@gem_repo}Marshal.#{@marshal_version}.Z"] = util_zip source_index
|
|
455
|
+
else
|
|
456
|
+
@fetcher.data["#{@gem_repo}Marshal.#{@marshal_version}"] = source_index
|
|
457
|
+
end
|
|
458
|
+
end
|
|
459
|
+
|
|
460
|
+
end
|
|
461
|
+
|