diff options
Diffstat (limited to 'test/rubygems/test_gem_ext_ext_conf_builder.rb')
-rw-r--r-- | test/rubygems/test_gem_ext_ext_conf_builder.rb | 69 |
1 files changed, 58 insertions, 11 deletions
diff --git a/test/rubygems/test_gem_ext_ext_conf_builder.rb b/test/rubygems/test_gem_ext_ext_conf_builder.rb index d9483df2de..4b03858a2a 100644 --- a/test/rubygems/test_gem_ext_ext_conf_builder.rb +++ b/test/rubygems/test_gem_ext_ext_conf_builder.rb @@ -1,4 +1,10 @@ -require_relative 'gemutilities' +###################################################################### +# This file is imported from the rubygems project. +# DO NOT make modifications in this repo. They _will_ be reverted! +# File a patch instead and assign it to Ryan Davis or Eric Hodel. +###################################################################### + +require "test/rubygems/gemutilities" require 'rubygems/ext' class TestGemExtExtConfBuilder < RubyGemTestCase @@ -28,19 +34,60 @@ class TestGemExtExtConfBuilder < RubyGemTestCase Gem::Ext::ExtConfBuilder.build 'extconf.rb', nil, @dest_path, output end - expected = [ - "ruby extconf.rb", - "creating Makefile\n", - "make", - "make: Nothing to be done for `all'.\n", - "make install", - "make: Nothing to be done for `install'.\n" - ] - assert_match(/^#{Gem.ruby} extconf.rb/, output[0]) assert_equal "creating Makefile\n", output[1] + case RUBY_PLATFORM + when /mswin/ then + assert_equal "nmake", output[2] + assert_equal "nmake install", output[4] + else + assert_equal "make", output[2] + assert_equal "make install", output[4] + end + end + + def test_class_build_rbconfig_make_prog + configure_args = RbConfig::CONFIG['configure_args'] + + File.open File.join(@ext, 'extconf.rb'), 'w' do |extconf| + extconf.puts "require 'mkmf'\ncreate_makefile 'foo'" + end + + output = [] + + Dir.chdir @ext do + Gem::Ext::ExtConfBuilder.build 'extconf.rb', nil, @dest_path, output + end + + assert_equal "creating Makefile\n", output[1] assert_equal make_command, output[2] - assert_equal make_command + " install", output[4] + assert_equal "#{make_command} install", output[4] + ensure + RbConfig::CONFIG['configure_args'] = configure_args + end + + def test_class_build_env_make + configure_args, env_make = RbConfig::CONFIG['configure_args'], ENV.delete('make') + RbConfig::CONFIG['configure_args'] = '' + ENV['make'] = 'anothermake' + + File.open File.join(@ext, 'extconf.rb'), 'w' do |extconf| + extconf.puts "require 'mkmf'\ncreate_makefile 'foo'" + end + + output = [] + + assert_raises Gem::InstallError do + Dir.chdir @ext do + Gem::Ext::ExtConfBuilder.build 'extconf.rb', nil, @dest_path, output + end + end + + assert_equal "creating Makefile\n", output[1] + assert_equal "anothermake", output[2] + ensure + RbConfig::CONFIG['configure_args'] = configure_args + ENV['make'] = env_make end def test_class_build_extconf_fail |