From f6b1680052a4b721c1b64553e6063bbfe22882a9 Mon Sep 17 00:00:00 2001 From: "Mark D. Blackwell" Date: Thu, 21 Jul 2016 17:54:56 -0400 Subject: [PATCH 1/2] Add test for sh full command echo on error exit --- test/test_rake_file_utils.rb | 43 ++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/test/test_rake_file_utils.rb b/test/test_rake_file_utils.rb index 1b43a49d1..14430a3cd 100644 --- a/test/test_rake_file_utils.rb +++ b/test/test_rake_file_utils.rb @@ -287,6 +287,49 @@ def test_sh_show_command assert_equal expected_cmd, show_cmd end + def test_sh_if_a_command_exits_with_error_status_its_full_output_is_printed + verbose false do + standard_output = 'Some output' + standard_error = 'Some error' + shell_command = "ruby -e\"puts '#{standard_output}';STDERR.puts '#{standard_error}';exit false\"" + actual_both = capture_subprocess_io do + begin + sh shell_command + rescue + else + flunk + end + end + actual = actual_both.join + assert_match standard_output, actual + assert_match standard_error, actual + end + end + + def test_sh_if_a_command_exits_with_error_status_sh_echoes_it_fully + verbose true do + assert_echoes_fully + end + verbose false do + assert_echoes_fully + end + end + + def assert_echoes_fully + long_string = '1234567890' * 10 + shell_command = "ruby -e\"'#{long_string}';exit false\"" + capture_subprocess_io do + begin + sh shell_command + rescue => ex + assert_match 'Command failed with status', ex.message + assert_match shell_command, ex.message + else + flunk + end + end + end + def test_ruby_with_multiple_arguments skip if jruby9? # https://github.com/jruby/jruby/issues/3653 From 64eaba2c83dae029c06471a1b9e2844383f98543 Mon Sep 17 00:00:00 2001 From: "Mark D. Blackwell" Date: Sun, 24 Jul 2016 09:22:21 -0400 Subject: [PATCH 2/2] Sh full command echo on error exit --- lib/rake/file_utils.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/rake/file_utils.rb b/lib/rake/file_utils.rb index 14cb092fc..8fd7067ec 100644 --- a/lib/rake/file_utils.rb +++ b/lib/rake/file_utils.rb @@ -62,8 +62,6 @@ def sh(*cmd, &block) def create_shell_runner(cmd) # :nodoc: show_command = sh_show_command cmd - show_command = show_command[0, 42] + "..." unless $trace - lambda do |ok, status| ok or fail "Command failed with status (#{status.exitstatus}): " +