2016-02-01 12:43:26 +00:00
|
|
|
# frozen_string_literal: true
|
2021-06-02 12:32:47 +09:00
|
|
|
require_relative 'helper'
|
2015-07-02 02:36:23 +00:00
|
|
|
require 'rubygems/installer'
|
2013-11-19 00:34:13 +00:00
|
|
|
|
|
|
|
class TestGemResolverGitSpecification < Gem::TestCase
|
|
|
|
def setup
|
|
|
|
super
|
|
|
|
|
|
|
|
@set = Gem::Resolver::GitSet.new
|
|
|
|
@spec = Gem::Specification.new 'a', 1
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_equals2
|
|
|
|
g_spec_a = Gem::Resolver::GitSpecification.new @set, @spec
|
|
|
|
|
|
|
|
assert_equal g_spec_a, g_spec_a
|
|
|
|
|
|
|
|
spec_b = Gem::Specification.new 'b', 1
|
|
|
|
g_spec_b = Gem::Resolver::GitSpecification.new @set, spec_b
|
|
|
|
|
|
|
|
refute_equal g_spec_a, g_spec_b
|
|
|
|
|
|
|
|
g_set = Gem::Resolver::GitSet.new
|
|
|
|
g_spec_s = Gem::Resolver::GitSpecification.new g_set, @spec
|
|
|
|
|
|
|
|
refute_equal g_spec_a, g_spec_s
|
|
|
|
|
|
|
|
i_set = Gem::Resolver::IndexSet.new
|
|
|
|
source = Gem::Source.new @gem_repo
|
|
|
|
i_spec = Gem::Resolver::IndexSpecification.new(
|
|
|
|
i_set, 'a', v(1), source, Gem::Platform::RUBY)
|
|
|
|
|
|
|
|
refute_equal g_spec_a, i_spec
|
|
|
|
end
|
|
|
|
|
2014-09-14 03:30:02 +00:00
|
|
|
def test_add_dependency
|
|
|
|
git_gem 'a', 1
|
|
|
|
|
|
|
|
git_spec = Gem::Resolver::GitSpecification.new @set, @spec
|
|
|
|
|
|
|
|
b_dep = dep 'b'
|
|
|
|
|
|
|
|
git_spec.add_dependency b_dep
|
|
|
|
|
|
|
|
assert_equal [b_dep], git_spec.dependencies
|
|
|
|
end
|
|
|
|
|
2013-11-25 19:14:49 +00:00
|
|
|
def test_install
|
|
|
|
git_gem 'a', 1
|
|
|
|
|
|
|
|
git_spec = Gem::Resolver::GitSpecification.new @set, @spec
|
|
|
|
|
|
|
|
called = false
|
|
|
|
|
|
|
|
git_spec.install({}) do |installer|
|
|
|
|
called = installer
|
|
|
|
end
|
|
|
|
|
|
|
|
assert called
|
|
|
|
end
|
|
|
|
|
2013-11-30 23:27:52 +00:00
|
|
|
# functional test for Gem::Ext::Builder
|
|
|
|
|
|
|
|
def test_install_extension
|
2021-05-11 12:27:07 +09:00
|
|
|
pend if Gem.java_platform?
|
|
|
|
pend if /mswin/ =~ RUBY_PLATFORM && ENV.key?('GITHUB_ACTIONS') # not working from the beginning
|
2013-11-30 23:27:52 +00:00
|
|
|
name, _, repository, = git_gem 'a', 1 do |s|
|
|
|
|
s.extensions << 'ext/extconf.rb'
|
|
|
|
end
|
|
|
|
|
|
|
|
Dir.chdir 'git/a' do
|
|
|
|
FileUtils.mkdir_p 'ext/lib'
|
|
|
|
|
2018-02-06 02:58:35 +00:00
|
|
|
File.open 'ext/extconf.rb', 'w' do |io|
|
2013-11-30 23:27:52 +00:00
|
|
|
io.puts 'require "mkmf"'
|
|
|
|
io.puts 'create_makefile "a"'
|
|
|
|
end
|
|
|
|
|
|
|
|
FileUtils.touch 'ext/lib/b.rb'
|
|
|
|
|
|
|
|
system @git, 'add', 'ext/extconf.rb'
|
|
|
|
system @git, 'add', 'ext/lib/b.rb'
|
|
|
|
|
|
|
|
system @git, 'commit', '--quiet', '-m', 'Add extension files'
|
|
|
|
end
|
|
|
|
|
|
|
|
source = Gem::Source::Git.new name, repository, 'master', true
|
|
|
|
|
|
|
|
spec = source.specs.first
|
|
|
|
|
|
|
|
git_spec = Gem::Resolver::GitSpecification.new @set, spec, source
|
|
|
|
|
|
|
|
git_spec.install({})
|
|
|
|
|
2020-05-25 21:05:45 +09:00
|
|
|
assert_path_exist File.join git_spec.spec.extension_dir, 'b.rb'
|
2013-11-30 23:27:52 +00:00
|
|
|
end
|
|
|
|
|
2013-12-08 01:22:39 +00:00
|
|
|
def test_install_installed
|
|
|
|
git_gem 'a', 1
|
|
|
|
|
|
|
|
git_spec = Gem::Resolver::GitSpecification.new @set, @spec
|
|
|
|
|
|
|
|
git_spec.install({})
|
|
|
|
|
|
|
|
called = false
|
|
|
|
|
|
|
|
git_spec.install({}) do |installer|
|
|
|
|
called = installer
|
|
|
|
end
|
|
|
|
|
|
|
|
assert called
|
|
|
|
end
|
2013-11-19 00:34:13 +00:00
|
|
|
end
|