Skip to content

Commit

Permalink
Set pipefail option in subprocesses
Browse files Browse the repository at this point in the history
  • Loading branch information
Evan Thomas committed Oct 5, 2017
1 parent e96c8a0 commit 3aad469
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions app/util/process_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ def Popen_with_delayed_expansion(cmd, *args, **kwargs):
else:
cmd_with_deplayed_expansion.extend(cmd)
cmd = cmd_with_deplayed_expansion
else:
if os.path.exists('/bin/bash'):
kwargs.setdefault('executable', '/bin/bash')
if kwargs.get('shell') is True:
cmd = 'set -o pipefail; ' + cmd
return subprocess.Popen(cmd, *args, **kwargs)


Expand Down
4 changes: 3 additions & 1 deletion test/unit/util/test_process_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ def test_Popen_with_deplayed_expansion(self, input_cmd, os_name, expected_final_
Popen_with_delayed_expansion(input_cmd)

# Assert
mock_subprocess_popen.assert_called_once_with(expected_final_cmd)
self.assertEqual(len(mock_subprocess_popen.call_args_list), 1)
(cmd,), _ = mock_subprocess_popen.call_args
self.assertEqual(cmd, expected_final_cmd)

@genty_dataset(
windows=genty_args(
Expand Down

0 comments on commit 3aad469

Please sign in to comment.