From a6223b3939f0ef91c928f94502c806a68a011e74 Mon Sep 17 00:00:00 2001 From: Jeff Forcier Date: Sun, 15 Jun 2008 00:52:57 -0400 Subject: [PATCH] Update capture() to warn about stderr instead of raising CaptureError. --- CHANGELOG | 5 +++++ lib/capistrano/configuration/actions/inspect.rb | 2 +- test/configuration/actions/inspect_test.rb | 11 +++++++---- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index e5ebfff5..38fede4b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,8 @@ +*unreleased* + +* Changed capture() helper to not raise an exception on error, but to warn instead [Jeff Forcier] + + *2.4.0* June 13, 2008 * Added :normalize_asset_timestamps option to deployment, defaulting to true, which allows asset timestamping to be disabled [John Trupiano] diff --git a/lib/capistrano/configuration/actions/inspect.rb b/lib/capistrano/configuration/actions/inspect.rb index c319e546..c2ea8c77 100644 --- a/lib/capistrano/configuration/actions/inspect.rb +++ b/lib/capistrano/configuration/actions/inspect.rb @@ -34,7 +34,7 @@ module Capistrano invoke_command(command, options.merge(:once => true)) do |ch, stream, data| case stream when :out then output << data - when :err then raise CaptureError, "error processing #{command.inspect}: #{data.inspect}" + when :err then warn "[err :: #{ch[:server]}] #{data}" end end output diff --git a/test/configuration/actions/inspect_test.rb b/test/configuration/actions/inspect_test.rb index c5928d5d..5538ce04 100644 --- a/test/configuration/actions/inspect_test.rb +++ b/test/configuration/actions/inspect_test.rb @@ -37,9 +37,12 @@ class ConfigurationActionsInspectTest < Test::Unit::TestCase @config.capture("hostname", :foo => "bar") end - def test_capture_with_stderr_result_should_raise_capture_error - @config.expects(:invoke_command).yields(mock("channel"), :err, "boom") - assert_raises(Capistrano::CaptureError) { @config.capture("hostname") } + def test_capture_with_stderr_should_emit_stderr_via_warn + ch = mock("channel") + ch.expects(:[]).with(:server).returns(server("capistrano")) + @config.expects(:invoke_command).yields(ch, :err, "boom") + @config.expects(:warn).with("[err :: capistrano] boom") + @config.capture("hostname") end def test_capture_with_stdout_should_aggregate_and_return_stdout @@ -59,4 +62,4 @@ class ConfigurationActionsInspectTest < Test::Unit::TestCase @config.channel = channel @config.script = output end -end \ No newline at end of file +end