From 86af0ef6d793b85068a44fb3407b23c9c9b09bc7 Mon Sep 17 00:00:00 2001 From: Eric Hodel Date: Mon, 1 Dec 2014 21:35:22 -0800 Subject: [PATCH] Revert "Stop editing ARGV" This reverts commit a36505d33f873f8f475a28dc4fc48a913b82e8eb. This caused issues with tools that used rake across fork boundaries. Fixes rails/spring#366 Possibly also #4 --- History.rdoc | 9 +++++++++ lib/rake/application.rb | 10 ++-------- test/test_rake_application.rb | 22 +++++++++++----------- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/History.rdoc b/History.rdoc index fadb17a0d..c0a8be05c 100644 --- a/History.rdoc +++ b/History.rdoc @@ -1,3 +1,10 @@ +=== 10.4.1 + +Bug fixes: + +* Reverted fix for #277 as it caused numerous issues for rake users. + rails/spring issue #366 by Gustavo Dutra. + === 10.4.0 / 2014-11-22 Enhancements: @@ -10,6 +17,8 @@ Enhancements: * Rake no longer edits ARGV. This allows you to re-exec rake from a rake task. Issue #277 by Matt Palmer. * Etc.nprocessors is used for counting the number of CPUs. +* Rake no longer edits ARGV. This allows you to re-exec rake from a rake + task. Issue #277 by Matt Palmer. Bug fixes: diff --git a/lib/rake/application.rb b/lib/rake/application.rb index 96f907b07..795b4685d 100644 --- a/lib/rake/application.rb +++ b/lib/rake/application.rb @@ -20,9 +20,6 @@ class Application include TaskManager include TraceOutput - # The command-line arguments rake is using (defaults to ARGV) - attr_reader :argv # :nodoc: - # The name of the application (typically 'rake') attr_reader :name @@ -48,7 +45,6 @@ class Application # Initialize a Rake::Application object. def initialize super - @argv = ARGV.dup @name = 'rake' @rakefiles = DEFAULT_RAKEFILES.dup @rakefile = nil @@ -77,8 +73,6 @@ def initialize # call +top_level+ to run your top level tasks. def run standard_exception_handling do - @argv = argv - init load_rakefile top_level @@ -639,7 +633,7 @@ def handle_options # :nodoc: standard_rake_options.each { |args| opts.on(*args) } opts.environment('RAKEOPT') - end.parse! @argv + end.parse! end # Similar to the regular Ruby +require+ command, but will check @@ -735,7 +729,7 @@ def standard_system_dir #:nodoc: # Environmental assignments are processed at this time as well. def collect_command_line_tasks # :nodoc: @top_level_tasks = [] - @argv.each do |arg| + ARGV.each do |arg| if arg =~ /^(\w+)=(.*)$/m ENV[$1] = $2 else diff --git a/test/test_rake_application.rb b/test/test_rake_application.rb index 19e500598..f52040471 100644 --- a/test/test_rake_application.rb +++ b/test/test_rake_application.rb @@ -10,9 +10,9 @@ def setup end def setup_command_line(*options) - @app.argv.clear + ARGV.clear options.each do |option| - @app.argv << option + ARGV << option end end @@ -268,7 +268,7 @@ def test_load_rakefile_doesnt_print_rakefile_directory_from_subdir_if_silent end def test_load_rakefile_not_found - @app.argv.clear + ARGV.clear Dir.chdir @tempdir ENV['RAKE_SYSTEM'] = 'not_exist' @@ -378,7 +378,7 @@ def test_handle_options_should_strip_options_from_argv @app.handle_options - assert !@app.argv.include?(valid_option) + assert !ARGV.include?(valid_option) assert @app.options.trace end @@ -406,14 +406,14 @@ def test_handle_options_trace_does_not_eat_following_task_names setup_command_line("--trace", "sometask") @app.handle_options - assert @app.argv.include?("sometask") + assert ARGV.include?("sometask") assert @app.options.trace end def test_good_run ran = false - @app.argv << '--rakelib=""' + ARGV << '--rakelib=""' @app.options.silent = true @@ -468,7 +468,7 @@ def test_bad_run } assert_match(/see full trace/i, err) ensure - @app.argv.clear + ARGV.clear end def test_bad_run_with_trace @@ -479,7 +479,7 @@ def test_bad_run_with_trace } refute_match(/see full trace/i, err) ensure - @app.argv.clear + ARGV.clear end def test_bad_run_with_backtrace @@ -492,7 +492,7 @@ def test_bad_run_with_backtrace } refute_match(/see full trace/, err) ensure - @app.argv.clear + ARGV.clear end CustomError = Class.new(RuntimeError) @@ -549,7 +549,7 @@ def test_printing_original_exception_cause end assert_match(/Secondary Error/, err) ensure - @app.argv.clear + ARGV.clear end def test_run_with_bad_options @@ -559,7 +559,7 @@ def test_run_with_bad_options capture_io { @app.run } } ensure - @app.argv.clear + ARGV.clear end def test_standard_exception_handling_invalid_option