diff options
author | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-06-25 13:28:57 +0000 |
---|---|---|
committer | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-06-25 13:28:57 +0000 |
commit | 8cc31037224bca3e9b5c8e8f9ae206753a3822f8 (patch) | |
tree | 82ed31572cd801b8a5beae7f0577290f5f170034 /lib | |
parent | 7565d728b6f3910cf41ce106bf0b7bc2aef2bc77 (diff) | |
download | ruby-8cc31037224bca3e9b5c8e8f9ae206753a3822f8.tar.gz |
* lib/rubygems/ext/builder.rb (Gem::Ext::Builder.make): Pass
DESTDIR via command line to override what's in MAKEFLAGS. This
fixes an installation problem under a package building
environment where DESTDIR is specified in the (parent) command
line. [Fixes GH-327]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41629 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r-- | lib/rubygems/ext/builder.rb | 11 | ||||
-rw-r--r-- | lib/rubygems/test_case.rb | 58 |
2 files changed, 66 insertions, 3 deletions
diff --git a/lib/rubygems/ext/builder.rb b/lib/rubygems/ext/builder.rb index 9b6ad304a2..ab454b4ba1 100644 --- a/lib/rubygems/ext/builder.rb +++ b/lib/rubygems/ext/builder.rb @@ -23,9 +23,14 @@ class Gem::Ext::Builder make_program = (/mswin/ =~ RUBY_PLATFORM) ? 'nmake' : 'make' end - ['', ' install'].each do |target| - cmd = "#{make_program}#{target}" - run(cmd, results, "make#{target}") + ['', 'install'].each do |target| + # Pass DESTDIR via command line to override what's in MAKEFLAGS + cmd = [ + make_program, + '"DESTDIR=%s"' % ENV['DESTDIR'], + target + ].join(' ').rstrip + run(cmd, results, "make #{target}".rstrip) end end diff --git a/lib/rubygems/test_case.rb b/lib/rubygems/test_case.rb index 3da3173285..e92e5d868a 100644 --- a/lib/rubygems/test_case.rb +++ b/lib/rubygems/test_case.rb @@ -28,6 +28,7 @@ require 'rubygems/test_utilities' require 'pp' require 'zlib' require 'pathname' +require 'shellwords' Gem.load_yaml require 'rubygems/mock_gem_ui' @@ -89,6 +90,63 @@ class Gem::TestCase < MiniTest::Unit::TestCase refute File.exist?(path), msg end + def scan_make_command_lines(output) + output.scan(/^#{Regexp.escape make_command}(?:[[:blank:]].*)?$/) + end + + def parse_make_command_line(line) + command, *args = line.shellsplit + + targets = [] + macros = {} + + args.each do |arg| + case arg + when /\A(\w+)=/ + macros[$1] = $' + else + targets << arg + end + end + + targets << '' if targets.empty? + + { + :command => command, + :targets => targets, + :macros => macros, + } + end + + def assert_contains_make_command(target, output, msg = nil) + if output.match(/\n/) + msg = message(msg) { + 'Expected output containing make command "%s": %s' % [ + ('%s %s' % [make_command, target]).rstrip, + output.inspect + ] + } + else + msg = message(msg) { + 'Expected make command "%s": %s' % [ + ('%s %s' % [make_command, target]).rstrip, + output.inspect + ] + } + end + + assert scan_make_command_lines(output).any? { |line| + make = parse_make_command_line(line) + + if make[:targets].include?(target) + yield make, line if block_given? + true + else + false + end + }, msg + end + include Gem::DefaultUserInteraction undef_method :default_test if instance_methods.include? 'default_test' or |