Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Move Gem::Future::Test to Gem::Test.

  • Loading branch information...
commit 633ae0ddfc5b2be268c49ce1413eab4eb0fa7103 1 parent e86c592
@jbarnette authored
View
4 Rakefile
@@ -5,7 +5,7 @@ task :default => :test
desc "Run the tests."
task :test do
tests = ENV["ONLY"] ? [ENV["ONLY"]] : Dir["test/test_*.rb"]
- flags = %w(-w -Ilib:. -I../rubygems/lib)
+ flags = %w(-w -Ilib:test -I../rubygems/lib)
flags.unshift "--disable-gems" if RUBY_VERSION > "1.9"
@@ -14,7 +14,7 @@ task :test do
ruby << RbConfig::CONFIG["EXEEXT"]
- requires = tests.map { |t| %Q(require "#{t}") }.join "; "
+ requires = tests.map { |t| %Q(require "./#{t}") }.join "; "
sh "#{ruby} #{flags.join ' '} -e '#{requires}'"
end
View
141 lib/rubygems/future/test.rb
@@ -1,141 +0,0 @@
-Dir["vendor/*/lib"].each { |lib| $: << File.expand_path(lib) }
-
-require "rubygems"
-
-Gem::DefaultUserInteraction.ui = Gem::SilentUI.new
-
-if ENV["COVERAGE"]
- require "simplecov"
-
- SimpleCov.start do
- add_filter "/test/"
- add_filter "/vendor/"
- end
-end
-
-require "fileutils"
-require "minitest/autorun"
-require "minitest/mock"
-require "rubygems/repo"
-require "tmpdir"
-
-module Gem
- module Future
- class Test < MiniTest::Unit::TestCase
-
- # Construct a new Gem::Dependency.
-
- def dep name, *requirements
- Gem::Dependency.new name, *requirements
- end
-
- # Construct a real live gem in a repo! Looks to use @repo first,
- # then at <tt>options[:repo]</tt>. Expects the default
- # implementation of Gem::Repo, which uses the filesystem. If
- # <tt>options[:cache]</tt> is true, a built version of the gem
- # will be put in the repo's cache dir. All files will be empty.
-
- def gem name, version = nil, options = nil, &block
- if Hash === version && !options
- options = version
- version = nil
- end
-
- options ||= {}
- version ||= "1.0.0"
-
- repo = options[:repo] || @repo
- repo or raise "Need a repo or @repo to make a gem."
-
- s = spec(name, version, &block)
-
- specpath = File.join repo.specdir, s.spec_name
- s.loaded_from = specpath
-
- FileUtils.mkdir_p File.dirname(specpath)
- open(specpath, "wb") { |f| f.write s.to_ruby }
-
- gempath = File.join repo.gemdir, s.full_name
- FileUtils.mkdir_p gempath
-
- s.files.each do |f|
- path = File.join gempath, f
- FileUtils.mkdir_p File.dirname(path)
- FileUtils.touch path
- end
-
- if options[:cache]
- FileUtils.mkdir_p repo.cachedir
- gemfile s, gempath, File.join(repo.cachedir, s.file_name)
- end
-
- repo.reset
- repo[name, version]
- end
-
- # Use +spec+ and the unpacked version of the spec in the
- # +source+ dir to create a .gem file and drop it in the
- # +destination+ directory. If a destination isn't specified the
- # file gets dropped in the current directory.
-
- def gemfile spec, source, destination = nil
- destination ||= File.expand_path "."
-
- require "rubygems/builder"
-
- Dir.chdir source do
- FileUtils.mv Gem::Builder.new(spec).build, destination
- end
-
- destination
- end
-
- # Create a real live repo on disk, in a temp dir. Cleaned up at
- # the end of +block+, which gets yielded the Gem::Repo
- # instance. any +extras+ are passed along to Gem::Repo.new.
-
- def repo *extras, &block
- old_repo = @repo if defined? @repo
- @repo = repo = Gem::Repo.new(Dir.mktmpdir, *extras)
-
- begin
- yield repo
- ensure
- @repo = old_repo
- FileUtils.rm_rf repo.home
- end
-
- repo
- end
-
- # Construct a new Gem::Requirement.
-
- def req *requirements
- return requirements.first if Gem::Requirement === requirements.first
- Gem::Requirement.create requirements
- end
-
- # Construct a new Gem::Specification.
-
- def spec name, version, &block
- Gem::Specification.new name, v(version) do |s|
- s.author = "RubyGems Tests"
- s.description = "A test gem."
- s.email = "rubygems@example.org"
- s.homepage = "http://example.com"
- s.platform = Gem::Platform::RUBY
- s.summary = "A test gem summary."
-
- yield s if block_given?
- end
- end
-
- # Construct a new Gem::Version.
-
- def v string
- Gem::Version.create string
- end
- end
- end
-end
-
View
138 test/rubygems/test.rb
@@ -0,0 +1,138 @@
+Dir["vendor/*/lib"].each { |lib| $: << File.expand_path(lib) }
+
+require "rubygems"
+
+Gem::DefaultUserInteraction.ui = Gem::SilentUI.new
+
+if ENV["COVERAGE"]
+ require "simplecov"
+
+ SimpleCov.start do
+ add_filter "/test/"
+ add_filter "/vendor/"
+ end
+end
+
+require "fileutils"
+require "minitest/autorun"
+require "minitest/mock"
+require "rubygems/repo"
+require "tmpdir"
+
+module Gem
+ class Test < MiniTest::Unit::TestCase
+
+ # Construct a new Gem::Dependency.
+
+ def dep name, *requirements
+ Gem::Dependency.new name, *requirements
+ end
+
+ # Construct a real live gem in a repo! Looks to use @repo first,
+ # then at <tt>options[:repo]</tt>. Expects the default
+ # implementation of Gem::Repo, which uses the filesystem. If
+ # <tt>options[:cache]</tt> is true, a built version of the gem
+ # will be put in the repo's cache dir. All files will be empty.
+
+ def gem name, version = nil, options = nil, &block
+ if Hash === version && !options
+ options = version
+ version = nil
+ end
+
+ options ||= {}
+ version ||= "1.0.0"
+
+ repo = options[:repo] || @repo
+ repo or raise "Need a repo or @repo to make a gem."
+
+ s = spec(name, version, &block)
+
+ specpath = File.join repo.specdir, s.spec_name
+ s.loaded_from = specpath
+
+ FileUtils.mkdir_p File.dirname(specpath)
+ open(specpath, "wb") { |f| f.write s.to_ruby }
+
+ gempath = File.join repo.gemdir, s.full_name
+ FileUtils.mkdir_p gempath
+
+ s.files.each do |f|
+ path = File.join gempath, f
+ FileUtils.mkdir_p File.dirname(path)
+ FileUtils.touch path
+ end
+
+ if options[:cache]
+ FileUtils.mkdir_p repo.cachedir
+ gemfile s, gempath, File.join(repo.cachedir, s.file_name)
+ end
+
+ repo.reset
+ repo[name, version]
+ end
+
+ # Use +spec+ and the unpacked version of the spec in the
+ # +source+ dir to create a .gem file and drop it in the
+ # +destination+ directory. If a destination isn't specified the
+ # file gets dropped in the current directory.
+
+ def gemfile spec, source, destination = nil
+ destination ||= File.expand_path "."
+
+ require "rubygems/builder"
+
+ Dir.chdir source do
+ FileUtils.mv Gem::Builder.new(spec).build, destination
+ end
+
+ destination
+ end
+
+ # Create a real live repo on disk, in a temp dir. Cleaned up at
+ # the end of +block+, which gets yielded the Gem::Repo
+ # instance. any +extras+ are passed along to Gem::Repo.new.
+
+ def repo *extras, &block
+ old_repo = @repo if defined? @repo
+ @repo = repo = Gem::Repo.new(Dir.mktmpdir, *extras)
+
+ begin
+ yield repo
+ ensure
+ @repo = old_repo
+ FileUtils.rm_rf repo.home
+ end
+
+ repo
+ end
+
+ # Construct a new Gem::Requirement.
+
+ def req *requirements
+ return requirements.first if Gem::Requirement === requirements.first
+ Gem::Requirement.create requirements
+ end
+
+ # Construct a new Gem::Specification.
+
+ def spec name, version, &block
+ Gem::Specification.new name, v(version) do |s|
+ s.author = "RubyGems Tests"
+ s.description = "A test gem."
+ s.email = "rubygems@example.org"
+ s.homepage = "http://example.com"
+ s.platform = Gem::Platform::RUBY
+ s.summary = "A test gem summary."
+
+ yield s if block_given?
+ end
+ end
+
+ # Construct a new Gem::Version.
+
+ def v string
+ Gem::Version.create string
+ end
+ end
+end
View
4 test/test_gem_collection.rb
@@ -1,8 +1,8 @@
-require "rubygems/future/test"
+require "rubygems/test"
require "rubygems/collection"
require "rubygems/info"
-class TestGemCollection < Gem::Future::Test
+class TestGemCollection < Gem::Test
def test_by
a = entry "foo", "1.0.0"
b = entry "foo", "2.0.0"
View
4 test/test_gem_globber.rb
@@ -1,7 +1,7 @@
-require "rubygems/future/test"
+require "rubygems/test"
require "rubygems/repo"
-class TestGemGlobber < Gem::Future::Test
+class TestGemGlobber < Gem::Test
def test_gem
repo do |r|
gem "foo" do |s|
View
4 test/test_gem_info.rb
@@ -1,8 +1,8 @@
-require "rubygems/future/test"
+require "rubygems/test"
require "rubygems/info"
require "rubygems/specification"
-class TestGemInfo < Gem::Future::Test
+class TestGemInfo < Gem::Test
def test_dependencies
assert_equal [], Gem::Info.new("foo", "1.0.0").dependencies
end
View
4 test/test_gem_installable.rb
@@ -1,7 +1,7 @@
-require "rubygems/future/test"
+require "rubygems/test"
require "rubygems/installable"
-class TestGemInstallable < Gem::Future::Test
+class TestGemInstallable < Gem::Test
include Gem::Installable
def test_install
View
4 test/test_gem_installable_file.rb
@@ -1,7 +1,7 @@
-require "rubygems/future/test"
+require "rubygems/test"
require "rubygems/installable/file"
-class TestGemInstallableFile < Gem::Future::Test
+class TestGemInstallableFile < Gem::Test
def test_install
repo do |source|
foo = gem "foo", "1.0.0", :cache => true
View
4 test/test_gem_repo.rb
@@ -1,9 +1,9 @@
-require "rubygems/future/test"
+require "rubygems/test"
require "rubygems/repo"
require "mocha"
-class TestGemRepo < Gem::Future::Test
+class TestGemRepo < Gem::Test
def setup
@old_load_path = $LOAD_PATH.dup
end
View
4 test/test_gem_resolver.rb
@@ -1,8 +1,8 @@
-require "rubygems/future/test"
+require "rubygems/test"
require "rubygems/repo"
require "rubygems/resolver"
-class TestGemResolver < Gem::Future::Test
+class TestGemResolver < Gem::Test
def test_specs_simplest
repo do |r|
# gem "foo"
Please sign in to comment.
Something went wrong with that request. Please try again.