diff --git a/tests/functional/plots.py b/tests/functional/plots.py index 131e4c35..297a6915 100644 --- a/tests/functional/plots.py +++ b/tests/functional/plots.py @@ -83,3 +83,17 @@ def without_confirmation(proc, TIMEOUT): def how_to_configure(proc, TIMEOUT): proc.sendline(u'fuck') assert proc.expect([TIMEOUT, u"alias isn't configured"]) + + +def status_success(proc, TIMEOUT): + proc.sendline(u'git commit --allow-empty -m "Test"') + + proc.sendline(u'fuck') + assert proc.expect([TIMEOUT, u'git commit --amend']) + + +def status_failure(proc, TIMEOUT): + proc.sendline(u'git commit -m "Test"') + + proc.sendline(u'fuck') + assert proc.expect([TIMEOUT, u'git reset HEAD~']) diff --git a/tests/functional/test_bash.py b/tests/functional/test_bash.py index dbb6fed2..9a25b8c3 100644 --- a/tests/functional/test_bash.py +++ b/tests/functional/test_bash.py @@ -1,7 +1,8 @@ import pytest from tests.functional.plots import with_confirmation, without_confirmation, \ refuse_with_confirmation, history_changed, history_not_changed, \ - select_command_with_arrows, how_to_configure + select_command_with_arrows, how_to_configure, status_success, \ + status_failure python_3 = (u'thefuck/python3-bash', @@ -66,3 +67,13 @@ def test_without_confirmation(proc, TIMEOUT): def test_how_to_configure_alias(proc, TIMEOUT): proc.sendline('unset -f fuck') how_to_configure(proc, TIMEOUT) + + +@pytest.mark.functional +def test_status_success(proc, TIMEOUT): + status_success(proc, TIMEOUT) + + +@pytest.mark.functional +def test_status_failure(proc, TIMEOUT): + status_failure(proc, TIMEOUT) diff --git a/tests/functional/test_fish.py b/tests/functional/test_fish.py index 657ebf19..3048e6e0 100644 --- a/tests/functional/test_fish.py +++ b/tests/functional/test_fish.py @@ -1,6 +1,7 @@ import pytest from tests.functional.plots import with_confirmation, without_confirmation, \ - refuse_with_confirmation, select_command_with_arrows + refuse_with_confirmation, select_command_with_arrows, status_success, \ + status_failure containers = (('thefuck/python3-fish', u'''FROM python:3 @@ -49,4 +50,14 @@ def test_refuse_with_confirmation(proc, TIMEOUT): def test_without_confirmation(proc, TIMEOUT): without_confirmation(proc, TIMEOUT) + +@pytest.mark.functional +def test_status_success(proc, TIMEOUT): + status_success(proc, TIMEOUT) + + +@pytest.mark.functional +def test_status_failure(proc, TIMEOUT): + status_failure(proc, TIMEOUT) + # TODO: ensure that history changes. diff --git a/tests/functional/test_tcsh.py b/tests/functional/test_tcsh.py index 12cabe30..80e40363 100644 --- a/tests/functional/test_tcsh.py +++ b/tests/functional/test_tcsh.py @@ -1,6 +1,7 @@ import pytest from tests.functional.plots import with_confirmation, without_confirmation, \ - refuse_with_confirmation, select_command_with_arrows + refuse_with_confirmation, select_command_with_arrows, status_success, \ + status_failure containers = (('thefuck/python3-tcsh', u'''FROM python:3 @@ -44,4 +45,14 @@ def test_refuse_with_confirmation(proc, TIMEOUT): def test_without_confirmation(proc, TIMEOUT): without_confirmation(proc, TIMEOUT) + +@pytest.mark.functional +def test_status_success(proc, TIMEOUT): + status_success(proc, TIMEOUT) + + +@pytest.mark.functional +def test_status_failure(proc, TIMEOUT): + status_failure(proc, TIMEOUT) + # TODO: ensure that history changes. diff --git a/tests/functional/test_zsh.py b/tests/functional/test_zsh.py index f8ea2af5..9dc861f2 100644 --- a/tests/functional/test_zsh.py +++ b/tests/functional/test_zsh.py @@ -1,7 +1,8 @@ import pytest from tests.functional.plots import with_confirmation, without_confirmation, \ refuse_with_confirmation, history_changed, history_not_changed, \ - select_command_with_arrows, how_to_configure + select_command_with_arrows, how_to_configure, status_success, \ + status_failure python_3 = ('thefuck/python3-zsh', @@ -73,3 +74,13 @@ def test_without_confirmation(proc, TIMEOUT): def test_how_to_configure_alias(proc, TIMEOUT): proc.sendline(u'unfunction fuck') how_to_configure(proc, TIMEOUT) + + +@pytest.mark.functional +def test_status_success(proc, TIMEOUT): + status_success(proc, TIMEOUT) + + +@pytest.mark.functional +def test_status_failure(proc, TIMEOUT): + status_failure(proc, TIMEOUT) diff --git a/thefuck/shells/tcsh.py b/thefuck/shells/tcsh.py index b9075f93..ec40e905 100644 --- a/thefuck/shells/tcsh.py +++ b/thefuck/shells/tcsh.py @@ -10,6 +10,7 @@ class Tcsh(Generic): def app_alias(self, alias_name): return ("alias {0} 'setenv TF_SHELL tcsh && setenv TF_ALIAS {0} && " + "setenv TF_STATUS=$status && " "set fucked_cmd=`history -h 2 | head -n 1` && " "eval `thefuck ${{fucked_cmd}}`'").format(alias_name) diff --git a/thefuck/shells/zsh.py b/thefuck/shells/zsh.py index e1fdf207..c094ab37 100644 --- a/thefuck/shells/zsh.py +++ b/thefuck/shells/zsh.py @@ -18,6 +18,7 @@ class Zsh(Generic): {name} () {{ TF_PYTHONIOENCODING=$PYTHONIOENCODING; export TF_SHELL=zsh; + export TF_STATUS=$?; export TF_ALIAS={name}; TF_SHELL_ALIASES=$(alias); export TF_SHELL_ALIASES;