Repository navigation
fix(install): return failure exit codes - #7123
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the Windows installer script (install.ps1) to throw an error message on failure when not in Tauri mode, and adds a regression test to verify that invalid package names cause the installer to fail. The review feedback suggests improving the test's robustness on Windows systems by falling back to powershell if pwsh is unavailable, and resolving the executable path to an absolute path to prevent potential path resolution issues.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| @pytest.mark.skipif(shutil.which("pwsh") is None, reason = "PowerShell is unavailable") | ||
| def test_windows_installer_invalid_package_fails(): | ||
| result = subprocess.run( | ||
| [ | ||
| "pwsh", | ||
| "-NoProfile", | ||
| "-NonInteractive", | ||
| "-File", | ||
| str(INSTALL_PS1), | ||
| "--package", | ||
| "bad!", | ||
| ], | ||
| capture_output = True, | ||
| text = True, | ||
| timeout = 30, | ||
| ) | ||
|
|
||
| assert result.returncode != 0 | ||
| assert "package name contains invalid characters" in result.stdout + result.stderr |
There was a problem hiding this comment.
On Windows systems, PowerShell Core (pwsh) may not be installed by default, whereas Windows PowerShell (powershell) is always available. To ensure this regression test runs and provides coverage on standard Windows environments, we can dynamically fall back to powershell if pwsh is not found on the system PATH. Additionally, when resolving executable paths to be passed to subprocesses, we should always return an absolute path (e.g., using Path.resolve()) to prevent relative paths without directory separators from being incorrectly resolved via the system PATH.
@pytest.mark.skipif(
shutil.which("pwsh") is None and shutil.which("powershell") is None,
reason="PowerShell is unavailable",
)
def test_windows_installer_invalid_package_fails():
resolved_shell = shutil.which("pwsh") or shutil.which("powershell")
ps_cmd = str(pathlib.Path(resolved_shell).resolve())
result = subprocess.run(
[
ps_cmd,
"-NoProfile",
"-NonInteractive",
"-File",
str(INSTALL_PS1.resolve()),
"--package",
"bad!",
],
capture_output=True,
text=True,
timeout=30,
)
assert result.returncode != 0
assert "package name contains invalid characters" in result.stdout + result.stderrReferences
- Skip tests that invoke platform-specific shells (like 'sh' or 'pwsh') via subprocesses when those shells are unavailable on the host system (e.g., using pytest.mark.skipif), or structure the test suite to run the native shell of each platform.
- When resolving executable paths to be passed to subprocesses, always return an absolute path (e.g., using
Path.resolve()). This prevents relative paths without directory separators from being incorrectly resolved via the system PATH, which can lead to FileNotFoundError.
There was a problem hiding this comment.
Leaving as-is. INSTALL_PS1 is already absolute (REPO_ROOT uses Path(file).resolve()) and shutil.which() already returns an absolute path, so the extra .resolve() calls are no-ops here. windows-latest ships pwsh preinstalled, so this test runs (not skips) in CI, and skipif only skips on a host without pwsh rather than failing. The invalid-package path returns exit code 1 identically under Windows PowerShell 5.1 and 7, so a powershell fallback would not add coverage.
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. 👍 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Summary
--packageinputVerification
install.ps1under Windows PowerShell 5.1--packagereturns exit code 1 in standard and Tauri modespython -m py_compile tests/test_installer_skip_autostart.py