mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
19bad26c5a
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25215 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
60 lines
1.6 KiB
Ruby
60 lines
1.6 KiB
Ruby
require_relative 'gemutilities'
|
|
require 'rubygems/indexer'
|
|
require 'rubygems/commands/mirror_command'
|
|
|
|
class TestGemCommandsMirrorCommand < RubyGemTestCase
|
|
|
|
def setup
|
|
super
|
|
|
|
@cmd = Gem::Commands::MirrorCommand.new
|
|
end
|
|
|
|
def test_execute
|
|
util_make_gems
|
|
|
|
gems_dir = File.join @tempdir, 'gems'
|
|
mirror = File.join @tempdir, 'mirror'
|
|
|
|
FileUtils.mkdir_p gems_dir
|
|
FileUtils.mkdir_p mirror
|
|
|
|
Dir[File.join(@gemhome, 'cache', '*.gem')].each do |gem|
|
|
FileUtils.mv gem, gems_dir
|
|
end
|
|
|
|
use_ui @ui do
|
|
Gem::Indexer.new(@tempdir).generate_index
|
|
end
|
|
|
|
orig_HOME = ENV['HOME']
|
|
ENV['HOME'] = @tempdir
|
|
Gem.instance_variable_set :@user_home, nil
|
|
|
|
File.open File.join(Gem.user_home, '.gemmirrorrc'), 'w' do |fp|
|
|
fp.puts "---"
|
|
# tempdir could be a drive+path (under windows)
|
|
if @tempdir.match(/[a-z]:/i)
|
|
fp.puts "- from: file:///#{@tempdir}"
|
|
else
|
|
fp.puts "- from: file://#{@tempdir}"
|
|
end
|
|
fp.puts " to: #{mirror}"
|
|
end
|
|
|
|
use_ui @ui do
|
|
@cmd.execute
|
|
end
|
|
|
|
assert File.exist?(File.join(mirror, 'gems', "#{@a1.full_name}.gem"))
|
|
assert File.exist?(File.join(mirror, 'gems', "#{@a2.full_name}.gem"))
|
|
assert File.exist?(File.join(mirror, 'gems', "#{@b2.full_name}.gem"))
|
|
assert File.exist?(File.join(mirror, 'gems', "#{@c1_2.full_name}.gem"))
|
|
assert File.exist?(File.join(mirror, "Marshal.#{@marshal_version}"))
|
|
ensure
|
|
orig_HOME.nil? ? ENV.delete('HOME') : ENV['HOME'] = orig_HOME
|
|
Gem.instance_variable_set :@user_home, nil
|
|
end
|
|
|
|
end if ''.respond_to? :to_xs
|
|
|