2007-11-10 02:48:56 -05:00
|
|
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
|
|
|
require 'rubygems/ext'
|
|
|
|
|
|
|
|
class TestGemExtRakeBuilder < RubyGemTestCase
|
|
|
|
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"
|
|
|
|
|
2007-11-10 02:48:56 -05:00
|
|
|
expected = [
|
2008-07-01 02:01:15 -04:00
|
|
|
"#{@@ruby} mkrf_conf.rb",
|
2007-11-10 02:48:56 -05:00
|
|
|
"",
|
2008-07-01 02:01:15 -04:00
|
|
|
"#{@@rake} RUBYARCHDIR=#{@dest_path} RUBYLIBDIR=#{@dest_path}",
|
2007-11-10 02:48:56 -05:00
|
|
|
"(in #{realdir})\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
|
|
|
|
|
|
|
|
expected = <<-EOF.strip
|
|
|
|
rake failed:
|
|
|
|
|
2008-07-01 02:01:15 -04:00
|
|
|
#{@@ruby} mkrf_conf.rb
|
2007-11-10 02:48:56 -05:00
|
|
|
|
2008-07-01 02:01:15 -04:00
|
|
|
#{@@rake} RUBYARCHDIR=#{@dest_path} RUBYLIBDIR=#{@dest_path}
|
2007-11-10 02:48:56 -05:00
|
|
|
EOF
|
|
|
|
|
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
|
|
|
|
|