test(cli): skip install.sh tests on Windows runner (#1099)#1101
Conversation
…racer-Cloud#1099) The post-merge ``test (windows-latest)`` job on commit 67dc64d (PR Tracer-Cloud#1090 landing) is failing with two distinct symptoms in the install.sh test suites added by PR Tracer-Cloud#1064: 1. ``tests/cli/test_install_sh_path.py`` — 12 tests fail because the subprocess call ``subprocess.run(["bash", "-c", script])`` resolves ``bash`` to ``wsl.exe`` on the GitHub Actions ``windows-latest`` runner, and that runner has no installed WSL distribution. Every ``_run`` call exits 1 with a literal "Windows Subsystem for Linux has no installed distributions" message, so none of the asserted rc files (``.zshrc``/``.bashrc``/``config.fish``) ever get written. 2. ``tests/cli/test_install_sh_resolution.py`` — module fails to import on Windows: the existing ``@pytest.mark.skipif(os.geteuid() == 0, reason=...)`` decorator evaluates ``os.geteuid()`` at decorator-application time, but ``os.geteuid`` does not exist on Windows. ``AttributeError`` fires *before* pytest can read any markers, blocking collection of every test in the module. Both files exclusively test ``install.sh``, which is a POSIX shell script (zsh/bash/fish RC files) with no Windows analogue, so the correct fix for the Windows runner is to skip them. Changes: - ``test_install_sh_path.py``: module-level ``pytestmark = pytest.mark.skipif(sys.platform == "win32", ...)`` with a comment that names the failure mode. - ``test_install_sh_resolution.py``: same module-level skipif, *and* defensively replace ``os.geteuid() == 0`` with ``_RUNNING_AS_ROOT = hasattr(os, "geteuid") and os.geteuid() == 0`` evaluated once at module load. ``hasattr`` short-circuits the ``and`` on Windows so ``os.geteuid()`` is never called there — the module imports cleanly even before pytest reads ``pytestmark``. No source-checkout behaviour change: skipif is a no-op on macOS/Linux, and the existing root-only test still skips correctly on those platforms (verified by running ``pytest tests/cli/test_install_sh_path.py tests/cli/test_install_sh_resolution.py`` locally — 15 / 15 pass). Full unit suite: 4164 pass / 2 skipped / 1 xfailed. Closes Tracer-Cloud#1099.
Greptile SummaryAdds module-level Confidence Score: 5/5Safe to merge — minimal, targeted fix with no production code changes and no Unix-side test regressions. Both changes are correct: No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[pytest collects module] --> B{sys.platform == win32?}
B -- Yes --> C[pytestmark: skip all tests\nin module with reason text]
B -- No --> D[Evaluate _RUNNING_AS_ROOT\nhasattr guard]
D --> E{os.geteuid == 0?}
E -- Yes --> F[skip test_uses_sudo_for_non_writable_system_path_dir]
E -- No --> G[Run all tests via\nsubprocess bash -c]
G --> H[Assert rc-file writes\nand return codes]
Reviews (2): Last reviewed commit: "test(cli): skip install.sh tests on Wind..." | Re-trigger Greptile |
|
@mayankbharati-ops I hope only these two were the affected regions? |
|
@mayankbharati-ops I just added a custom workflow check(already in main), after your PR. so maintainers can trigger window CI checks during PR only.. have triggered it here, pls see if any more windows issues.. looks like it passed #1102 |
|
🛸 Aliens watching our repo just upgraded @mayankbharati-ops's threat level to: do not engage — too competent. 👽 👋 Join us on Discord - OpenSRE : hang out, contribute, or hunt for features and issues. Everyone's welcome. |
|
@mayankbharati-ops thanks for the quick fix. window checks green at #1102 |
|
@muddlebee yes — those two were the only affected modules. I just re-audited the test tree to be sure, and PR #1102's now-green Windows checks corroborate it: Audit results across
So the surface area for Windows-specific test failures was exactly those two files. The "windows test SUCCESS" on #1102 is the empirical confirmation. Re: the pre-merge Windows trigger — that's a nice addition. With it, this whole regression class would have been caught at PR-review time on #1064 (where these tests landed) instead of post-merge. Glad it's in. Thanks for the quick merge! |
|
@mayankbharati-ops in case you are interested how we added the new ci windows workflows |
…racer-Cloud#1099) (Tracer-Cloud#1101) The post-merge ``test (windows-latest)`` job on commit 67dc64d (PR Tracer-Cloud#1090 landing) is failing with two distinct symptoms in the install.sh test suites added by PR Tracer-Cloud#1064: 1. ``tests/cli/test_install_sh_path.py`` — 12 tests fail because the subprocess call ``subprocess.run(["bash", "-c", script])`` resolves ``bash`` to ``wsl.exe`` on the GitHub Actions ``windows-latest`` runner, and that runner has no installed WSL distribution. Every ``_run`` call exits 1 with a literal "Windows Subsystem for Linux has no installed distributions" message, so none of the asserted rc files (``.zshrc``/``.bashrc``/``config.fish``) ever get written. 2. ``tests/cli/test_install_sh_resolution.py`` — module fails to import on Windows: the existing ``@pytest.mark.skipif(os.geteuid() == 0, reason=...)`` decorator evaluates ``os.geteuid()`` at decorator-application time, but ``os.geteuid`` does not exist on Windows. ``AttributeError`` fires *before* pytest can read any markers, blocking collection of every test in the module. Both files exclusively test ``install.sh``, which is a POSIX shell script (zsh/bash/fish RC files) with no Windows analogue, so the correct fix for the Windows runner is to skip them. Changes: - ``test_install_sh_path.py``: module-level ``pytestmark = pytest.mark.skipif(sys.platform == "win32", ...)`` with a comment that names the failure mode. - ``test_install_sh_resolution.py``: same module-level skipif, *and* defensively replace ``os.geteuid() == 0`` with ``_RUNNING_AS_ROOT = hasattr(os, "geteuid") and os.geteuid() == 0`` evaluated once at module load. ``hasattr`` short-circuits the ``and`` on Windows so ``os.geteuid()`` is never called there — the module imports cleanly even before pytest reads ``pytestmark``. No source-checkout behaviour change: skipif is a no-op on macOS/Linux, and the existing root-only test still skips correctly on those platforms (verified by running ``pytest tests/cli/test_install_sh_path.py tests/cli/test_install_sh_resolution.py`` locally — 15 / 15 pass). Full unit suite: 4164 pass / 2 skipped / 1 xfailed. Closes Tracer-Cloud#1099.

Closes #1099.
Root cause
The post-merge
test (windows-latest)job on67dc64d1(the merge of #1090) is failing with two distinct symptoms in theinstall.shtest suite added by #1064:1.
tests/cli/test_install_sh_path.py— 12 failuresThe helper
_runcallssubprocess.run(["bash", "-c", script]). On the GitHub Actionswindows-latestrunner,bashresolves towsl.exe, and that runner has no installed WSL distribution. Every_runexits with code 1 and the literal message:So none of the asserted rc files (
.zshrc,.bashrc,config.fish) ever get written, and assertions likeassert zshrc.exists()andassert result.returncode == 0fail.2.
tests/cli/test_install_sh_resolution.py— module collection error@pytest.mark.skipif(os.geteuid() == 0, reason="sudo fallback is only meaningful for non-root users")os.geteuiddoes not exist on Windows. The decorator condition is evaluated at decorator-application time (i.e. module import), soAttributeError: module 'os' has no attribute 'geteuid'fires before pytest gets a chance to read any markers. The whole module fails to collect.Why skip rather than fix the test scaffolding
Both files exclusively test
install.sh, which is a POSIX shell script driving zsh/bash/fish rc-file behaviour. There's no Windows analogue (the project ships a separate Windows installer /pip installpath), so installing WSL or porting the test scaffolding to PowerShell would be busywork. Skipping the module on Windows matches what the codebase actually claims to support.Changes
test_install_sh_resolution.pygets the samepytestmark, plus a defensive replacement of the bareos.geteuid()access:Without that defensive guard the module still wouldn't import on Windows, even with
pytestmarkdefined — andpytestmarkonly kicks in once pytest has collected the module.Verification
ruff check/ruff format --checkScope
tests/cli/test_install_sh_path.pytests/cli/test_install_sh_resolution.py_RUNNING_AS_ROOTconstant; existing decorator references the new constant)No production code touched. No test logic changed for the platforms where these tests do run.
cc @muddlebee — this is the post-#1090 Windows CI fix. Both files were added by #1064 and have been failing on Windows since that landed; this PR makes the Windows runner green again without changing any Unix-side behaviour.