File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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+ )
Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ elif [ "$PLATFORM" == "cu121" ]; then
3030 PYG_URL=" https://data.pyg.org/whl/torch-${TORCH_VER} +cu121.html"
3131else
3232 echo " ❌ Error: Invalid platform '$PLATFORM '. Use: cpu, cu118, or cu121."
33- exit 1
33+ return 1 2> /dev/null || exit 1
3434fi
3535
3636echo " ⚙️ Updating pyproject.toml..."
You can’t perform that action at this time.
0 commit comments