mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
Merge pull request #7164 from dlanderson/fix_issue_7154
Fix #7154 - cmd.* should fail when cwd does not exist
This commit is contained in:
commit
e644de7e76
@ -215,6 +215,11 @@ def _run(cmd,
|
||||
# munge the cmd and cwd through the template
|
||||
(cmd, cwd) = _render_cmd(cmd, cwd, template)
|
||||
|
||||
if not os.path.isdir(cwd):
|
||||
# cwd is not a directory - fatal error
|
||||
msg = 'Working directory {0!r} does not exist'
|
||||
raise CommandExecutionError(msg.format(cwd))
|
||||
|
||||
ret = {}
|
||||
|
||||
if not env:
|
||||
|
@ -200,6 +200,22 @@ sys.stdout.write('cheese')
|
||||
'hello' == self.run_function(
|
||||
'cmd.run', ['sleep 1 && echo hello', 'timeout=2']))
|
||||
|
||||
def test_run_cwd_doesnt_exist_issue_7154(self):
|
||||
'''
|
||||
cmd.run should fail and raise
|
||||
salt.exceptions.CommandExecutionError if the cwd dir does not
|
||||
exist
|
||||
'''
|
||||
from salt.exceptions import CommandExecutionError
|
||||
import salt.modules.cmdmod as cmdmod
|
||||
cmd = 'echo OHAI'
|
||||
cwd = '/path/to/nowhere'
|
||||
try:
|
||||
cmdmod.run_all(cmd, cwd=cwd)
|
||||
except CommandExecutionError:
|
||||
pass
|
||||
else:
|
||||
raise RuntimeError
|
||||
|
||||
if __name__ == '__main__':
|
||||
from integration import run_tests
|
||||
|
Loading…
Reference in New Issue
Block a user