Skip to content

Commit 02bcc2c

Browse files
committed
test: regression test for #305
Verify that `source uv_env_setup.sh INVALID` does not kill the user's shell (uses return instead of exit).
1 parent 193bac1 commit 02bcc2c

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

test/test_uv_env_setup.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
"""Tests for uv_env_setup.sh error handling."""
2+
3+
import subprocess
4+
from pathlib import Path
5+
6+
7+
def test_source_invalid_platform_does_not_kill_shell():
8+
"""Verify sourcing with invalid platform does not kill the shell.
9+
10+
If the script uses bare `exit 1`, sourcing it kills the shell
11+
(subshell exits). If it uses `return 1`, the subshell survives
12+
and the sentinel `STILL_ALIVE` is printed.
13+
"""
14+
script = Path(__file__).parents[1] / "uv_env_setup.sh"
15+
result = subprocess.run(
16+
[
17+
"bash",
18+
"-c",
19+
f"source {script} INVALID 2>/dev/null; echo STILL_ALIVE",
20+
],
21+
capture_output=True,
22+
text=True,
23+
)
24+
assert "STILL_ALIVE" in result.stdout, (
25+
"Shell was killed by `exit 1` instead of `return 1`"
26+
)

0 commit comments

Comments
 (0)