Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/changelog/2717.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix bad return code from activate.sh if hashing is disabled - by :user:'fenkes-ibm'.
2 changes: 1 addition & 1 deletion src/virtualenv/activation/bash/activate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,4 @@ pydoc () {
# The hash command must be called to get it to forget past
# commands. Without forgetting past commands the $PATH changes
# we made may not be respected
hash -r 2>/dev/null
hash -r 2>/dev/null || true
1 change: 1 addition & 0 deletions tests/unit/activation/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def __call__(self, monkeypatch, tmp_path):
process = Popen(invoke, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=env)
raw_, _ = process.communicate()
raw = raw_.decode()
assert process.returncode == 0, raw
except subprocess.CalledProcessError as exception:
output = exception.output + exception.stderr
assert not exception.returncode, output # noqa: PT017
Expand Down
8 changes: 7 additions & 1 deletion tests/unit/activation/test_bash.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@


@pytest.mark.skipif(IS_WIN, reason="Github Actions ships with WSL bash")
def test_bash(raise_on_non_source_class, activation_tester):
@pytest.mark.parametrize("hashing_enabled", [True, False])
def test_bash(raise_on_non_source_class, hashing_enabled, activation_tester):
class Bash(raise_on_non_source_class):
def __init__(self, session) -> None:
super().__init__(
Expand All @@ -18,6 +19,11 @@ def __init__(self, session) -> None:
"sh",
"You must source this script: $ source ",
)
self.deactivate += " || exit 1"
self._invoke_script.append("-h" if hashing_enabled else "+h")

def activate_call(self, script):
return super().activate_call(script) + " || exit 1"

def print_prompt(self):
return self.print_os_env_var("PS1")
Expand Down