From 10f2d6bdfd7a2999ed6f155802885f5a248b567b Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Sun, 11 Jan 2026 10:00:08 -0800 Subject: [PATCH] Revert "Fix for stderr warnings from ssh dirtying Borg JSON output and breaking "check" (#485)." This reverts commit 7987a5ff1fcc51469ca65c963a6b1209f5236058. --- borgmatic/execute.py | 2 +- tests/unit/test_execute.py | 35 ++++++----------------------------- 2 files changed, 7 insertions(+), 30 deletions(-) diff --git a/borgmatic/execute.py b/borgmatic/execute.py index f533ed43..ea3ea467 100644 --- a/borgmatic/execute.py +++ b/borgmatic/execute.py @@ -471,7 +471,7 @@ def execute_command_and_capture_output( command, stdin=input_file, stdout=subprocess.PIPE, - stderr=subprocess.PIPE if capture_stderr else None, + stderr=subprocess.PIPE, shell=shell, env=environment, cwd=working_directory, diff --git a/tests/unit/test_execute.py b/tests/unit/test_execute.py index 94e89960..f0115894 100644 --- a/tests/unit/test_execute.py +++ b/tests/unit/test_execute.py @@ -497,7 +497,7 @@ def test_execute_command_and_capture_output_returns_stdout(): full_command, stdin=None, stdout=subprocess.PIPE, - stderr=None, + stderr=subprocess.PIPE, shell=False, env=None, cwd=None, @@ -534,29 +534,6 @@ def test_execute_command_and_capture_output_with_capture_stderr_returns_stderr() assert output_lines == ('out',) -def test_execute_command_and_capture_output_without_capture_stderr_omits_stderr(): - full_command = ['foo', 'bar'] - process = flexmock() - flexmock(module.subprocess).should_receive('Popen').with_args( - full_command, - stdin=None, - stdout=subprocess.PIPE, - stderr=None, - shell=False, - env=None, - cwd=None, - close_fds=False, - ).and_return(process).once() - flexmock(module.borgmatic.logger).should_receive('Log_prefix').and_return(flexmock()) - flexmock(module).should_receive('log_outputs').and_yield('out') - - output_lines = tuple( - module.execute_command_and_capture_output(full_command, capture_stderr=False) - ) - - assert output_lines == ('out',) - - def test_execute_command_and_capture_output_returns_output_when_process_error_is_not_considered_an_error(): full_command = ['foo', 'bar'] err_output = b'[]' @@ -565,7 +542,7 @@ def test_execute_command_and_capture_output_returns_output_when_process_error_is full_command, stdin=None, stdout=subprocess.PIPE, - stderr=None, + stderr=subprocess.PIPE, shell=False, env=None, cwd=None, @@ -587,7 +564,7 @@ def test_execute_command_and_capture_output_raises_when_command_errors(): full_command, stdin=None, stdout=subprocess.PIPE, - stderr=None, + stderr=subprocess.PIPE, shell=False, env=None, cwd=None, @@ -609,7 +586,7 @@ def test_execute_command_and_capture_output_with_shell_returns_output(): 'foo bar', stdin=None, stdout=subprocess.PIPE, - stderr=None, + stderr=subprocess.PIPE, shell=True, env=None, cwd=None, @@ -631,7 +608,7 @@ def test_execute_command_and_capture_output_with_enviroment_returns_output(): full_command, stdin=None, stdout=subprocess.PIPE, - stderr=None, + stderr=subprocess.PIPE, shell=False, env={'a': 'b'}, cwd=None, @@ -659,7 +636,7 @@ def test_execute_command_and_capture_output_returns_output_with_working_director full_command, stdin=None, stdout=subprocess.PIPE, - stderr=None, + stderr=subprocess.PIPE, shell=False, env=None, cwd='/working',