|
|
|
@ -1,13 +1,12 @@ |
|
|
|
|
"""Test enter""" |
|
|
|
|
|
|
|
|
|
import os |
|
|
|
|
import warnings |
|
|
|
|
import pytest |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize( |
|
|
|
|
'shell, success', [ |
|
|
|
|
('delete', True), |
|
|
|
|
('delete', True), # if there is no shell variable, bash creates it |
|
|
|
|
('', False), |
|
|
|
|
('/usr/bin/env', True), |
|
|
|
|
('noexec', False), |
|
|
|
@ -33,6 +32,7 @@ def test_enter(runner, yadm_y, paths, shell, success): |
|
|
|
|
env['SHELL'] = str(noexec) |
|
|
|
|
else: |
|
|
|
|
env['SHELL'] = shell |
|
|
|
|
|
|
|
|
|
run = runner(command=yadm_y('enter'), env=env) |
|
|
|
|
assert run.success == success |
|
|
|
|
assert run.err == '' |
|
|
|
@ -40,20 +40,12 @@ def test_enter(runner, yadm_y, paths, shell, success): |
|
|
|
|
if success: |
|
|
|
|
assert run.out.startswith('Entering yadm repo') |
|
|
|
|
assert run.out.rstrip().endswith('Leaving yadm repo') |
|
|
|
|
if shell == 'delete': |
|
|
|
|
# When SHELL is empty (unlikely), it is attempted to be run anyway. |
|
|
|
|
# This is a but which must be fixed. |
|
|
|
|
warnings.warn('Unhandled bug: SHELL executed when empty', Warning) |
|
|
|
|
else: |
|
|
|
|
assert f'PROMPT={prompt}' in run.out |
|
|
|
|
assert f'PS1={prompt}' in run.out |
|
|
|
|
assert f'GIT_DIR={paths.repo}' in run.out |
|
|
|
|
if not success: |
|
|
|
|
assert 'does not refer to an executable' in run.out |
|
|
|
|
if 'env' in shell: |
|
|
|
|
assert f'GIT_DIR={paths.repo}' in run.out |
|
|
|
|
assert 'PROMPT=yadm shell' in run.out |
|
|
|
|
assert 'PS1=yadm shell' in run.out |
|
|
|
|
assert f'PROMPT={prompt}' in run.out |
|
|
|
|
assert f'PS1={prompt}' in run.out |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize( |
|
|
|
|