Skip to content

bug(windows): unit tests rely on POSIX semantics and overlong temporary paths #1501

Description

@knqiufan

Describe the bug

Several unit tests for portable behavior fail on Windows because their fixtures or assertions depend on POSIX semantics or excessively long pytest temporary paths. These failures prevent a useful Windows unit-test baseline and can obscure genuine regressions.

The failures below are test portability defects. They should not be reported as evidence that Windows authorization, subprocess cleanup, or default host installation is broken.

Steps to reproduce

On Windows at master 80d618bd61432d1bb4eae85433fa22f2bbd50bce, with development dependencies installed, run these existing nodes through uv run pytest -q:

Test node Incorrect platform assumption
tests/builtin/artifacts/skill/test_package.py::test_directory_package_round_trips_exact_files_and_executable_mode The fixture uses platform-translating write_text(), but asserts archived LF bytes; it also expects POSIX executable bits.
tests/builtin/runtime/test_external_skills.py::test_explicit_external_skill_import_captures_exact_snapshot_and_enters_review chmod(0755) on a Windows fixture is assumed to provide POSIX executable metadata.
tests/test_cli.py::test_remote_enroll_can_install_automatic_service_in_one_command Windows st_mode is compared directly to POSIX 0600.
tests/test_openclaw_cli.py::test_build_openclaw_plugin_runs_pnpm_install_non_interactively The fake pnpm executable is a shebang script without a Windows launcher.
tests/test_opencode_cli.py::test_run_opencode_probe_executes_request_waits_for_nonce_and_stops_process _assert_process_stopped() treats os.kill(pid, 0) as a POSIX liveness check and catches only ProcessLookupError.
tests/test_opencode_cli.py::test_run_opencode_probe_handles_process_exit_and_stops_process Same subprocess assertion.
tests/test_opencode_cli.py::test_run_opencode_probe_times_out_and_stops_process Same subprocess assertion.
tests/test_service_bootstrap.py::test_unsafe_retry_state_exits_nonzero_and_removes_token[group-readable] A launchd/POSIX mode check runs on Windows, where the implementation deliberately does not apply POSIX permission bits.

The first seven nodes and the parameterized retry-state test reproduced 8 failures and 1 platform skip in an unmodified checkout.

Also run these nodes with pytest's default temporary root on a Windows machine where long-path support is disabled:

uv run pytest -q tests/test_cli_workbuddy.py::test_setup_workbuddy_remote_checkout_refreshes_the_requested_ref tests/test_opencode_cli.py::test_remote_checkout_cache_is_scoped_by_source_and_resolved_commit tests/test_opencode_cli.py::test_remote_checkout_refresh_failure_keeps_previous_commit

The default user temporary path, pytest's descriptive directory names, nested cache layout, and backup UUIDs can exceed the traditional path limit. In the same environment, all three tests pass with a sufficiently short, unused --basetemp root, such as D:\pc-win-audit-tests.

Expected behavior

  • Portable byte-preservation tests use explicit input bytes/newlines and compare against those inputs. They retain exact snapshot guarantees.
  • POSIX-only permission or execution-mode assertions are scoped to the applicable platform; archive metadata tests can use explicit ZIP mode metadata. Windows ACL claims require Windows-specific evidence rather than POSIX mode bits.
  • Subprocess fixtures are executable on their target platform, and process-exit assertions use the appropriate Windows semantics without weakening the cleanup guarantee.
  • Test temporary paths leave room for staging and backup names, including on systems without long-path support.
  • Windows regression coverage protects these corrected behaviors. Keep genuine unsupported-platform checks explicit.

Actual behavior

Observed failures include CRLF-versus-LF byte mismatches, mode 0644 versus 0755, 0666 versus 0600, WinError 193 for the fake executable, WinError 87 in the exited-process assertion, and failures to create/rename/remove overlong fixture paths. None of those observations alone establishes a product security or data-integrity defect.

The Python 3.11–3.14 matrix in Main runs on Ubuntu. The Windows job in Native personal service covers selected cursor and service lifecycle scenarios, so it does not catch these unit-test assumptions.

Environment

  • Upstream master: 80d618bd61432d1bb4eae85433fa22f2bbd50bce.
  • Windows x64, CPython 3.12.13, Windows LongPathsEnabled=0.
  • The short-root control changed neither production code nor the machine's long-path setting.
  • fix: Establish Windows support test coverage #1308 is closed. The three separate systemd receiver tests already have a Linux-platform fixture in open PR feat: add database-backed distributed work runtime #1446 and are excluded from this issue. Open PR feat(topic-memory): add end-to-end topic memory #1490 adds native-service failure annotations, not these unit-test fixes.
  • The python3/WindowsApps failure is also excluded: the unchanged helper test passed after supplying an actual python3 command in a temporary environment.
  • No open issue or PR was found fixing the remaining cases listed above.
  • AI assistance: OpenAI Codex assisted with reproduction, platform classification, duplicate checking, and this report.

Are you willing to submit a PR to fix this bug?

  • Yes, I would like to submit a PR.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions