diff options
author | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-05-30 13:01:35 +0000 |
---|---|---|
committer | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-05-30 13:01:35 +0000 |
commit | 8da8d4b043c37b53a69803c71ff36b478d4776d0 (patch) | |
tree | 7c8cec15645e74f19c88e4eb5b210b96174c7d03 /lib/rubygems/test_case.rb | |
parent | c5cb386eba6d9a2d9a8e6ffa8c30137d0c4660c1 (diff) |
Merge RubyGems 3.0.0.beta1.
* It drop to support < Ruby 2.2
* Cleanup deprecated methods and classes.
* Mark obsoleted methods to deprecate.
* and other enhancements.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63528 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/test_case.rb')
-rw-r--r-- | lib/rubygems/test_case.rb | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/lib/rubygems/test_case.rb b/lib/rubygems/test_case.rb index f03515cc8f..f1cd3d274c 100644 --- a/lib/rubygems/test_case.rb +++ b/lib/rubygems/test_case.rb @@ -2,7 +2,7 @@ # TODO: $SAFE = 1 begin - gem 'minitest', '~> 4.0' + gem 'minitest', '~> 5.0' rescue NoMethodError, Gem::LoadError # for ruby tests end @@ -18,6 +18,16 @@ begin rescue Gem::LoadError end +begin + require 'simplecov' + SimpleCov.start do + add_filter "/test/" + add_filter "/bundler/" + add_filter "/lib/rubygems/resolver/molinillo" + end +rescue LoadError +end + # We have to load these up front because otherwise we'll try to load # them while we're testing rubygems, and thus we can't actually load them. unless Gem::Dependency.new('rdoc', '>= 3.10').matching_specs.empty? @@ -86,7 +96,7 @@ end # # Tests are always run at a safe level of 1. -class Gem::TestCase < MiniTest::Unit::TestCase +class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Unit::TestCase) extend Gem::Deprecate @@ -595,7 +605,7 @@ class Gem::TestCase < MiniTest::Unit::TestCase def mu_pp(obj) s = String.new s = PP.pp obj, s - s = s.force_encoding(Encoding.default_external) if defined? Encoding + s = s.force_encoding(Encoding.default_external) s.chomp end @@ -819,8 +829,7 @@ class Gem::TestCase < MiniTest::Unit::TestCase spec end - # TODO: mark deprecate after replacing util_spec from new_spec - # deprecate :new_spec, :none, 2018, 12 + deprecate :new_spec, :none, 2018, 12 def new_default_spec(name, version, deps = nil, *files) spec = util_spec name, version, deps @@ -845,7 +854,7 @@ class Gem::TestCase < MiniTest::Unit::TestCase # Creates a spec with +name+, +version+. +deps+ can specify the dependency # or a +block+ can be given for full customization of the specification. - def util_spec name, version = 2, deps = nil # :yields: specification + def util_spec name, version = 2, deps = nil, *files # :yields: specification raise "deps or block, not both" if deps and block_given? spec = Gem::Specification.new do |s| @@ -858,6 +867,8 @@ class Gem::TestCase < MiniTest::Unit::TestCase s.summary = "this is a summary" s.description = "This is a test description" + s.files.push(*files) unless files.empty? + yield s if block_given? end @@ -869,6 +880,19 @@ class Gem::TestCase < MiniTest::Unit::TestCase end end + unless files.empty? then + write_file spec.spec_file do |io| + io.write spec.to_ruby_for_cache + end + + util_build_gem spec + + cache_file = File.join @tempdir, 'gems', "#{spec.full_name}.gem" + FileUtils.mkdir_p File.dirname cache_file + FileUtils.mv spec.cache_file, cache_file + FileUtils.rm spec.spec_file + end + Gem::Specification.reset return spec |