2011-01-28 18:46:47 -05:00
|
|
|
require 'rubygems/test_case'
|
2007-11-10 02:48:56 -05:00
|
|
|
require 'rubygems/ext'
|
|
|
|
|
2011-01-28 18:46:47 -05:00
|
|
|
class TestGemExtRakeBuilder < Gem::TestCase
|
2007-11-10 02:48:56 -05:00
|
|
|
def setup
|
|
|
|
super
|
|
|
|
|
|
|
|
@ext = File.join @tempdir, 'ext'
|
|
|
|
@dest_path = File.join @tempdir, 'prefix'
|
|
|
|
|
|
|
|
FileUtils.mkdir_p @ext
|
|
|
|
FileUtils.mkdir_p @dest_path
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_class_build
|
|
|
|
File.open File.join(@ext, 'mkrf_conf.rb'), 'w' do |mkrf_conf|
|
|
|
|
mkrf_conf.puts <<-EO_MKRF
|
|
|
|
File.open("Rakefile","w") do |f|
|
|
|
|
f.puts "task :default"
|
|
|
|
end
|
|
|
|
EO_MKRF
|
|
|
|
end
|
|
|
|
|
|
|
|
output = []
|
|
|
|
realdir = nil # HACK /tmp vs. /private/tmp
|
|
|
|
|
2012-11-29 01:52:18 -05:00
|
|
|
build_rake_in do |rake|
|
2008-07-01 08:33:11 -04:00
|
|
|
Dir.chdir @ext do
|
|
|
|
realdir = Dir.pwd
|
|
|
|
Gem::Ext::RakeBuilder.build 'mkrf_conf.rb', nil, @dest_path, output
|
|
|
|
end
|
2007-11-10 02:48:56 -05:00
|
|
|
|
2012-11-29 01:52:18 -05:00
|
|
|
output = output.join "\n"
|
2008-09-25 06:13:50 -04:00
|
|
|
|
2012-11-29 01:52:18 -05:00
|
|
|
refute_match %r%^rake failed:%, output
|
|
|
|
assert_match %r%^#{Regexp.escape @@ruby} mkrf_conf\.rb%, output
|
|
|
|
assert_match %r%^#{Regexp.escape rake} RUBYARCHDIR=#{Regexp.escape @dest_path} RUBYLIBDIR=#{Regexp.escape @dest_path}%, output
|
|
|
|
end
|
2007-11-10 02:48:56 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_class_build_fail
|
|
|
|
File.open File.join(@ext, 'mkrf_conf.rb'), 'w' do |mkrf_conf|
|
|
|
|
mkrf_conf.puts <<-EO_MKRF
|
|
|
|
File.open("Rakefile","w") do |f|
|
|
|
|
f.puts "task :default do abort 'fail' end"
|
|
|
|
end
|
2012-11-29 01:52:18 -05:00
|
|
|
EO_MKRF
|
2007-11-10 02:48:56 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
output = []
|
|
|
|
|
2012-11-29 01:52:18 -05:00
|
|
|
build_rake_in(false) do |rake|
|
|
|
|
error = assert_raises Gem::InstallError do
|
2008-07-01 08:33:11 -04:00
|
|
|
Dir.chdir @ext do
|
|
|
|
Gem::Ext::RakeBuilder.build "mkrf_conf.rb", nil, @dest_path, output
|
|
|
|
end
|
2007-11-10 02:48:56 -05:00
|
|
|
end
|
|
|
|
|
2012-11-29 01:52:18 -05:00
|
|
|
assert_match %r%^rake failed:%, error.message
|
|
|
|
assert_match %r%^#{Regexp.escape @@ruby} mkrf_conf\.rb%, error.message
|
|
|
|
assert_match %r%^#{Regexp.escape rake} RUBYARCHDIR=#{Regexp.escape @dest_path} RUBYLIBDIR=#{Regexp.escape @dest_path}%, error.message
|
|
|
|
end
|
2007-11-10 02:48:56 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|