2
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
5
class TestGemExtRakeBuilder < RubyGemTestCase
10
@ext = File.join @tempdir, 'ext'
11
@dest_path = File.join @tempdir, 'prefix'
13
FileUtils.mkdir_p @ext
14
FileUtils.mkdir_p @dest_path
18
File.open File.join(@ext, 'mkrf_conf.rb'), 'w' do |mkrf_conf|
19
mkrf_conf.puts <<-EO_MKRF
20
File.open("Rakefile","w") do |f|
21
f.puts "task :default"
27
realdir = nil # HACK /tmp vs. /private/tmp
31
Gem::Ext::RakeBuilder.build 'mkrf_conf.rb', nil, @dest_path, output
35
"#{Gem.ruby} mkrf_conf.rb",
37
"rake RUBYARCHDIR=#{@dest_path} RUBYLIBDIR=#{@dest_path}",
41
assert_equal expected, output
44
def test_class_build_fail
45
File.open File.join(@ext, 'mkrf_conf.rb'), 'w' do |mkrf_conf|
46
mkrf_conf.puts <<-EO_MKRF
47
File.open("Rakefile","w") do |f|
48
f.puts "task :default do abort 'fail' end"
55
error = assert_raise Gem::InstallError do
57
Gem::Ext::RakeBuilder.build "mkrf_conf.rb", nil, @dest_path, output
61
expected = <<-EOF.strip
64
#{Gem.ruby} mkrf_conf.rb
66
rake RUBYARCHDIR=#{@dest_path} RUBYLIBDIR=#{@dest_path}
69
assert_equal expected, error.message.split("\n")[0..4].join("\n")