Skip to content

Commit

Permalink
Revert "Stop editing ARGV"
Browse files Browse the repository at this point in the history
This reverts commit a36505d.

This caused issues with tools that used rake across fork boundaries.

Fixes rails/spring#366

Possibly also #4
  • Loading branch information
drbrain committed Dec 2, 2014
1 parent 3a18e55 commit 86af0ef
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 19 deletions.
9 changes: 9 additions & 0 deletions History.rdoc
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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:

Expand Down
10 changes: 2 additions & 8 deletions lib/rake/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
22 changes: 11 additions & 11 deletions test/test_rake_application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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'

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 86af0ef

Please sign in to comment.