Permalink
Browse files

fix bug #23210 - move processing of build args out of gem binary so t…

…hey are handled correctly via API usage

git-svn-id: svn+ssh://rubyforge.org/var/svn/rubygems/trunk@1987 3d4018f9-ac1a-0410-99e9-8a154d859a19
  • Loading branch information...
1 parent 39dc93a commit 159af051f5b73a6c4d9d5fa92543aea651d7bfd2 @thewoolleyman thewoolleyman committed Jan 5, 2009
View
@@ -1,5 +1,21 @@
# -*- coding: utf-8 -*-
+2009-01-05 Chad Woolley <thewoolleyman@gmail.com>
+
+ * move processing of build args out of gem binary so they are handled correctly via API usage.
+ * lib/rubygems/command.rb: Add class accessor for build_args.
+ * lib/rubygems/ext/rake_builder.rb: Use Gem::Command.build_args instead of ARGV.
+ * lib/rubygems/ext/ext_conf_builder.rb: Use Gem::Command.build_args instead of ARGV.
+ * lib/rubygems/gem_runner.rb: Move build arg processing from gem binary.
+ * lib/rubygems/commands/contents_command.rb: Use nonzero return code (required to make tests pass).
+ * bin/gem: Move build arg processing to gem_runner.rb.
+ [RubyForge: bug #23210]
+
+ * lib/rubygems/config_file.rb: Fix --config-file option with no
+ equals and subsequent options to properly assign config file.
+ Previously config file was overwritten by subsequent option.
+ Fixes bug #16688.
+
2009-1-4 Daniel Berger <djberg96@gmail.com>
* lib/rubygems/installer.rb: Remove existing path if it already
exists before installing.
View
@@ -15,10 +15,7 @@ unless required_version.satisfied_by? Gem.ruby_version then
abort "Expected Ruby Version #{required_version}, was #{Gem.ruby_version}"
end
-# We need to preserve the original ARGV to use for passing gem options
-# to source gems. If there is a -- in the line, strip all options after
-# it...its for the source building process.
-args = !ARGV.include?("--") ? ARGV.clone : ARGV[0...ARGV.index("--")]
+args = ARGV.clone
begin
Gem::GemRunner.new.run args
@@ -288,6 +288,15 @@ def wrap(text, width)
##################################################################
# Class methods for Command.
class << self
+ # arguments used when building gems
+ def build_args
+ @build_args ||= []
+ end
+
+ def build_args=(value)
+ @build_args = value
+ end
+
def common_options
@common_options ||= []
end
@@ -61,7 +61,7 @@ def execute
s.each { |dir| say dir }
end
- terminate_interaction
+ terminate_interaction 1
end
files = options[:lib_only] ? gem_spec.lib_files : gem_spec.files
@@ -5,12 +5,13 @@
#++
require 'rubygems/ext/builder'
+require 'rubygems/command'
class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder
def self.build(extension, directory, dest_path, results)
cmd = "#{Gem.ruby} #{File.basename extension}"
- cmd << " #{ARGV.join ' '}" unless ARGV.empty?
+ cmd << " #{Gem::Command.build_args.join ' '}" unless Gem::Command.build_args.empty?
run cmd, results
@@ -5,13 +5,14 @@
#++
require 'rubygems/ext/builder'
+require 'rubygems/command'
class Gem::Ext::RakeBuilder < Gem::Ext::Builder
def self.build(extension, directory, dest_path, results)
if File.basename(extension) =~ /mkrf_conf/i then
cmd = "#{Gem.ruby} #{File.basename extension}"
- cmd << " #{ARGV.join " "}" unless ARGV.empty?
+ cmd << " #{Gem::Command.build_args.join " "}" unless Gem::Command.build_args.empty?
run cmd, results
end
@@ -24,6 +24,14 @@ def initialize(options={})
# Run the gem command with the following arguments.
def run(args)
start_time = Time.now
+ if args.include?('--')
+ # We need to preserve the original ARGV to use for passing gem options
+ # to source gems. If there is a -- in the line, strip all options after
+ # it...its for the source building process.
+ build_args = args[args.index("--") + 1...args.length]
+ args = args[0...args.index("--")]
+ end
+ Command.build_args = build_args if build_args
do_configuration(args)
cmd = @command_manager_class.instance
cmd.command_names.each do |command_name|
View
@@ -56,7 +56,8 @@ def terminated?
def terminate_interaction(status=0)
@terminated = true
- raise TermError
+ raise TermError unless status == 0
+ raise Gem::SystemExitException, status
end
end
@@ -30,5 +30,16 @@ def test_do_configuration
assert_equal %w[--all], Gem::DocManager.configured_args
end
+ def test_build_args__are_handled
+ Gem.clear_paths
+
+ gr = Gem::GemRunner.new
+ assert_raises(Gem::SystemExitException) do
+ gr.run(%W[--help -- --build_arg1 --build_arg2])
+ end
+
+ assert_equal %w[--build_arg1 --build_arg2], Gem::Command.build_args
+ end
+
end

0 comments on commit 159af05

Please sign in to comment.