diff options
author | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-11-19 00:34:13 +0000 |
---|---|---|
committer | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-11-19 00:34:13 +0000 |
commit | a7fa4d5d9aab150ad4b0c3f3217fe444df69f527 (patch) | |
tree | 88ab96d22f7228b556337aa7c34042d4fd279394 /lib/rubygems/test_case.rb | |
parent | e7ec3dad907f2c77f17faddb40a98b2ef4523222 (diff) |
* lib/rubygems: Update to RubyGems master 6a3d9f9. Changes include:
Compatibly renamed Gem::DependencyResolver to Gem::Resolver.
Added support for git gems in gem.deps.rb and Gemfile.
Fixed resolver bugs.
* test/rubygems: ditto.
* lib/rubygems/LICENSE.txt: Updated to license from RubyGems trunk.
[ruby-trunk - Bug #9086]
* lib/rubygems/commands/which_command.rb: RubyGems now indicates
failure when any file is missing. [ruby-trunk - Bug #9004]
* lib/rubygems/ext/builder: Extensions are now installed into the
extension install directory and the first directory in the require
path from the gem. This allows backwards compatibility with msgpack
and other gems that calculate full require paths.
[ruby-trunk - Bug #9106]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43714 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/test_case.rb')
-rw-r--r-- | lib/rubygems/test_case.rb | 70 |
1 files changed, 65 insertions, 5 deletions
diff --git a/lib/rubygems/test_case.rb b/lib/rubygems/test_case.rb index b04cbfc1f3..d1b471f619 100644 --- a/lib/rubygems/test_case.rb +++ b/lib/rubygems/test_case.rb @@ -233,6 +233,8 @@ class Gem::TestCase < MiniTest::Unit::TestCase ruby end + @git = ENV['GIT'] || 'git' + Gem.ensure_gem_subdirectories @gemhome @orig_LOAD_PATH = $LOAD_PATH.dup @@ -373,6 +375,64 @@ class Gem::TestCase < MiniTest::Unit::TestCase end ## + # A git_gem is used with a gem dependencies file. The gem created here + # has no files, just a gem specification for the given +name+ and +version+. + # + # Yields the +specification+ to the block, if given + + def git_gem name = 'a', version = 1 + have_git? + + directory = File.join 'git', name + directory = File.expand_path directory + + git_spec = Gem::Specification.new name, version do |specification| + yield specification if block_given? + end + + FileUtils.mkdir_p directory + + gemspec = "#{name}.gemspec" + + open File.join(directory, gemspec), 'w' do |io| + io.write git_spec.to_ruby + end + + head = nil + + Dir.chdir directory do + unless File.exist? '.git' then + system @git, 'init', '--quiet' + system @git, 'config', 'user.name', 'RubyGems Tests' + system @git, 'config', 'user.email', 'rubygems@example' + end + + system @git, 'add', gemspec + system @git, 'commit', '-a', '-m', 'a non-empty commit message', '--quiet' + head = Gem::Util.popen('git', 'rev-parse', 'master').strip + end + + return name, git_spec.version, directory, head + end + + ## + # Skips this test unless you have a git executable + + def have_git? + return if in_path? @git + + skip 'cannot find git executable, use GIT environment variable to set' + end + + def in_path? executable # :nodoc: + return true if %r%\A([A-Z]:|/)% =~ executable and File.exist? executable + + ENV['PATH'].split(File::PATH_SEPARATOR).any? do |directory| + File.exist? File.join directory, executable + end + end + + ## # Builds and installs the Gem::Specification +spec+ def install_gem spec, options = {} @@ -1082,21 +1142,21 @@ Also, a list: end ## - # Constructs a Gem::DependencyResolver::DependencyRequest from a + # Constructs a Gem::Resolver::DependencyRequest from a # Gem::Dependency +dep+, a +from_name+ and +from_version+ requesting the # dependency and a +parent+ DependencyRequest def dependency_request dep, from_name, from_version, parent = nil remote = Gem::Source.new @uri - parent ||= Gem::DependencyResolver::DependencyRequest.new \ + parent ||= Gem::Resolver::DependencyRequest.new \ dep, nil - spec = Gem::DependencyResolver::IndexSpecification.new \ + spec = Gem::Resolver::IndexSpecification.new \ nil, from_name, from_version, remote, Gem::Platform::RUBY - activation = Gem::DependencyResolver::ActivationRequest.new spec, parent + activation = Gem::Resolver::ActivationRequest.new spec, parent - Gem::DependencyResolver::DependencyRequest.new dep, activation + Gem::Resolver::DependencyRequest.new dep, activation end ## |