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
|
|
|
|
|
2008-07-01 08:33:11 -04:00
|
|
|
build_rake_in do
|
|
|
|
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
|
|
|
end
|
|
|
|
|
2008-09-25 06:13:50 -04:00
|
|
|
output = output.join "\n"
|
|
|
|
|
2008-10-25 18:58:43 -04:00
|
|
|
refute_match %r%^rake failed:%, output
|
2008-09-25 06:13:50 -04:00
|
|
|
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
|
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
|
|
|
|
EO_MKRF
|
|
|
|
end
|
|
|
|
|
|
|
|
output = []
|
|
|
|
|
2008-10-25 18:58:43 -04:00
|
|
|
error = assert_raises Gem::InstallError do
|
2008-07-01 08:33:11 -04:00
|
|
|
build_rake_in do
|
|
|
|
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
|
|
|
|
end
|
|
|
|
|
2008-09-25 06:13:50 -04: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
|
2007-11-10 02:48:56 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|