diff --git a/History.rdoc b/History.rdoc index 6be889a38..17aaea8a2 100644 --- a/History.rdoc +++ b/History.rdoc @@ -1,3 +1,10 @@ +=== 10.3.2 + +Bug fixes: + +* Rake no longer infinitely loops when showing exception causes that refer to + each other. Bug #272 by Chris Bandy. + === 10.3.1 / 2014-04-17 Bug fixes: diff --git a/lib/rake/application.rb b/lib/rake/application.rb index e819f3ad9..795b4685d 100644 --- a/lib/rake/application.rb +++ b/lib/rake/application.rb @@ -202,6 +202,10 @@ def display_error_message(ex) # :nodoc: end def display_exception_details(ex) # :nodoc: + seen = Thread.current[:rake_display_exception_details_seen] ||= [] + return if seen.include? ex + seen << ex + display_exception_message_details(ex) display_exception_backtrace(ex) display_exception_details(ex.cause) if has_cause?(ex) diff --git a/test/test_rake_application.rb b/test/test_rake_application.rb index e4397d0e4..1532be1c9 100644 --- a/test/test_rake_application.rb +++ b/test/test_rake_application.rb @@ -55,6 +55,33 @@ def test_display_exception_details_cause assert_match 'cause b', err end + def test_display_exception_details_cause_loop + skip 'Exception#cause not implemented' unless + Exception.method_defined? :cause + + begin + begin + raise 'cause a' + rescue => a + begin + raise 'cause b' + rescue + raise a + end + end + rescue => ex + end + + out, err = capture_io do + @app.display_error_message ex + end + + assert_empty out + + assert_match 'cause a', err + assert_match 'cause b', err + end + def test_display_tasks @app.options.show_tasks = :tasks @app.options.show_task_pattern = //