File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -287,6 +287,49 @@ def test_sh_show_command
287287 assert_equal expected_cmd , show_cmd
288288 end
289289
290+ def test_sh_if_a_command_exits_with_error_status_its_full_output_is_printed
291+ verbose false do
292+ standard_output = 'Some output'
293+ standard_error = 'Some error'
294+ shell_command = "ruby -e\" puts '#{ standard_output } ';STDERR.puts '#{ standard_error } ';exit false\" "
295+ actual_both = capture_subprocess_io do
296+ begin
297+ sh shell_command
298+ rescue
299+ else
300+ flunk
301+ end
302+ end
303+ actual = actual_both . join
304+ assert_match standard_output , actual
305+ assert_match standard_error , actual
306+ end
307+ end
308+
309+ def test_sh_if_a_command_exits_with_error_status_sh_echoes_it_fully
310+ verbose true do
311+ assert_echoes_fully
312+ end
313+ verbose false do
314+ assert_echoes_fully
315+ end
316+ end
317+
318+ def assert_echoes_fully
319+ long_string = '1234567890' * 10
320+ shell_command = "ruby -e\" '#{ long_string } ';exit false\" "
321+ capture_subprocess_io do
322+ begin
323+ sh shell_command
324+ rescue => ex
325+ assert_match 'Command failed with status' , ex . message
326+ assert_match shell_command , ex . message
327+ else
328+ flunk
329+ end
330+ end
331+ end
332+
290333 def test_ruby_with_multiple_arguments
291334 skip if jruby9? # https://github.com/jruby/jruby/issues/3653
292335
You can’t perform that action at this time.
0 commit comments