Skip to content

test(cli): cherry-pick #1101 to verify ci:windows label CI#1102

Closed
muddlebee wants to merge 1 commit intoTracer-Cloud:mainfrom
muddlebee:test/cherry-pick-1101-windows-ci-label
Closed

test(cli): cherry-pick #1101 to verify ci:windows label CI#1102
muddlebee wants to merge 1 commit intoTracer-Cloud:mainfrom
muddlebee:test/cherry-pick-1101-windows-ci-label

Conversation

@muddlebee
Copy link
Copy Markdown
Collaborator

Purpose

Smoke-test the merged CI Labels workflow (ci:windows) on a branch based on latest main.

This is a cherry-pick of #1101 (11ca577) onto current main so the PR head branch includes .github/workflows/ci-labels.yml from upstream.

How to verify

  1. Wait for default CI to complete.
  2. Add label ci:windows on this PR.
  3. Confirm CI Labels run shows Windows quality / typecheck / test jobs.

Note

Contributor fork PRs do not inherit new workflow files until the branch syncs with main; this duplicates the logical change here for validation only. Close/replace once #1101 is updated from main if redundant.

…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-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 30, 2026

Greptile Summary

This PR cherry-picks Windows CI compatibility fixes for two install.sh test modules: a module-level pytestmark skip is added to both files so all tests are skipped on win32, and a _RUNNING_AS_ROOT helper replaces a bare os.geteuid() == 0 decorator expression in test_install_sh_resolution.py to avoid an AttributeError at import time on Windows (where os.geteuid does not exist). Both changes are correct and well-commented.

Confidence Score: 5/5

Safe to merge — targeted, well-reasoned Windows CI compatibility fixes with no logic changes to existing tests.

Both changes are minimal and correct: the pytestmark module-level skip properly gates POSIX-only tests on Windows, and the _RUNNING_AS_ROOT guard correctly prevents an AttributeError from os.geteuid() on import. No existing test logic is altered. No P0 or P1 findings.

No files require special attention.

Important Files Changed

Filename Overview
tests/cli/test_install_sh_path.py Added module-level pytestmark to skip all tests on win32, plus the required import sys and import pytest; no logic changes to existing tests.
tests/cli/test_install_sh_resolution.py Added module-level pytestmark skip for Windows and introduced _RUNNING_AS_ROOT guard to prevent AttributeError from os.geteuid() on Windows at decorator-application time.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[pytest collects module] --> B{sys.platform == win32?}
    B -- Yes --> C[pytestmark: skip all tests in module]
    B -- No --> D[Module-level code executes normally]

    D --> E[test_install_sh_path.py tests]
    D --> F[test_install_sh_resolution.py tests]

    E --> G[bash subprocess runs install.sh functions]

    F --> H["_RUNNING_AS_ROOT = hasattr(os, geteuid) and os.geteuid() == 0"]
    H --> I{_RUNNING_AS_ROOT?}
    I -- Yes --> J[skipif: skip sudo test]
    I -- No --> K[run test_uses_sudo_for_non_writable_system_path_dir]
    F --> L[run other resolution tests normally]
Loading

Reviews (1): Last reviewed commit: "test(cli): skip install.sh tests on Wind..." | Re-trigger Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants