1
0
Fork 0
mirror of synced 2024-12-21 05:31:08 -05:00

Fix bug with shell defaults

This commit is contained in:
Anish Athalye 2017-06-27 21:20:37 -07:00
parent 0b01d56d81
commit f1e8297255
3 changed files with 48 additions and 6 deletions

View file

@ -22,15 +22,21 @@ class Shell(dotbot.Plugin):
with open(os.devnull, 'w') as devnull: with open(os.devnull, 'w') as devnull:
for item in data: for item in data:
stdin = stdout = stderr = devnull stdin = stdout = stderr = devnull
if defaults.get('stdin', False) == True:
stdin = None
if defaults.get('stdout', False) == True:
stdout = None
if defaults.get('stderr', False) == True:
stderr = None
if isinstance(item, dict): if isinstance(item, dict):
cmd = item['command'] cmd = item['command']
msg = item.get('description', None) msg = item.get('description', None)
if item.get('stdin', defaults.get('stdin', False)) is True: if 'stdin' in item:
stdin = None stdin = None if item['stdin'] == True else devnull
if item.get('stdout', defaults.get('stdout', False)) is True: if 'stdout' in item:
stdout = None stdout = None if item['stdout'] == True else devnull
if item.get('stderr', defaults.get('stderr', False)) is True: if 'stderr' in item:
stderr = None stderr = None if item['stderr'] == True else devnull
elif isinstance(item, list): elif isinstance(item, list):
cmd = item[0] cmd = item[0]
msg = item[1] if len(item) > 1 else None msg = item[1] if len(item) > 1 else None

View file

@ -0,0 +1,22 @@
test_description='shell command stdout works in compact form'
. '../test-lib.bash'
test_expect_success 'run' '
(run_dotbot | grep "^apple") <<EOF
- defaults:
shell:
stdout: true
- shell:
- echo apple
EOF
'
test_expect_success 'run 2' '
(run_dotbot | grep "^apple") <<EOF
- defaults:
shell:
stdout: true
- shell:
- [echo apple, "echoing message"]
EOF
'

View file

@ -0,0 +1,14 @@
test_description='shell command can override default'
. '../test-lib.bash'
test_expect_success 'run' '
(run_dotbot | (! grep "^apple")) <<EOF
- defaults:
shell:
stdout: true
- shell:
-
command: echo apple
stdout: false
EOF
'