summaryrefslogtreecommitdiff
path: root/test/rubygems
diff options
context:
space:
mode:
authorhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-01-24 02:38:57 +0000
committerhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-01-24 02:38:57 +0000
commit5d438215365e1a5dc3da7172a511a335aa58a5b4 (patch)
tree72ac80942856be3a5370dea6458f3b6dfce671e4 /test/rubygems
parent6219b68fb53a77a221f615d47dde83fea0a7e7c8 (diff)
Update Rubygems 2.6.10
* https://github.com/rubygems/rubygems/commit/2ee5bf9fd3bd7649d3e244bc40107ff32070ef47 * https://github.com/rubygems/rubygems/commit/be510dd4097e65c6a256a6e173d6b724a3a96472 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57412 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rubygems')
-rw-r--r--test/rubygems/test_gem.rb2
-rw-r--r--test/rubygems/test_gem_ext_ext_conf_builder.rb23
-rw-r--r--test/rubygems/test_gem_ext_rake_builder.rb51
-rw-r--r--test/rubygems/test_gem_remote_fetcher.rb4
-rw-r--r--test/rubygems/test_gem_server.rb16
-rw-r--r--test/rubygems/test_gem_specification.rb2
-rw-r--r--test/rubygems/test_gem_stub_specification.rb61
-rw-r--r--test/rubygems/test_gem_version.rb6
-rw-r--r--test/rubygems/test_require.rb25
9 files changed, 170 insertions, 20 deletions
diff --git a/test/rubygems/test_gem.rb b/test/rubygems/test_gem.rb
index 787350727f..e1ebebffb5 100644
--- a/test/rubygems/test_gem.rb
+++ b/test/rubygems/test_gem.rb
@@ -1451,6 +1451,7 @@ class TestGem < Gem::TestCase
ENV['RUBYGEMS_GEMDEPS'] = "-"
out = `#{Gem.ruby.dup.untaint} -I "#{LIB_PATH.untaint}" -rubygems -e "p Gem.loaded_specs.values.map(&:full_name).sort"`
+ out.sub!(/, "openssl-#{Gem::Version::VERSION_PATTERN}"/, "")
assert_equal '["a-1", "b-1", "c-1"]', out.strip
end
@@ -1484,6 +1485,7 @@ class TestGem < Gem::TestCase
out = Dir.chdir "sub1" do
`#{Gem.ruby.dup.untaint} -I "#{LIB_PATH.untaint}" -rubygems -e "p Gem.loaded_specs.values.map(&:full_name).sort"`
end
+ out.sub!(/, "openssl-#{Gem::Version::VERSION_PATTERN}"/, "")
Dir.rmdir "sub1"
diff --git a/test/rubygems/test_gem_ext_ext_conf_builder.rb b/test/rubygems/test_gem_ext_ext_conf_builder.rb
index f5d10fae50..b43ebf00d9 100644
--- a/test/rubygems/test_gem_ext_ext_conf_builder.rb
+++ b/test/rubygems/test_gem_ext_ext_conf_builder.rb
@@ -111,6 +111,29 @@ class TestGemExtExtConfBuilder < Gem::TestCase
assert_match(/^#{Gem.ruby}.* extconf.rb/, output[1])
assert_match(File.join(@dest_path, 'mkmf.log'), output[4])
+ assert_includes(output, "To see why this extension failed to compile, please check the mkmf.log which can be found here:\n")
+
+ assert_path_exists File.join @dest_path, 'mkmf.log'
+ end
+
+ def test_class_build_extconf_success_without_warning
+ if vc_windows? && !nmake_found?
+ skip("test_class_build_extconf_fail skipped - nmake not found")
+ end
+
+ File.open File.join(@ext, 'extconf.rb'), 'w' do |extconf|
+ extconf.puts "require 'mkmf'"
+ extconf.puts "File.open('mkmf.log', 'w'){|f| f.write('a')}"
+ extconf.puts "create_makefile 'foo'"
+ end
+
+ output = []
+
+ Dir.chdir @ext do
+ Gem::Ext::ExtConfBuilder.build 'extconf.rb', nil, @dest_path, output
+ end
+
+ refute_includes(output, "To see why this extension failed to compile, please check the mkmf.log which can be found here:\n")
assert_path_exists File.join @dest_path, 'mkmf.log'
end
diff --git a/test/rubygems/test_gem_ext_rake_builder.rb b/test/rubygems/test_gem_ext_rake_builder.rb
index b728f8f30a..9f59f51660 100644
--- a/test/rubygems/test_gem_ext_rake_builder.rb
+++ b/test/rubygems/test_gem_ext_rake_builder.rb
@@ -14,14 +14,7 @@ class TestGemExtRakeBuilder < Gem::TestCase
end
def test_class_build
- File.open File.join(@ext, 'mkrf_conf.rb'), 'w' do |mkrf_conf|
- mkrf_conf.puts <<-EO_MKRF
- File.open("Rakefile","w") do |f|
- f.puts "task :default"
- end
- EO_MKRF
- end
-
+ create_temp_mkrf_file('task :default')
output = []
realdir = nil # HACK /tmp vs. /private/tmp
@@ -39,15 +32,31 @@ class TestGemExtRakeBuilder < Gem::TestCase
end
end
- def test_class_build_fail
- File.open File.join(@ext, 'mkrf_conf.rb'), 'w' do |mkrf_conf|
- mkrf_conf.puts <<-EO_MKRF
- File.open("Rakefile","w") do |f|
- f.puts "task :default do abort 'fail' end"
- end
- EO_MKRF
+ # https://github.com/rubygems/rubygems/pull/1819
+ #
+ # It should not fail with a non-empty args list either
+ def test_class_build_with_args
+ create_temp_mkrf_file('task :default')
+ output = []
+ realdir = nil # HACK /tmp vs. /private/tmp
+
+ build_rake_in do |rake|
+ Dir.chdir @ext do
+ realdir = Dir.pwd
+ non_empty_args_list = ['']
+ Gem::Ext::RakeBuilder.build 'mkrf_conf.rb', nil, @dest_path, output, non_empty_args_list
+ end
+
+ output = output.join "\n"
+
+ refute_match %r%^rake failed:%, output
+ assert_match %r%^#{Regexp.escape @@ruby} mkrf_conf\.rb%, output
+ assert_match %r%^#{Regexp.escape rake} RUBYARCHDIR=#{Regexp.escape @dest_path} RUBYLIBDIR=#{Regexp.escape @dest_path}%, output
end
+ end
+ def test_class_build_fail
+ create_temp_mkrf_file("task :default do abort 'fail' end")
output = []
build_rake_in(false) do |rake|
@@ -60,6 +69,14 @@ class TestGemExtRakeBuilder < Gem::TestCase
assert_match %r%^rake failed%, error.message
end
end
-
+
+ def create_temp_mkrf_file(rakefile_content)
+ File.open File.join(@ext, 'mkrf_conf.rb'), 'w' do |mkrf_conf|
+ mkrf_conf.puts <<-EO_MKRF
+ File.open("Rakefile","w") do |f|
+ f.puts "#{rakefile_content}"
+ end
+ EO_MKRF
+ end
+ end
end
-
diff --git a/test/rubygems/test_gem_remote_fetcher.rb b/test/rubygems/test_gem_remote_fetcher.rb
index ca62a8342e..cb994462cd 100644
--- a/test/rubygems/test_gem_remote_fetcher.rb
+++ b/test/rubygems/test_gem_remote_fetcher.rb
@@ -163,7 +163,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
fetcher = Gem::RemoteFetcher.new nil
@fetcher = fetcher
def fetcher.request(uri, request_class, last_modified = nil)
- raise SocketError, "tarded"
+ raise SocketError, "oops"
end
uri = 'http://gems.example.com/yaml'
@@ -171,7 +171,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
fetcher.fetch_size uri
end
- assert_equal "SocketError: tarded (#{uri})", e.message
+ assert_equal "SocketError: oops (#{uri})", e.message
end
def test_no_proxy
diff --git a/test/rubygems/test_gem_server.rb b/test/rubygems/test_gem_server.rb
index 0ece6d67ef..4873fac5b6 100644
--- a/test/rubygems/test_gem_server.rb
+++ b/test/rubygems/test_gem_server.rb
@@ -392,6 +392,22 @@ class TestGemServer < Gem::TestCase
Marshal.load(Gem.gunzip(@res.body))
end
+ def test_uri_encode
+ url_safe = @server.uri_encode 'http://rubyonrails.org/">malicious_content</a>'
+ assert_equal url_safe, 'http://rubyonrails.org/%22%3Emalicious_content%3C/a%3E'
+ end
+
+ # Regression test for issue #1793: incorrect URL encoding.
+ # Checking that no URLs have had '://' incorrectly encoded
+ def test_regression_1793
+ data = StringIO.new "GET / HTTP/1.0\r\n\r\n"
+ @req.parse data
+
+ @server.root @req, @res
+
+ refute_match %r|%3A%2F%2F|, @res.body
+ end
+
def util_listen
webrick = Object.new
webrick.instance_variable_set :@listeners, []
diff --git a/test/rubygems/test_gem_specification.rb b/test/rubygems/test_gem_specification.rb
index 2c0ea770b5..d43289d745 100644
--- a/test/rubygems/test_gem_specification.rb
+++ b/test/rubygems/test_gem_specification.rb
@@ -1260,7 +1260,7 @@ dependencies: []
s.version = '1'
end
- spec.instance_variable_set :@licenses, Object.new.singleton_class
+ spec.instance_variable_set :@licenses, (class << (Object.new);self;end)
spec.loaded_from = '/path/to/file'
e = assert_raises Gem::FormatException do
diff --git a/test/rubygems/test_gem_stub_specification.rb b/test/rubygems/test_gem_stub_specification.rb
index 4cba13e139..5316449fba 100644
--- a/test/rubygems/test_gem_stub_specification.rb
+++ b/test/rubygems/test_gem_stub_specification.rb
@@ -33,6 +33,20 @@ class TestStubSpecification < Gem::TestCase
assert_equal %w[ext/stub_e/extconf.rb], stub.extensions
end
+ def test_initialize_version
+ stub = stub_with_version
+
+ assert_equal 'stub_v', stub.name
+ assert_equal v(2), stub.version
+ end
+
+ def test_initialize_with_empty_version
+ stub = stub_without_version
+
+ assert_equal 'stub_v', stub.name
+ assert_equal v(0), stub.version
+ end
+
def test_initialize_missing_stubline
stub = Gem::StubSpecification.gemspec_stub(BAR, @base_dir, @gems_dir)
assert_equal "bar", stub.name
@@ -164,6 +178,53 @@ class TestStubSpecification < Gem::TestCase
assert stub.to_spec.instance_variable_get :@ignored
end
+ def stub_with_version
+ spec = File.join @gemhome, 'specifications', 'stub_e-2.gemspec'
+ open spec, 'w' do |io|
+ io.write <<-STUB
+# -*- encoding: utf-8 -*-
+# stub: stub_v 2 ruby lib
+
+Gem::Specification.new do |s|
+ s.name = 'stub_v'
+ s.version = Gem::Version.new '2'
+end
+ STUB
+
+ io.flush
+
+ stub = Gem::StubSpecification.gemspec_stub io.path, @gemhome, File.join(@gemhome, 'gems')
+
+ yield stub if block_given?
+
+ return stub
+ end
+ end
+
+ def stub_without_version
+ spec = File.join @gemhome, 'specifications', 'stub-2.gemspec'
+ open spec, 'w' do |io|
+ io.write <<-STUB
+# -*- encoding: utf-8 -*-
+# stub: stub_v ruby lib
+
+Gem::Specification.new do |s|
+ s.name = 'stub_v'
+ s.version = ""
+end
+ STUB
+
+ io.flush
+
+ stub = Gem::StubSpecification.gemspec_stub io.path, @gemhome, File.join(@gemhome, 'gems')
+
+ yield stub if block_given?
+
+ return stub
+ end
+
+ end
+
def stub_with_extension
spec = File.join @gemhome, 'specifications', 'stub_e-2.gemspec'
open spec, 'w' do |io|
diff --git a/test/rubygems/test_gem_version.rb b/test/rubygems/test_gem_version.rb
index 9898669ce6..1897d44905 100644
--- a/test/rubygems/test_gem_version.rb
+++ b/test/rubygems/test_gem_version.rb
@@ -91,6 +91,12 @@ class TestGemVersion < Gem::TestCase
end
end
+ def test_empty_version
+ ["", " ", " "].each do |empty|
+ assert_equal "0", Gem::Version.new(empty).version
+ end
+ end
+
def test_prerelease
assert_prerelease "1.2.0.a"
assert_prerelease "2.9.b"
diff --git a/test/rubygems/test_require.rb b/test/rubygems/test_require.rb
index 04cbc094d8..dd606e44d4 100644
--- a/test/rubygems/test_require.rb
+++ b/test/rubygems/test_require.rb
@@ -341,6 +341,31 @@ class TestGemRequire < Gem::TestCase
Kernel::RUBYGEMS_ACTIVATION_MONITOR.exit
end
+ def test_require_when_gem_defined
+ default_gem_spec = new_default_spec("default", "2.0.0.0",
+ nil, "default/gem.rb")
+ install_default_specs(default_gem_spec)
+ c = Class.new do
+ def self.gem(*args)
+ raise "received #gem with #{args.inspect}"
+ end
+ end
+ assert c.send(:require, "default/gem")
+ assert_equal %w(default-2.0.0.0), loaded_spec_names
+ end
+
+ def test_require_default_when_gem_defined
+ a = new_spec("a", "1", nil, "lib/a.rb")
+ install_specs a
+ c = Class.new do
+ def self.gem(*args)
+ raise "received #gem with #{args.inspect}"
+ end
+ end
+ assert c.send(:require, "a")
+ assert_equal %w(a-1), loaded_spec_names
+ end
+
def silence_warnings
old_verbose, $VERBOSE = $VERBOSE, false
yield